0/5]
PATCH v2 1/1 0/5]
These patches converts the remaining sh4 devices to the memory API. The patch "sh_intc: convert interrupt controller to memory API" is somewhat tricky
V2:
Cosmetic change of a memory region size in "sh7750: convert memory controller/ioport to memory API".
Remove the realloc in "convert interrupt controller to memory API" to make is safer even we loose some extra pointers.
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 | 85 +++++++++++++++++++--------- 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, 215 insertions(+), 146 deletions(-)
Signature · 1 line
1.7.5.4
PATCH v2 1/1 1/5] sh7750: convert memory controller/ioport to memory API
--- 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 v2 1/1 4/5] sh_intc: convert interrupt controller to memory API
In reply to Benoît Canet--- hw/sh7750.c | 2 +- hw/sh_intc.c | 85 ++++++++++++++++++++++++++++++++++----------------- hw/sh_intc.h | 7 +++- target-sh4/helper.c | 3 ++ 4 files changed, 66 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 +57 -28
148 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 v2 1/1 2/5] sh7750: convert cache and tlb to memory API
In reply to Benoît Canet--- 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 v2 1/1 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
PATCH v2 1/1 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
Avi Kivity
AppliedQuoted 5 lines · Benoît Canet
These patches converts the remaining sh4 devices to the memory API. The patch "
sh_intc: convert interrupt controller to memory API" is somewhat tricky
Thanks, applied. Please adjust your editor to display tabs as 8 positions, not 4. Your patches had wierd indentation due to that, which I adjusted before applying.
Signature · 1 line
error compiling committee.c: too many arguments to function