From: Michel Pollet Date: Sun, 2 Jun 2013 17:29:45 +0000 (+0100) Subject: io,elf: pass the trace section name to getirq X-Git-Tag: v1.1~16 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=77c0525fa53ac81daaf277593767cc5659e2e43e;p=sx%2Fsimavr.git io,elf: pass the trace section name to getirq avr_iomem_getirq() now takes a 'name' for the IRQs. The elf loader now passes down the trace name so the irq gets named properly. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_elf.c b/simavr/sim/sim_elf.c index 90afccf..3f58825 100644 --- a/simavr/sim/sim_elf.c +++ b/simavr/sim/sim_elf.c @@ -79,7 +79,10 @@ void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware) for (int ti = 0; ti < firmware->tracecount; ti++) { if (firmware->trace[ti].mask == 0xff || firmware->trace[ti].mask == 0) { // easy one - avr_irq_t * all = avr_iomem_getirq(avr, firmware->trace[ti].addr, AVR_IOMEM_IRQ_ALL); + avr_irq_t * all = avr_iomem_getirq(avr, + firmware->trace[ti].addr, + firmware->trace[ti].name, + AVR_IOMEM_IRQ_ALL); if (!all) { AVR_LOG(avr, LOG_ERROR, "ELF: %s: unable to attach trace to address %04x\n", __FUNCTION__, firmware->trace[ti].addr); @@ -93,7 +96,10 @@ void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware) count++; for (int bi = 0; bi < 8; bi++) if (firmware->trace[ti].mask & (1 << bi)) { - avr_irq_t * bit = avr_iomem_getirq(avr, firmware->trace[ti].addr, bi); + avr_irq_t * bit = avr_iomem_getirq(avr, + firmware->trace[ti].addr, + firmware->trace[ti].name, + bi); if (!bit) { AVR_LOG(avr, LOG_ERROR, "ELF: %s: unable to attach trace to address %04x\n", __FUNCTION__, firmware->trace[ti].addr); diff --git a/simavr/sim/sim_io.c b/simavr/sim/sim_io.c index 00c647e..f3fff7c 100644 --- a/simavr/sim/sim_io.c +++ b/simavr/sim/sim_io.c @@ -158,8 +158,11 @@ avr_irq_t * avr_iomem_getirq( avr_t * avr, avr_io_addr_t addr, + const char * name, int index) { + if (index > 8) + return NULL; avr_io_addr_t a = AVR_DATA_TO_IO(addr); if (avr->io[a].irq == NULL) { /* @@ -182,7 +185,15 @@ avr_iomem_getirq( for (int i = 0; i < 8; i++) avr->io[a].irq[i].flags |= IRQ_FLAG_FILTERED; } - return index < 9 ? avr->io[a].irq + index : NULL; + // if given a name, replace the default one... + if (name) { + int l = strlen(name); + char n[l + 10]; + sprintf(n, "avr.io.%s", name); + free((void*)avr->io[a].irq[index].name); + avr->io[a].irq[index].name = strdup(n); + } + return avr->io[a].irq + index; } avr_irq_t * diff --git a/simavr/sim/sim_io.h b/simavr/sim/sim_io.h index f0d44e6..32541ab 100644 --- a/simavr/sim/sim_io.h +++ b/simavr/sim/sim_io.h @@ -113,6 +113,7 @@ avr_irq_t * avr_iomem_getirq( avr_t * avr, avr_io_addr_t addr, + const char * name /* Optional, if NULL, "ioXXXX" will be used */ , int index); // Terminates all IOs and remove from them from the io chain