Convert remaining sh4 devices to memory API
PATCH 1/5 sh7750: convert memory controller/ioport to memory API
In reply to Benoît Canet--- hw/r2d.c | 2 +- hw/sh.h | 3 +- hw/sh7750.c | 72 ++++++++++++++++++++++++++++++++++++---------------------- hw/shix.c | 2 +- 4 files changed, 49 insertions(+), 30 deletions(-)
hw/r2d.c +1 -1
@@ -250,7 +250,7 @@ static void r2d_init(ram_addr_t ram_size,memory_region_init_ram (sdram,NULL ,"r2d.sdram" ,SDRAM_SIZE );memory_region_add_subregion (address_space_mem,SDRAM_BASE , sdram);/* Register peripherals */ - s =sh7750_init (env); + s =sh7750_init (env, address_space_mem); irq =r2d_fpga_init (address_space_mem,0x04000000 ,sh7750_irl (s));sysbus_create_varargs ("sh_pci" ,0x1e200000 , irq[PCI_INTA ], irq[PCI_INTB ], irq[PCI_INTC ], irq[PCI_INTD ],NULL );
hw/sh.h +2 -1
@@ -9,8 +9,9 @@/* sh7750.c */ struct SH7750State ; +struct MemoryRegion ; -struct SH7750State *sh7750_init (CPUState * cpu); +struct SH7750State *sh7750_init (CPUState * cpu,struct MemoryRegion *sysmem); typedef struct { /* The callback will be triggered if any of the designated lines change */
hw/sh7750.c +45 -27
101 lines not on this page · raw message
hw/shix.c +1 -1
@@ -80,7 +80,7 @@ static void shix_init(ram_addr_t ram_size, }/* Register peripherals */ - s =sh7750_init (env); + s =sh7750_init (env, sysmem);/* XXXXX Check success */ tc58128_init (s,"shix_linux_nand.bin" ,NULL );fprintf (stderr,"initialization terminated\n" );
Signature · 1 line
1.7.5.4
PATCH 3/5 sh_timer: convert to memory API
In reply to Benoît Canet--- hw/sh.h | 3 ++- hw/sh7750.c | 4 ++-- hw/sh_timer.c | 43 ++++++++++++++++++++++++------------------- 3 files changed, 28 insertions(+), 22 deletions(-)
hw/sh.h +2 -1
@@ -31,7 +31,8 @@ int sh7750_register_io_device(struct SH7750State *s,#define TMU012_FEAT_TOCR (1 << 0)#define TMU012_FEAT_3CHAN (1 << 1)#define TMU012_FEAT_EXTCLK (1 << 2) -void tmu012_init (target_phys_addr_t base,int feat,uint32_t freq, +void tmu012_init (struct MemoryRegion *sysmem,target_phys_addr_t base, +int feat,uint32_t freq,qemu_irq ch0_irq,qemu_irq ch1_irq,qemu_irq ch2_irq0,qemu_irq ch2_irq1);
hw/sh7750.c +2 -2
@@ -780,7 +780,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem)NULL , s->intc.irqs[SCIF_BRI]); - tmu012_init(0x1fd80000, + tmu012_init(sysmem, 0x1fd80000, TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK, s->periph_freq, s->intc.irqs[TMU0],
@@ -804,7 +804,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem)sh_intc_register_sources (&s->intc,_INTC_ARRAY (vectors_tmu34),NULL ,0 ); -tmu012_init (0x1e100000 ,0 , s->periph_freq, +tmu012_init (sysmem,0x1e100000 ,0 , s->periph_freq, s->intc.irqs[TMU3 ], s->intc.irqs[TMU4 ],NULL ,NULL );
hw/sh_timer.c +24 -19
83 lines not on this page · raw message
Signature · 1 line
1.7.5.4
cover Convert remaining sh4 devices to memory API
These patches converts the remaining sh4 devices to the memory API. The patch "sh_intc: convert interrupt controller to memory API" is somewhat tricky.
Benoît Canet (5):
sh7750: convert memory controller/ioport to memory API
sh7750: convert cache and tlb to memory API
sh_timer: convert to memory API
sh_intc: convert interrupt controller to memory API
sh_serial: convert to memory API
hw/r2d.c | 2 +- hw/sh.h | 9 ++- hw/sh7750.c | 155 +++++++++++++++++++++++++++++---------------------- hw/sh_intc.c | 87 +++++++++++++++++++--------- hw/sh_intc.h | 7 ++- hw/sh_serial.c | 55 ++++++++++-------- hw/sh_timer.c | 43 ++++++++------ hw/shix.c | 2 +- target-sh4/helper.c | 3 + 9 files changed, 217 insertions(+), 146 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 2/5 sh7750: convert cache and tlb to memory API
--- hw/sh7750.c | 43 ++++++++++++++++++++++--------------------- 1 files changed, 22 insertions(+), 21 deletions(-)
hw/sh7750.c +22 -21
@@ -42,6 +42,7 @@ typedef struct SH7750State {MemoryRegion iomem_ff8;MemoryRegion iomem_1fc;MemoryRegion iomem_ffc; +MemoryRegion mmct_iomem;/* CPU */ CPUSH4State *cpu;/* Peripheral frequency in Hz */
@@ -623,18 +624,23 @@ static struct intc_group groups_irl[] = {#define MM_UTLB_DATA (7)#define MM_REGION_TYPE (addr) ((addr & MM_REGION_MASK) >> 24) -static uint32_t invalid_read (void *opaque,target_phys_addr_t addr) +static uint64_t invalid_read (void *opaque,target_phys_addr_t addr) {abort ();return 0 ; } -static uint32_t sh7750_mmct_readl (void *opaque,target_phys_addr_t addr) +static uint64_t sh7750_mmct_read (void *opaque,target_phys_addr_t addr, +unsigned size) {SH7750State *s = opaque;uint32_t ret =0 ; +if (size !=4 ) { +return invalid_read (opaque, addr); + } +switch (MM_REGION_TYPE (addr)) {case MM_ICACHE_ADDR :case MM_ICACHE_DATA :
@@ -664,16 +670,20 @@ static uint32_t sh7750_mmct_readl(void *opaque, target_phys_addr_t addr) }static void invalid_write (void *opaque,target_phys_addr_t addr, -uint32_t mem_value) +uint64_t mem_value) {abort (); } -static void sh7750_mmct_writel (void *opaque,target_phys_addr_t addr, -uint32_t mem_value) +static void sh7750_mmct_write (void *opaque,target_phys_addr_t addr, +uint64_t mem_value,unsigned size) {SH7750State *s = opaque; +if (size !=4 ) { +invalid_write (opaque, addr, mem_value); + } +switch (MM_REGION_TYPE (addr)) {case MM_ICACHE_ADDR :case MM_ICACHE_DATA :
@@ -702,22 +712,15 @@ static void sh7750_mmct_writel(void *opaque, target_phys_addr_t addr, } } -static CPUReadMemoryFunc *const sh7750_mmct_read[] = { - invalid_read, - invalid_read, - sh7750_mmct_readl -}; - -static CPUWriteMemoryFunc *const sh7750_mmct_write[] = { - invalid_write, - invalid_write, - sh7750_mmct_writel +static const struct MemoryRegionOps sh7750_mmct_ops = { + .read = sh7750_mmct_read, + .write = sh7750_mmct_write, + .endianness =DEVICE_NATIVE_ENDIAN , };SH7750State *sh7750_init (CPUSH4State * cpu,MemoryRegion *sysmem) {SH7750State *s; -int sh7750_mm_cache_and_tlb;/* memory mapped cache and tlb */ s =g_malloc0 (sizeof (SH7750State)); s->cpu = cpu;
@@ -749,11 +752,9 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) &s->iomem, 0x1fc00000, 0x1000);memory_region_add_subregion (sysmem,0xffc00000 , &s->iomem_ffc); - sh7750_mm_cache_and_tlb =cpu_register_io_memory (sh7750_mmct_read, - sh7750_mmct_write, s, -DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (0xf0000000 ,0x08000000 , - sh7750_mm_cache_and_tlb); +memory_region_init_io (&s->mmct_iomem, &sh7750_mmct_ops, s, +"cache-and-tlb" ,0x08000000 ); +memory_region_add_subregion (sysmem,0xf0000000 , &s->mmct_iomem); sh_intc_init(&s->intc, NR_SOURCES, _INTC_ARRAY(mask_registers),
Signature · 1 line
1.7.5.4
PATCH 4/5 sh_intc: convert interrupt controller to memory API
In reply to Benoît Canet--- hw/sh7750.c | 2 +- hw/sh_intc.c | 87 ++++++++++++++++++++++++++++++++++---------------- hw/sh_intc.h | 7 +++- target-sh4/helper.c | 3 ++ 4 files changed, 68 insertions(+), 31 deletions(-)
hw/sh7750.c +1 -1
@@ -756,7 +756,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) "cache-and-tlb", 0x08000000);memory_region_add_subregion (sysmem,0xf0000000 , &s->mmct_iomem); -sh_intc_init (&s->intc,NR_SOURCES , +sh_intc_init (sysmem, &s->intc,NR_SOURCES ,_INTC_ARRAY (mask_registers),_INTC_ARRAY (prio_registers));
hw/sh_intc.c +59 -28
150 lines not on this page · raw message
hw/sh_intc.h +5 -2
@@ -3,6 +3,7 @@#include "qemu-common.h" #include "irq.h" +#include "exec-memory.h" typedef unsigned char intc_enum ;
@@ -46,6 +47,8 @@ struct intc_source { };struct intc_desc { +MemoryRegion iomem; +MemoryRegion *iomem_aliases;qemu_irq *irqs;struct intc_source *sources;int nr_sources;
@@ -53,7 +56,6 @@ struct intc_desc {int nr_mask_regs;struct intc_prio_reg *prio_regs;int nr_prio_regs; -int iomemtype;int pending;/* number of interrupt sources that has pending set */ };
@@ -68,7 +70,8 @@ void sh_intc_register_sources(struct intc_desc *desc,struct intc_group *groups, int nr_groups); -int sh_intc_init(struct intc_desc *desc, +int sh_intc_init(MemoryRegion *sysmem, + struct intc_desc *desc, int nr_sources, struct intc_mask_reg *mask_regs, int nr_mask_regs,
target-sh4/helper.c +3 -0
@@ -24,7 +24,10 @@#include <signal.h> #include "cpu.h" + +#if !defined(CONFIG_USER_ONLY )#include "hw/sh_intc.h" +#endif #if defined(CONFIG_USER_ONLY )
Signature · 1 line
1.7.5.4
PATCH 5/5 sh_serial: convert to memory API
In reply to Benoît Canet--- hw/sh.h | 3 ++- hw/sh7750.c | 28 +++++++++++++++------------- hw/sh_serial.c | 55 ++++++++++++++++++++++++++++++------------------------- 3 files changed, 47 insertions(+), 39 deletions(-)
hw/sh.h +2 -1
@@ -39,7 +39,8 @@ void tmu012_init(struct MemoryRegion *sysmem, target_phys_addr_t base,/* sh_serial.c */ #define SH_SERIAL_FEAT_SCIF (1 << 0) -void sh_serial_init (target_phys_addr_t base, int feat, +void sh_serial_init(MemoryRegion *sysmem, + target_phys_addr_t base, int feat, uint32_t freq, CharDriverState *chr, qemu_irq eri_source, qemu_irq rxi_source,
hw/sh7750.c +15 -13
@@ -766,19 +766,21 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) cpu->intc_handle = &s->intc; -sh_serial_init (0x1fe00000 ,0 , s->periph_freq, serial_hds[0 ], - s->intc.irqs[SCI1_ERI ], - s->intc.irqs[SCI1_RXI ], - s->intc.irqs[SCI1_TXI ], - s->intc.irqs[SCI1_TEI ], -NULL ); -sh_serial_init (0x1fe80000 ,SH_SERIAL_FEAT_SCIF , - s->periph_freq, serial_hds[1 ], - s->intc.irqs[SCIF_ERI ], - s->intc.irqs[SCIF_RXI ], - s->intc.irqs[SCIF_TXI ], -NULL , - s->intc.irqs[SCIF_BRI ]); +sh_serial_init (sysmem,0x1fe00000 , +0 , s->periph_freq, serial_hds[0 ], + s->intc.irqs[SCI1_ERI ], + s->intc.irqs[SCI1_RXI ], + s->intc.irqs[SCI1_TXI ], + s->intc.irqs[SCI1_TEI ], +NULL ); +sh_serial_init (sysmem,0x1fe80000 , +SH_SERIAL_FEAT_SCIF , + s->periph_freq, serial_hds[1 ], + s->intc.irqs[SCIF_ERI ], + s->intc.irqs[SCIF_RXI ], + s->intc.irqs[SCIF_TXI ], +NULL , + s->intc.irqs[SCIF_BRI ]); tmu012_init(sysmem, 0x1fd80000, TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK,
hw/sh_serial.c +30 -25
95 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Re: [Qemu-devel] [PATCH 1/5] sh7750: convert memory controller/ioport to memory API
In reply to Benoît CanetQuoted 24 lines · Benoît Canet
Signed-off-by Benoit Canet <[email protected]>/* sh775x interrupt controller tables for
sh_intc.chw/sh7750.c +1
-9@@ -706,30 +714,40 @@ static CPUWriteMemoryFunc * const sh7750_mmct_write[] = { sh7750_mmct_writel }; -SH7750State *sh7750_init (CPUSH4State * cpu) +SH7750State *sh7750_init (CPUSH4State * cpu,MemoryRegion *sysmem) {SH7750State *s; -int sh7750_io_memory;int sh7750_mm_cache_and_tlb;/* memory mapped cache and tlb */ s =g_malloc0 (sizeof (SH7750State)); s->cpu = cpu; s->periph_freq =60000000 ;/* 60MHz */ - sh7750_io_memory =cpu_register_io_memory (sh7750_mem_read, - sh7750_mem_write, s, -DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory_offset (0x1f000000 ,0x1000 , - sh7750_io_memory,0x1f000000 ); -cpu_register_physical_memory_offset (0xff000000 ,0x1000 , - sh7750_io_memory,0x1f000000 );
hw/sh7750.c static CPUWriteMemoryFunc * const sh7750_mmct_write[] = { · line 726
Quoted 10 lines
hw/sh7750.c +2
-8-cpu_register_physical_memory_offset (0x1f800000 ,0x1000 , - sh7750_io_memory,0x1f800000 ); -cpu_register_physical_memory_offset (0xff800000 ,0x1000 , - sh7750_io_memory,0x1f800000 ); -cpu_register_physical_memory_offset (0x1fc00000 ,0x1000 , - sh7750_io_memory,0x1fc00000 ); -cpu_register_physical_memory_offset (0xffc00000 ,0x1000 , - sh7750_io_memory,0x1fc00000 ); +memory_region_init_io (&s->iomem, &sh7750_mem_ops, s, +"memory" ,0x1fe00000 );
Any size >= 0x1fc01000 will work here, why did you pick px1fe00000? just curious.
I see serial starts at that address, but note that even a larger size won't interfere, since we never add anything to sysmem at that address.
Anyway, no need to change the patch, since it will work just fine.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 4/5] sh_intc: convert interrupt controller to memory API
In reply to Benoît Canet2011/11/17 Benoît Canet <[email protected]>:
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) · line 761
Quoted 11 lines
Signed-off-by Benoit Canet <[email protected]>hw/sh7750.c +1
-1@@ -756,7 +756,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) "cache-and-tlb", 0x08000000); memory_region_add_subregion(sysmem, 0xf0000000, &s->mmct_iomem); - sh_intc_init(&s->intc, NR_SOURCES, + sh_intc_init(sysmem, &s->intc, NR_SOURCES, _INTC_ARRAY(mask_registers), _INTC_ARRAY(prio_registers));
This would be nicer as a sysbus device so we didn't have to hand it the sysmem, but that can be done later if we care enough I guess.
Quoted 6 lines
hw/sh7750.c +6
-0+ iomem = &desc->iomem; + iomem_p4 = desc->iomem_aliases + index; + iomem_a7 = iomem_p4 + 1; + +#define SH_INTC_IOMEM_FORMAT "interrupt-controller-%s-%s-%s" + snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "p4");
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem)
Quoted 10 lines
hw/sh7750.c +10
-0+ memory_region_init_alias(iomem_p4, name, iomem, INTC_A7(address), 4); + memory_region_add_subregion(sysmem, P4ADDR(address), iomem_p4); + + snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "a7"); + memory_region_init_alias(iomem_a7, name, iomem, INTC_A7(address), 4); + memory_region_add_subregion(sysmem, A7ADDR(address), iomem_a7); +#undef SH_INTC_IOMEM_FORMAT + + /* used to increment aliases index */ + return 2;
This is going to give us 6 * 2 * 2 = 24 four-byte memory regions, incidentally. That should be OK, but one memory region per register is an interesting arrangement.
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 452
Quoted 7 lines
hw/sh7750.c +3
-0@@ -430,7 +447,11 @@ int sh_intc_init(struct intc_desc *desc, desc->nr_mask_regs = nr_mask_regs; desc->prio_regs = prio_regs; desc->nr_prio_regs = nr_prio_regs; + /* Allocate 4 MemoryRegions per register (2 actions * 2 aliases). */ + desc->iomem_aliases = g_new0(MemoryRegion, + (nr_mask_regs + nr_prio_regs) * 4);
This should be exactly the right size...
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 455
Quoted 3 lines
hw/sh7750.c +3
-0+ /* free unused MemoryRegions */ + desc->iomem_aliases = g_realloc(desc->iomem_aliases, + sizeof(MemoryRegion)*j);
making this realloc unnecessary; or am I missing something?
-- PMM
Re: [Qemu-devel] [PATCH 4/5] sh_intc: convert interrupt controller to memory API
Quoted 8 lines · Peter Maydell
2011/11/17 Benoît Canet <[email protected]>:
Quoted 7 lines
Signed-off-by Benoit Canet <[email protected]>hw/sh7750.c +0
-0@@ -756,7 +756,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) "cache-and-tlb", 0x08000000);memory_region_add_subregion (sysmem,0xf0000000 , &s->mmct_iomem);
Quoted 7 lines
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) · line 761
Quoted 4 lines
hw/sh7750.c +1
-1-sh_intc_init (&s->intc,NR_SOURCES , +sh_intc_init (sysmem, &s->intc,NR_SOURCES ,_INTC_ARRAY (mask_registers),_INTC_ARRAY (prio_registers));This would be nicer as a sysbus device so we didn't have to hand it the sysmem, but that can be done later if we care enough I guess.
Later, yes.
Quoted 13 lines
Quoted 13 lines
hw/sh7750.c +12
-0+ iomem = &desc->iomem; + iomem_p4 = desc->iomem_aliases + index; + iomem_a7 = iomem_p4 +1 ; + +#define SH_INTC_IOMEM_FORMAT "interrupt-controller-%s-%s-%s" +snprintf (name,sizeof (name),SH_INTC_IOMEM_FORMAT , type, action,"p4" ); +memory_region_init_alias (iomem_p4, name, iomem,INTC_A7 (address),4 ); +memory_region_add_subregion (sysmem,P4ADDR (address), iomem_p4); + +snprintf (name,sizeof (name),SH_INTC_IOMEM_FORMAT , type, action,"a7" ); +memory_region_init_alias (iomem_a7, name, iomem,INTC_A7 (address),4 ); +memory_region_add_subregion (sysmem,A7ADDR (address), iomem_a7);
Quoted 8 lines
hw/sh7750.c
Quoted 4 lines
hw/sh7750.c +4
-0+#undef SH_INTC_IOMEM_FORMAT + +/* used to increment aliases index */ +return 2 ;This is going to give us 6 * 2 * 2 = 24 four-byte memory regions, incidentally. That should be OK, but one memory region per register is an interesting arrangement.
In fact if we introduce a Register class there's no reason it won't be a MemoryRegion. So any Register would be a MemoryRegion, we could have thousands in a system. I don't see anything wrong with it, do you?
Quoted 11 lines
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 452
Quoted 8 lines
hw/sh7750.c +3
-0@@ -430,7 +447,11 @@ int sh_intc_init(struct intc_desc *desc, desc->nr_mask_regs = nr_mask_regs; desc->prio_regs = prio_regs; desc->nr_prio_regs = nr_prio_regs; +/* Allocate 4 MemoryRegions per register (2 actions * 2 aliases). */ + desc->iomem_aliases =g_new0 (MemoryRegion, + (nr_mask_regs + nr_prio_regs) *4 );This should be exactly the right size...
Quoted 6 lines
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 455
Quoted 3 lines
hw/sh7750.c +3
-0+/* free unused MemoryRegions */ + desc->iomem_aliases =g_realloc (desc->iomem_aliases, +sizeof (MemoryRegion)*j);making this realloc unnecessary; or am I missing something?
Not all calls to sh_intc_register() return 2.
However, calling realloc() in a MemoryRegion array is not a good idea, since the pointers may leak (memory_region_add_subregion() does this). It's true that a size-reducing realloc doesn't change the pointer, yet it makes me uncomfortable.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 4/5] sh_intc: convert interrupt controller to memory API
In reply to Peter MaydellYes, allocating the exact size would make the realloc unnecessary. But it involve more code to walk one more time through the mask_reg and prio_reg array before allocating.
I made it this way to make code shorter.
The freed MemoryRegion are not initialized at all.
However as realloc seems to be a bad idea I need something to compute the exact size in a minimum of code.
2011/11/17 Peter Maydell <[email protected]>
Quoted 60 lines
2011/11/17 Benoît Canet <[email protected]>:
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu,
Quoted 4 lines
Signed-off-by Benoit Canet <[email protected]>hw/sh7750.c +0
-0@@ -756,7 +756,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu,MemoryRegion *sysmem)
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem) · line 761
Quoted 7 lines
hw/sh7750.c +1
-1"cache-and-tlb", 0x08000000);memory_region_add_subregion (sysmem,0xf0000000 , &s->mmct_iomem); -sh_intc_init (&s->intc,NR_SOURCES , +sh_intc_init (sysmem, &s->intc,NR_SOURCES ,_INTC_ARRAY (mask_registers),_INTC_ARRAY (prio_registers));This would be nicer as a sysbus device so we didn't have to hand it the sysmem, but that can be done later if we care enough I guess.
hw/sh7750.c SH7750State *sh7750_init(CPUSH4State * cpu,
Quoted 6 lines
hw/sh7750.c +6
-0+ iomem = &desc->iomem; + iomem_p4 = desc->iomem_aliases + index; + iomem_a7 = iomem_p4 +1 ; + +#define SH_INTC_IOMEM_FORMAT "interrupt-controller-%s-%s-%s" + snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action,"p4");
Quoted 1 line
+ memory_region_init_alias(iomem_p4, name, iomem,
INTC_A7(address),4);
hw/sh7750.c
Quoted 3 lines
hw/sh7750.c +3
-0+memory_region_add_subregion (sysmem,P4ADDR (address), iomem_p4); + + snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action,"a7");
Quoted 1 line
+ memory_region_init_alias(iomem_a7, name, iomem,
INTC_A7(address),4);
hw/sh7750.c
Quoted 5 lines
hw/sh7750.c +5
-0+memory_region_add_subregion (sysmem,A7ADDR (address), iomem_a7); +#undef SH_INTC_IOMEM_FORMAT + +/* used to increment aliases index */ +return 2 ;This is going to give us 6 * 2 * 2 = 24 four-byte memory regions, incidentally. That should be OK, but one memory region per register is an interesting arrangement.
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 452
Quoted 7 lines
hw/sh7750.c +3
-0@@ -430,7 +447,11 @@ int sh_intc_init(struct intc_desc *desc, desc->nr_mask_regs = nr_mask_regs; desc->prio_regs = prio_regs; desc->nr_prio_regs = nr_prio_regs; +/* Allocate 4 MemoryRegions per register (2 actions * 2 aliases). */ + desc->iomem_aliases =g_new0 (MemoryRegion, + (nr_mask_regs + nr_prio_regs) *4 );This should be exactly the right size...
hw/sh7750.c int sh_intc_init(struct intc_desc *desc, · line 455
Quoted 3 lines
hw/sh7750.c +3
-0+/* free unused MemoryRegions */ + desc->iomem_aliases =g_realloc (desc->iomem_aliases, +sizeof (MemoryRegion)*j);making this realloc unnecessary; or am I missing something?
-- PMM