etrax-pic: Convert to MemoryRegion
PATCH 1/5 etrax-pic: Convert to MemoryRegion
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
--- hw/etraxfs_pic.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
hw/etraxfs_pic.c +15 -15
@@ -39,6 +39,7 @@struct etrax_pic {SysBusDevice busdev; +MemoryRegion mmio;void *interrupt_vector;qemu_irq parent_irq;qemu_irq parent_nmi;
@@ -77,7 +78,8 @@ static void pic_update(struct etrax_pic *fs)qemu_set_irq (fs->parent_irq, !!vector); } -static uint32_t pic_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +pic_read (void *opaque,target_phys_addr_t addr,unsigned int size) {struct etrax_pic *fs = opaque;uint32_t rval;
@@ -87,8 +89,8 @@ static uint32_t pic_readl (void *opaque, target_phys_addr_t addr)return rval; } -static void -pic_writel (void *opaque,target_phys_addr_t addr,uint32_t value) +static void pic_write (void *opaque,target_phys_addr_t addr, +uint64_t value,unsigned int size) {struct etrax_pic *fs = opaque;D (printf ("%s addr=%x val=%x\n" , __func__, addr, value));
@@ -99,14 +101,14 @@ pic_writel (void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc *const pic_read[] = { -NULL ,NULL , - &pic_readl, -}; - -static CPUWriteMemoryFunc *const pic_write[] = { -NULL ,NULL , - &pic_writel, +static const MemoryRegionOps pic_ops = { + .read = pic_read, + .write = pic_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 + } };static void nmi_handler (void *opaque,int irq,int level)
@@ -139,15 +141,13 @@ static void irq_handler(void *opaque, int irq, int level)static int etraxfs_pic_init (SysBusDevice *dev) {struct etrax_pic *s =FROM_SYSBUS (typeof (*s), dev); -int intr_vect_regs;qdev_init_gpio_in (&dev->qdev, irq_handler,32 );sysbus_init_irq (dev, &s->parent_irq);sysbus_init_irq (dev, &s->parent_nmi); - intr_vect_regs =cpu_register_io_memory (pic_read, pic_write, s, -DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (dev,R_MAX *4 , intr_vect_regs); +memory_region_init_io (&s->mmio, &pic_ops, s,"etraxfs-pic" ,R_MAX *4 ); +sysbus_init_mmio_region (dev, &s->mmio);return 0 ; }
Signature · 1 line
1.7.5.4
PATCH 2/5 etrax-ser: Convert to MemoryRegion
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
--- hw/etraxfs_ser.c | 33 ++++++++++++++++++--------------- 1 files changed, 18 insertions(+), 15 deletions(-)
hw/etraxfs_ser.c +18 -15
@@ -47,6 +47,7 @@struct etrax_serial {SysBusDevice busdev; +MemoryRegion mmio;CharDriverState *chr;qemu_irq irq;
@@ -73,7 +74,8 @@ static void ser_update_irq(struct etrax_serial *s)qemu_set_irq (s->irq, !!s->regs[R_MASKED_INTR ]); } -static uint32_t ser_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +ser_read (void *opaque,target_phys_addr_t addr,unsigned int size) {struct etrax_serial *s = opaque;D (CPUState *env = s->env);
@@ -108,10 +110,12 @@ static uint32_t ser_readl (void *opaque, target_phys_addr_t addr) }static void -ser_writel (void *opaque,target_phys_addr_t addr,uint32_t value) +ser_write (void *opaque,target_phys_addr_t addr, +uint64_t val64,unsigned int size) {struct etrax_serial *s = opaque; -unsigned char ch = value; +uint32_t value = val64; +unsigned char ch = val64;D (CPUState *env = s->env);D (qemu_log ("%s " TARGET_FMT_plx"=%x\n" , __func__, addr, value));
@@ -142,14 +146,14 @@ ser_writel (void *opaque, target_phys_addr_t addr, uint32_t value)ser_update_irq (s); } -static CPUReadMemoryFunc *const ser_read[] = { -NULL ,NULL , - &ser_readl, -}; - -static CPUWriteMemoryFunc *const ser_write[] = { -NULL ,NULL , - &ser_writel, +static const MemoryRegionOps ser_ops = { + .read = ser_read, + .write = ser_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 + } };static void serial_receive (void *opaque,const uint8_t *buf,int size)
@@ -207,12 +211,11 @@ static void etraxfs_ser_reset(DeviceState *d)static int etraxfs_ser_init (SysBusDevice *dev) {struct etrax_serial *s =FROM_SYSBUS (typeof (*s), dev); -int ser_regs;sysbus_init_irq (dev, &s->irq); - ser_regs =cpu_register_io_memory (ser_read, ser_write, s, -DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (dev,R_MAX *4 , ser_regs); +memory_region_init_io (&s->mmio, &ser_ops, s,"etraxfs-serial" ,R_MAX *4 ); +sysbus_init_mmio_region (dev, &s->mmio); + s->chr =qdev_init_chardev (&dev->qdev);if (s->chr) qemu_chr_add_handlers(s->chr,
Signature · 1 line
1.7.5.4
PATCH 3/5 etrax-timer: Convert to MemoryRegion
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
--- hw/etraxfs_timer.c | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-)
hw/etraxfs_timer.c +16 -15
@@ -43,6 +43,7 @@struct etrax_timer {SysBusDevice busdev; +MemoryRegion mmio;qemu_irq irq;qemu_irq nmi;
@@ -72,7 +73,8 @@ struct etrax_timer {uint32_t r_masked_intr; }; -static uint32_t timer_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +timer_read (void *opaque,target_phys_addr_t addr,unsigned int size) {struct etrax_timer *t = opaque;uint32_t r =0 ;
@@ -239,9 +241,11 @@ static inline void timer_watchdog_update(struct etrax_timer *t, uint32_t value) }static void -timer_writel (void *opaque,target_phys_addr_t addr,uint32_t value) +timer_write (void *opaque,target_phys_addr_t addr, +uint64_t val64,unsigned int size) {struct etrax_timer *t = opaque; +uint32_t value = val64;switch (addr) {
@@ -281,14 +285,14 @@ timer_writel (void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc *const timer_read[] = { -NULL ,NULL , - &timer_readl, -}; - -static CPUWriteMemoryFunc *const timer_write[] = { -NULL ,NULL , - &timer_writel, +static const MemoryRegionOps timer_ops = { + .read = timer_read, + .write = timer_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 + } };static void etraxfs_timer_reset (void *opaque)
@@ -307,7 +311,6 @@ static void etraxfs_timer_reset(void *opaque)static int etraxfs_timer_init (SysBusDevice *dev) {struct etrax_timer *t =FROM_SYSBUS (typeof (*t), dev); -int timer_regs; t->bh_t0 =qemu_bh_new (timer0_hit, t); t->bh_t1 =qemu_bh_new (timer1_hit, t);
@@ -319,10 +322,8 @@ static int etraxfs_timer_init(SysBusDevice *dev)sysbus_init_irq (dev, &t->irq);sysbus_init_irq (dev, &t->nmi); - timer_regs =cpu_register_io_memory (timer_read, timer_write, t, -DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (dev,0x5c , timer_regs); - +memory_region_init_io (&t->mmio, &timer_ops, t,"etraxfs-timer" ,0x5c ); +sysbus_init_mmio_region (dev, &t->mmio);qemu_register_reset (etraxfs_timer_reset, t);return 0 ; }
Signature · 1 line
1.7.5.4
PATCH 4/5 etrax-dma: Convert to MemoryRegion
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
--- hw/etraxfs_dma.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-)
hw/etraxfs_dma.c +27 -16
@@ -24,6 +24,7 @@#include <stdio.h> #include <sys/time.h> #include "hw.h" +#include "exec-memory.h" #include "qemu-common.h" #include "sysemu.h"
@@ -185,7 +186,7 @@ struct fs_dma_channelstruct fs_dma_ctrl { -int map; +MemoryRegion mmio;int nr_channels;struct fs_dma_channel *channels;
@@ -562,13 +563,17 @@ static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)return 0 ; } -static uint32_t -dma_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +dma_read (void *opaque,target_phys_addr_t addr,unsigned int size) {struct fs_dma_ctrl *ctrl = opaque;int c;uint32_t r =0 ; +if (size !=4 ) { +dma_rinvalid (opaque, addr); + } +/* Make addr relative to this channel and bounded to nr regs. */ c =fs_channel (addr); addr &=0xff ;
@@ -608,11 +613,17 @@ dma_update_state(struct fs_dma_ctrl *ctrl, int c) }static void -dma_writel (void *opaque,target_phys_addr_t addr,uint32_t value) +dma_write (void *opaque,target_phys_addr_t addr, +uint64_t val64,unsigned int size) {struct fs_dma_ctrl *ctrl = opaque; +uint32_t value = val64;int c; +if (size !=4 ) { +dma_winvalid (opaque, addr, value); + } +/* Make addr relative to this channel and bounded to nr regs. */ c =fs_channel (addr); addr &=0xff ;
@@ -668,16 +679,14 @@ dma_writel (void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc *const dma_read[] = { - &dma_rinvalid, - &dma_rinvalid, - &dma_readl, -}; - -static CPUWriteMemoryFunc *const dma_write[] = { - &dma_winvalid, - &dma_winvalid, - &dma_writel, +static const MemoryRegionOps dma_ops = { + .read = dma_read, + .write = dma_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 + } };static int etraxfs_dmac_run (void *opaque)
@@ -750,7 +759,9 @@ void *etraxfs_dmac_init(target_phys_addr_t base, int nr_channels) ctrl->nr_channels = nr_channels; ctrl->channels =qemu_mallocz (sizeof ctrl->channels[0 ] * nr_channels); - ctrl->map =cpu_register_io_memory (dma_read, dma_write, ctrl,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base, nr_channels *0x2000 , ctrl->map); +memory_region_init_io (&ctrl->mmio, &dma_ops, ctrl,"etraxfs-dma" , + nr_channels *0x2000 ); +memory_region_add_subregion (get_system_memory (), base, &ctrl->mmio); +return ctrl; }
Signature · 1 line
1.7.5.4
PATCH 5/5 etrax-eth: Convert to MemoryRegion
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
--- hw/etraxfs_eth.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-)
hw/etraxfs_eth.c +16 -14
@@ -320,6 +320,7 @@ static void mdio_cycle(struct qemu_mdio *bus)struct fs_eth {SysBusDevice busdev; +MemoryRegion mmio;NICState *nic;NICConf conf;int ethregs;
@@ -373,7 +374,8 @@ static void eth_validate_duplex(struct fs_eth *eth) } } -static uint32_t eth_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +eth_read (void *opaque,target_phys_addr_t addr,unsigned int size) {struct fs_eth *eth = opaque;uint32_t r =0 ;
@@ -417,9 +419,11 @@ static void eth_update_ma(struct fs_eth *eth, int ma) }static void -eth_writel (void *opaque,target_phys_addr_t addr,uint32_t value) +eth_write (void *opaque,target_phys_addr_t addr, +uint64_t val64,unsigned int size) {struct fs_eth *eth = opaque; +uint32_t value = val64; addr >>=2 ; switch (addr)
@@ -553,14 +557,14 @@ static void eth_set_link(VLANClientState *nc) eth->phy.link = !nc->link_down; } -static CPUReadMemoryFunc *const eth_read[] = { -NULL ,NULL , - ð_readl, -}; - -static CPUWriteMemoryFunc *const eth_write[] = { -NULL ,NULL , - ð_writel, +static const MemoryRegionOps eth_ops = { + .read = eth_read, + .write = eth_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 + } };static void eth_cleanup (VLANClientState *nc)
@@ -589,7 +593,6 @@ static NetClientInfo net_etraxfs_info = {static int fs_eth_init (SysBusDevice *dev) {struct fs_eth *s =FROM_SYSBUS (typeof (*s), dev); -int eth_regs;if (!s->dma_out || !s->dma_in) {hw_error ("Unconnected ETRAX-FS Ethernet MAC.\n" );
@@ -600,9 +603,8 @@ static int fs_eth_init(SysBusDevice *dev) s->dma_in->client.opaque = s; s->dma_in->client.pull =NULL ; - eth_regs =cpu_register_io_memory (eth_read, eth_write, s, -DEVICE_LITTLE_ENDIAN ); -sysbus_init_mmio (dev,0x5c , eth_regs); +memory_region_init_io (&s->mmio, ð_ops, s,"etraxfs-eth" ,0x5c ); +sysbus_init_mmio_region (dev, &s->mmio);qemu_macaddr_default_if_unset (&s->conf.macaddr); s->nic = qemu_new_nic(&net_etraxfs_info, &s->conf,
Signature · 1 line
1.7.5.4
Quoted 2 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Thanks, queued all 5 in the memory-region branch.
Signature · 1 line
error compiling committee.c: too many arguments to function