pxa2xx: memory API conversions
cover pxa2xx: memory API conversions
Convert most of pxa2xx periferal to memory API.
pxa2xx_dmai.c was intact appart because it use cpu_physical_memory_read/write internal and seems special.
Benoît Canet (10):
pxa2xx_gpio: convert to memory API
pxa2xx_pcmcia.c: convert common memory space to memory API pxa2xx_pcmcia.c: convert attribute memory space to memory API pxa2xx_pcmcia.c: convert io memory space to memory API pxa2xx_pcmcia.c: merge calls to get_system_memory()
pxa2xx_keypad: convert to memory API
pxa2xx_timer: convert to memory API
pxa2xx_pic: convert to memory API
pxa2xx_mmci: convert to memory API.
pxa2xx_lcd: convert to memory API
hw/pxa2xx_gpio.c | 29 ++++++---------- hw/pxa2xx_keypad.c | 30 +++++++--------- hw/pxa2xx_lcd.c | 30 +++++++--------- hw/pxa2xx_mmci.c | 28 ++++++++-------- hw/pxa2xx_pcmcia.c | 94 +++++++++++++++++++++++---------------------------- hw/pxa2xx_pic.c | 31 +++++++---------- hw/pxa2xx_timer.c | 28 +++++++--------- 7 files changed, 118 insertions(+), 152 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/10 pxa2xx_gpio: convert to memory API
--- hw/pxa2xx_gpio.c | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-)
hw/pxa2xx_gpio.c +11 -18
@@ -16,6 +16,7 @@typedef struct PXA2xxGPIOInfo PXA2xxGPIOInfo ;struct PXA2xxGPIOInfo {SysBusDevice busdev; +MemoryRegion iomem;qemu_irq irq0, irq1, irqX;int lines;int ncpu;
@@ -137,7 +138,8 @@ static void pxa2xx_gpio_handler_update(PXA2xxGPIOInfo *s) { } } -static uint32_t pxa2xx_gpio_read (void *opaque,target_phys_addr_t offset) +static uint64_t pxa2xx_gpio_read (void *opaque,target_phys_addr_t offset, +unsigned size) {PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;uint32_t ret;
@@ -188,8 +190,8 @@ static uint32_t pxa2xx_gpio_read(void *opaque, target_phys_addr_t offset)return 0 ; } -static void pxa2xx_gpio_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_gpio_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;int bank;
@@ -240,16 +242,10 @@ static void pxa2xx_gpio_write(void *opaque, } } -static CPUReadMemoryFunc *const pxa2xx_gpio_readfn[] = { - pxa2xx_gpio_read, - pxa2xx_gpio_read, - pxa2xx_gpio_read -}; - -static CPUWriteMemoryFunc *const pxa2xx_gpio_writefn[] = { - pxa2xx_gpio_write, - pxa2xx_gpio_write, - pxa2xx_gpio_write +static const MemoryRegionOps pxa_gpio_ops = { + .read = pxa2xx_gpio_read, + .write = pxa2xx_gpio_write, + .endianness =DEVICE_NATIVE_ENDIAN , }; DeviceState *pxa2xx_gpio_init(target_phys_addr_t base,
@@ -275,7 +271,6 @@ DeviceState *pxa2xx_gpio_init(target_phys_addr_t base,static int pxa2xx_gpio_initfn (SysBusDevice *dev) { -int iomemtype;PXA2xxGPIOInfo *s; s =FROM_SYSBUS (PXA2xxGPIOInfo, dev);
@@ -285,10 +280,8 @@ static int pxa2xx_gpio_initfn(SysBusDevice *dev)qdev_init_gpio_in (&dev->qdev, pxa2xx_gpio_set, s->lines);qdev_init_gpio_out (&dev->qdev, s->handler, s->lines); - iomemtype =cpu_register_io_memory (pxa2xx_gpio_readfn, - pxa2xx_gpio_writefn, s,DEVICE_NATIVE_ENDIAN ); - -sysbus_init_mmio (dev,0x1000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa_gpio_ops, s,"gpio" ,0x1000 ); +sysbus_init_mmio_region (dev, &s->iomem);sysbus_init_irq (dev, &s->irq0);sysbus_init_irq (dev, &s->irq1);sysbus_init_irq (dev, &s->irqX);
Signature · 1 line
1.7.4.1
PATCH 2/10 pxa2xx_pcmcia.c: convert common memory space to memory API
In reply to Benoît Canet--- hw/pxa2xx_pcmcia.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-)
hw/pxa2xx_pcmcia.c +14 -17
@@ -10,17 +10,19 @@#include "hw.h" #include "pcmcia.h" #include "pxa.h" +#include "exec-memory.h" struct PXA2xxPCMCIAState {PCMCIASocket slot;PCMCIACardState *card; +MemoryRegion common_iomem;qemu_irq irq;qemu_irq cd_irq; }; -static uint32_t pxa2xx_pcmcia_common_read (void *opaque, -target_phys_addr_t offset) +static uint64_t pxa2xx_pcmcia_common_read (void *opaque, +target_phys_addr_t offset,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -31,8 +33,8 @@ static uint32_t pxa2xx_pcmcia_common_read(void *opaque,return 0 ; } -static void pxa2xx_pcmcia_common_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_pcmcia_common_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -85,16 +87,10 @@ static void pxa2xx_pcmcia_io_write(void *opaque, } } -static CPUReadMemoryFunc *const pxa2xx_pcmcia_common_readfn[] = { - pxa2xx_pcmcia_common_read, - pxa2xx_pcmcia_common_read, - pxa2xx_pcmcia_common_read, -}; - -static CPUWriteMemoryFunc *const pxa2xx_pcmcia_common_writefn[] = { - pxa2xx_pcmcia_common_write, - pxa2xx_pcmcia_common_write, - pxa2xx_pcmcia_common_write, +static const MemoryRegionOps pxa2xx_pcmcia_common_ops = { + .read = pxa2xx_pcmcia_common_read, + .write = pxa2xx_pcmcia_common_write, + .endianness =DEVICE_NATIVE_ENDIAN };static CPUReadMemoryFunc *const pxa2xx_pcmcia_attr_readfn[] = {
@@ -151,9 +147,10 @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)cpu_register_physical_memory (base |0x08000000 ,0x04000000 , iomemtype);/* Socket Common Memory Space */ - iomemtype =cpu_register_io_memory (pxa2xx_pcmcia_common_readfn, - pxa2xx_pcmcia_common_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base |0x0c000000 ,0x04000000 , iomemtype); +memory_region_init_io (&s->common_iomem, &pxa2xx_pcmcia_common_ops, s, +"pcmcia_common" ,0x04000000 ); +memory_region_add_subregion (get_system_memory (), base |0x0c000000 , + &s->common_iomem);if (base ==0x30000000 ) s->slot.slot_string ="PXA PC Card Socket 1" ;
Signature · 1 line
1.7.4.1
PATCH 3/10 pxa2xx_pcmcia.c: convert attribute memory space to memory API
In reply to Benoît Canet--- hw/pxa2xx_pcmcia.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-)
hw/pxa2xx_pcmcia.c +14 -17
@@ -12,10 +12,12 @@#include "pxa.h" #include "exec-memory.h" +struct PXA2xxPCMCIAState {PCMCIASocket slot;PCMCIACardState *card;MemoryRegion common_iomem; +MemoryRegion attr_iomem;qemu_irq irq;qemu_irq cd_irq;
@@ -43,8 +45,8 @@ static void pxa2xx_pcmcia_common_write(void *opaque, target_phys_addr_t offset, } } -static uint32_t pxa2xx_pcmcia_attr_read (void *opaque, -target_phys_addr_t offset) +static uint64_t pxa2xx_pcmcia_attr_read (void *opaque, +target_phys_addr_t offset,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -55,8 +57,8 @@ static uint32_t pxa2xx_pcmcia_attr_read(void *opaque,return 0 ; } -static void pxa2xx_pcmcia_attr_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_pcmcia_attr_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -93,16 +95,10 @@ static const MemoryRegionOps pxa2xx_pcmcia_common_ops = { .endianness = DEVICE_NATIVE_ENDIAN }; -static CPUReadMemoryFunc *const pxa2xx_pcmcia_attr_readfn[] = { - pxa2xx_pcmcia_attr_read, - pxa2xx_pcmcia_attr_read, - pxa2xx_pcmcia_attr_read, -}; - -static CPUWriteMemoryFunc *const pxa2xx_pcmcia_attr_writefn[] = { - pxa2xx_pcmcia_attr_write, - pxa2xx_pcmcia_attr_write, - pxa2xx_pcmcia_attr_write, +static const MemoryRegionOps pxa2xx_pcmcia_attr_ops = { + .read = pxa2xx_pcmcia_attr_read, + .write = pxa2xx_pcmcia_attr_write, + .endianness =DEVICE_NATIVE_ENDIAN };static CPUReadMemoryFunc *const pxa2xx_pcmcia_io_readfn[] = {
@@ -142,9 +138,10 @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)/* Then next 64 MB is reserved */ /* Socket Attribute Memory Space */ - iomemtype =cpu_register_io_memory (pxa2xx_pcmcia_attr_readfn, - pxa2xx_pcmcia_attr_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base |0x08000000 ,0x04000000 , iomemtype); +memory_region_init_io (&s->attr_iomem, &pxa2xx_pcmcia_attr_ops, s, +"pcmcia_attribute" ,0x04000000 ); +memory_region_add_subregion (get_system_memory (), base |0x08000000 , + &s->attr_iomem);/* Socket Common Memory Space */ memory_region_init_io(&s->common_iomem, &pxa2xx_pcmcia_common_ops, s,
Signature · 1 line
1.7.4.1
PATCH 4/10 pxa2xx_pcmcia.c: convert io memory space to memory API
In reply to Benoît Canet--- hw/pxa2xx_pcmcia.c | 31 +++++++++++++------------------ 1 files changed, 13 insertions(+), 18 deletions(-)
hw/pxa2xx_pcmcia.c +13 -18
@@ -18,6 +18,7 @@ struct PXA2xxPCMCIAState {PCMCIACardState *card;MemoryRegion common_iomem;MemoryRegion attr_iomem; +MemoryRegion iomem;qemu_irq irq;qemu_irq cd_irq;
@@ -67,8 +68,8 @@ static void pxa2xx_pcmcia_attr_write(void *opaque, target_phys_addr_t offset, } } -static uint32_t pxa2xx_pcmcia_io_read (void *opaque, -target_phys_addr_t offset) +static uint64_t pxa2xx_pcmcia_io_read (void *opaque, +target_phys_addr_t offset,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -79,8 +80,8 @@ static uint32_t pxa2xx_pcmcia_io_read(void *opaque,return 0 ; } -static void pxa2xx_pcmcia_io_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_pcmcia_io_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
@@ -101,16 +102,10 @@ static const MemoryRegionOps pxa2xx_pcmcia_attr_ops = { .endianness = DEVICE_NATIVE_ENDIAN }; -static CPUReadMemoryFunc *const pxa2xx_pcmcia_io_readfn[] = { - pxa2xx_pcmcia_io_read, - pxa2xx_pcmcia_io_read, - pxa2xx_pcmcia_io_read, -}; - -static CPUWriteMemoryFunc *const pxa2xx_pcmcia_io_writefn[] = { - pxa2xx_pcmcia_io_write, - pxa2xx_pcmcia_io_write, - pxa2xx_pcmcia_io_write, +static const MemoryRegionOps pxa2xx_pcmcia_io_ops = { + .read = pxa2xx_pcmcia_io_read, + .write = pxa2xx_pcmcia_io_write, + .endianness =DEVICE_NATIVE_ENDIAN };static void pxa2xx_pcmcia_set_irq (void *opaque,int line,int level)
@@ -124,16 +119,16 @@ static void pxa2xx_pcmcia_set_irq(void *opaque, int line, int level)PXA2xxPCMCIAState *pxa2xx_pcmcia_init (target_phys_addr_t base) { -int iomemtype;PXA2xxPCMCIAState *s; s = (PXA2xxPCMCIAState *)g_malloc0 (sizeof (PXA2xxPCMCIAState));/* Socket I/O Memory Space */ - iomemtype =cpu_register_io_memory (pxa2xx_pcmcia_io_readfn, - pxa2xx_pcmcia_io_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base |0x00000000 ,0x04000000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_pcmcia_io_ops, s, +"pcmcia_io" ,0x04000000 ); +memory_region_add_subregion (get_system_memory (), base |0x00000000 , + &s->iomem);/* Then next 64 MB is reserved */
Signature · 1 line
1.7.4.1
PATCH 5/10 pxa2xx_pcmcia.c: merge calls to get_system_memory()
In reply to Benoît Canet--- hw/pxa2xx_pcmcia.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/pxa2xx_pcmcia.c +4 -3
@@ -120,6 +120,7 @@ static void pxa2xx_pcmcia_set_irq(void *opaque, int line, int level)PXA2xxPCMCIAState *pxa2xx_pcmcia_init (target_phys_addr_t base) {PXA2xxPCMCIAState *s; +MemoryRegion *system_memory =get_system_memory (); s = (PXA2xxPCMCIAState *)g_malloc0 (sizeof (PXA2xxPCMCIAState));
@@ -127,7 +128,7 @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)/* Socket I/O Memory Space */ memory_region_init_io (&s->iomem, &pxa2xx_pcmcia_io_ops, s,"pcmcia_io" ,0x04000000 ); -memory_region_add_subregion (get_system_memory (), base |0x00000000 , +memory_region_add_subregion (system_memory, base |0x00000000 , &s->iomem);/* Then next 64 MB is reserved */
@@ -135,13 +136,13 @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(target_phys_addr_t base)/* Socket Attribute Memory Space */ memory_region_init_io (&s->attr_iomem, &pxa2xx_pcmcia_attr_ops, s,"pcmcia_attribute" ,0x04000000 ); -memory_region_add_subregion (get_system_memory (), base |0x08000000 , +memory_region_add_subregion (system_memory, base |0x08000000 , &s->attr_iomem);/* Socket Common Memory Space */ memory_region_init_io (&s->common_iomem, &pxa2xx_pcmcia_common_ops, s,"pcmcia_common" ,0x04000000 ); -memory_region_add_subregion (get_system_memory (), base |0x0c000000 , +memory_region_add_subregion (system_memory, base |0x0c000000 , &s->common_iomem);if (base ==0x30000000 )
Signature · 1 line
1.7.4.1
PATCH 7/10 pxa2xx_timer: convert to memory API
In reply to Benoît Canet--- hw/pxa2xx_timer.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-)
hw/pxa2xx_timer.c +12 -16
@@ -12,6 +12,7 @@#include "sysemu.h" #include "pxa.h" #include "sysbus.h" +#include "exec-memory.h" #define OSMR0 0x00#define OSMR1 0x04
@@ -81,6 +82,7 @@ typedef struct {struct PXA2xxTimerInfo {SysBusDevice busdev; +MemoryRegion iomem;uint32_t flags;int32_t clock;
@@ -148,7 +150,8 @@ static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n)qemu_mod_timer (s->tm4[n].tm.qtimer, new_qemu); } -static uint32_t pxa2xx_timer_read (void *opaque,target_phys_addr_t offset) +static uint64_t pxa2xx_timer_read (void *opaque,target_phys_addr_t offset, +unsigned size) {PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;int tm =0 ;
@@ -226,7 +229,7 @@ static uint32_t pxa2xx_timer_read(void *opaque, target_phys_addr_t offset) }static void pxa2xx_timer_write (void *opaque,target_phys_addr_t offset, -uint32_t value) +uint64_t value,unsigned size) {int i, tm =0 ;PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque;
@@ -325,16 +328,10 @@ static void pxa2xx_timer_write(void *opaque, target_phys_addr_t offset, } } -static CPUReadMemoryFunc *const pxa2xx_timer_readfn[] = { - pxa2xx_timer_read, - pxa2xx_timer_read, - pxa2xx_timer_read, -}; - -static CPUWriteMemoryFunc *const pxa2xx_timer_writefn[] = { - pxa2xx_timer_write, - pxa2xx_timer_write, - pxa2xx_timer_write, +static const MemoryRegionOps pxa2xx_timer_ops = { + .read = pxa2xx_timer_read, + .write = pxa2xx_timer_write, + .endianness =DEVICE_NATIVE_ENDIAN , };static void pxa2xx_timer_tick (void *opaque)
@@ -387,7 +384,6 @@ static int pxa25x_timer_post_load(void *opaque, int version_id)static int pxa2xx_timer_init (SysBusDevice *dev) {int i; -int iomemtype;PXA2xxTimerInfo *s; s =FROM_SYSBUS (PXA2xxTimerInfo, dev);
@@ -419,9 +415,9 @@ static int pxa2xx_timer_init(SysBusDevice *dev) } } - iomemtype =cpu_register_io_memory (pxa2xx_timer_readfn, - pxa2xx_timer_writefn, s,DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (dev,0x00001000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_timer_ops, s, +"timer" ,0x00001000 ); +sysbus_init_mmio_region (dev, &s->iomem);return 0 ; }
Signature · 1 line
1.7.4.1
PATCH 6/10 pxa2xx_keypad: convert to memory API
In reply to Benoît Canet--- hw/pxa2xx_keypad.c | 30 +++++++++++++----------------- 1 files changed, 13 insertions(+), 17 deletions(-)
hw/pxa2xx_keypad.c +13 -17
@@ -11,6 +11,7 @@#include "hw.h" #include "pxa.h" #include "console.h" +#include "exec-memory.h" /* * Keypad
@@ -80,6 +81,7 @@#define PXAKBD_MAXCOL 8struct PXA2xxKeyPadState { +MemoryRegion iomem;qemu_irq irq;struct keymap *map;int pressed_cnt;
@@ -174,7 +176,8 @@ out:return ; } -static uint32_t pxa2xx_keypad_read (void *opaque,target_phys_addr_t offset) +static uint64_t pxa2xx_keypad_read (void *opaque,target_phys_addr_t offset, +unsigned size) {PXA2xxKeyPadState *s = (PXA2xxKeyPadState *) opaque;uint32_t tmp;
@@ -235,8 +238,8 @@ static uint32_t pxa2xx_keypad_read(void *opaque, target_phys_addr_t offset)return 0 ; } -static void pxa2xx_keypad_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_keypad_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxKeyPadState *s = (PXA2xxKeyPadState *) opaque;
@@ -277,16 +280,10 @@ static void pxa2xx_keypad_write(void *opaque, } } -static CPUReadMemoryFunc *const pxa2xx_keypad_readfn[] = { - pxa2xx_keypad_read, - pxa2xx_keypad_read, - pxa2xx_keypad_read -}; - -static CPUWriteMemoryFunc *const pxa2xx_keypad_writefn[] = { - pxa2xx_keypad_write, - pxa2xx_keypad_write, - pxa2xx_keypad_write +static const MemoryRegionOps pxa2xx_keypad_ops = { + .read = pxa2xx_keypad_read, + .write = pxa2xx_keypad_write, + .endianness =DEVICE_NATIVE_ENDIAN , };static const VMStateDescription vmstate_pxa2xx_keypad = {
@@ -309,15 +306,14 @@ static const VMStateDescription vmstate_pxa2xx_keypad = {PXA2xxKeyPadState *pxa27x_keypad_init (target_phys_addr_t base,qemu_irq irq) { -int iomemtype;PXA2xxKeyPadState *s; s = (PXA2xxKeyPadState *)g_malloc0 (sizeof (PXA2xxKeyPadState)); s->irq = irq; - iomemtype =cpu_register_io_memory (pxa2xx_keypad_readfn, - pxa2xx_keypad_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base,0x00100000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_keypad_ops, s, +"keypad" ,0x00100000 ); +memory_region_add_subregion (get_system_memory (), base, &s->iomem);vmstate_register (NULL ,0 , &vmstate_pxa2xx_keypad, s);
Signature · 1 line
1.7.4.1
PATCH 8/10 pxa2xx_pic: convert to memory API
In reply to Benoît CanetThe ARM documentation say transfers between the cpu and the coprocessor are 32 bits wide.
Use 4 as size for coprocessor read and writes.
--- hw/pxa2xx_pic.c | 31 +++++++++++++------------------ 1 files changed, 13 insertions(+), 18 deletions(-)
hw/pxa2xx_pic.c +13 -18
@@ -33,6 +33,7 @@ typedef struct { SysBusDevice busdev; + MemoryRegion iomem; CPUState *cpu_env; uint32_t int_enabled[2]; uint32_t int_pending[2];
@@ -115,7 +116,8 @@ static inline uint32_t pxa2xx_pic_highest(PXA2xxPICState *s) {return ichp; } -static uint32_t pxa2xx_pic_mem_read (void *opaque,target_phys_addr_t offset) +static uint64_t pxa2xx_pic_mem_read (void *opaque,target_phys_addr_t offset, +unsigned size) {PXA2xxPICState *s = (PXA2xxPICState *) opaque;
@@ -155,7 +157,7 @@ static uint32_t pxa2xx_pic_mem_read(void *opaque, target_phys_addr_t offset) }static void pxa2xx_pic_mem_write (void *opaque,target_phys_addr_t offset, -uint32_t value) +uint64_t value,unsigned size) {PXA2xxPICState *s = (PXA2xxPICState *) opaque;
@@ -214,7 +216,7 @@ static uint32_t pxa2xx_pic_cp_read(void *opaque, int op2, int reg, int crm) } offset = pxa2xx_cp_reg_map[reg]; -return pxa2xx_pic_mem_read (opaque, offset); +return pxa2xx_pic_mem_read (opaque, offset,4 ); } static void pxa2xx_pic_cp_write(void *opaque, int op2, int reg, int crm,
@@ -228,19 +230,13 @@ static void pxa2xx_pic_cp_write(void *opaque, int op2, int reg, int crm, } offset = pxa2xx_cp_reg_map[reg]; -pxa2xx_pic_mem_write (opaque, offset, value); +pxa2xx_pic_mem_write (opaque, offset, value,4 ); } -static CPUReadMemoryFunc *const pxa2xx_pic_readfn[] = { - pxa2xx_pic_mem_read, - pxa2xx_pic_mem_read, - pxa2xx_pic_mem_read, -}; - -static CPUWriteMemoryFunc *const pxa2xx_pic_writefn[] = { - pxa2xx_pic_mem_write, - pxa2xx_pic_mem_write, - pxa2xx_pic_mem_write, +static const MemoryRegionOps pxa2xx_pic_ops = { + .read = pxa2xx_pic_mem_read, + .write = pxa2xx_pic_mem_write, + .endianness =DEVICE_NATIVE_ENDIAN , };static int pxa2xx_pic_post_load (void *opaque,int version_id)
@@ -252,7 +248,6 @@ static int pxa2xx_pic_post_load(void *opaque, int version_id)DeviceState *pxa2xx_pic_init (target_phys_addr_t base,CPUState *env) {DeviceState *dev =qdev_create (NULL ,"pxa2xx_pic" ); -int iomemtype;PXA2xxPICState *s =FROM_SYSBUS (PXA2xxPICState,sysbus_from_qdev (dev)); s->cpu_env = env;
@@ -269,9 +264,9 @@ DeviceState *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)qdev_init_gpio_in (dev, pxa2xx_pic_set_irq,PXA2XX_PIC_SRCS );/* Enable IC memory-mapped registers access. */ - iomemtype =cpu_register_io_memory (pxa2xx_pic_readfn, - pxa2xx_pic_writefn, s,DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (sysbus_from_qdev (dev),0x00100000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_pic_ops, s, +"pic" ,0x00100000 ); +sysbus_init_mmio_region (sysbus_from_qdev (dev), &s->iomem);sysbus_mmio_map (sysbus_from_qdev (dev),0 , base);/* Enable IC coprocessor access. */
Signature · 1 line
1.7.4.1
PATCH 9/10 pxa2xx_mmci: convert to memory API.
In reply to Benoît CanetConvert mechanicaly; the access size of the old_mmio fields seems odd.
--- hw/pxa2xx_mmci.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
hw/pxa2xx_mmci.c +14 -14
@@ -11,8 +11,10 @@#include "pxa.h" #include "sd.h" #include "qdev.h" +#include "exec-memory.h" struct PXA2xxMMCIState { +MemoryRegion iomem;qemu_irq irq;qemu_irq rx_dma;qemu_irq tx_dma;
@@ -403,12 +405,6 @@ static uint32_t pxa2xx_mmci_readw(void *opaque, target_phys_addr_t offset)return pxa2xx_mmci_read (opaque, offset); } -static CPUReadMemoryFunc *const pxa2xx_mmci_readfn[] = { - pxa2xx_mmci_readb, - pxa2xx_mmci_readh, - pxa2xx_mmci_readw -}; -static void pxa2xx_mmci_writeb (void *opaque,target_phys_addr_t offset,uint32_t value) {
@@ -433,10 +429,16 @@ static void pxa2xx_mmci_writew(void *opaque,pxa2xx_mmci_write (opaque, offset, value); } -static CPUWriteMemoryFunc *const pxa2xx_mmci_writefn[] = { - pxa2xx_mmci_writeb, - pxa2xx_mmci_writeh, - pxa2xx_mmci_writew +static const MemoryRegionOps pxa2xx_mmci_ops = { + .old_mmio = { + .read = { pxa2xx_mmci_readb, + pxa2xx_mmci_readh, + pxa2xx_mmci_readw, }, + .write = { pxa2xx_mmci_writeb, + pxa2xx_mmci_writeh, + pxa2xx_mmci_writew, }, + }, + .endianness =DEVICE_NATIVE_ENDIAN , };static void pxa2xx_mmci_save (QEMUFile *f,void *opaque)
@@ -521,7 +523,6 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base, BlockDriverState *bd, qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) { - int iomemtype; PXA2xxMMCIState *s; s = (PXA2xxMMCIState *)g_malloc0 (sizeof (PXA2xxMMCIState));
@@ -529,9 +530,8 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base, s->rx_dma = rx_dma; s->tx_dma = tx_dma; - iomemtype =cpu_register_io_memory (pxa2xx_mmci_readfn, - pxa2xx_mmci_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base,0x00100000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_mmci_ops, s,"mmc" ,0x00100000 ); +memory_region_add_subregion (get_system_memory (), base, &s->iomem);/* Instantiate the actual storage */ s->card =sd_init (bd,0 );
Signature · 1 line
1.7.4.1
PATCH 10/10 pxa2xx_lcd: convert to memory API
In reply to Benoît Canet--- hw/pxa2xx_lcd.c | 30 +++++++++++++----------------- 1 files changed, 13 insertions(+), 17 deletions(-)
hw/pxa2xx_lcd.c +13 -17
@@ -14,6 +14,7 @@/* FIXME: For graphic_rotate. Should probably be done in common code. */ #include "sysemu.h" #include "framebuffer.h" +#include "exec-memory.h" struct DMAChannel {target_phys_addr_t branch;
@@ -30,6 +31,7 @@ struct DMAChannel { };struct PXA2xxLCDState { +MemoryRegion iomem;qemu_irq irq;int irqlevel;
@@ -315,7 +317,8 @@ static void pxa2xx_descriptor_load(PXA2xxLCDState *s) } } -static uint32_t pxa2xx_lcdc_read (void *opaque,target_phys_addr_t offset) +static uint64_t pxa2xx_lcdc_read (void *opaque,target_phys_addr_t offset, +unsigned size) {PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;int ch;
@@ -408,8 +411,8 @@ static uint32_t pxa2xx_lcdc_read(void *opaque, target_phys_addr_t offset)return 0 ; } -static void pxa2xx_lcdc_write (void *opaque, -target_phys_addr_t offset,uint32_t value) +static void pxa2xx_lcdc_write (void *opaque,target_phys_addr_t offset, +uint64_t value,unsigned size) {PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;int ch;
@@ -561,16 +564,10 @@ static void pxa2xx_lcdc_write(void *opaque, } } -static CPUReadMemoryFunc *const pxa2xx_lcdc_readfn[] = { - pxa2xx_lcdc_read, - pxa2xx_lcdc_read, - pxa2xx_lcdc_read -}; - -static CPUWriteMemoryFunc *const pxa2xx_lcdc_writefn[] = { - pxa2xx_lcdc_write, - pxa2xx_lcdc_write, - pxa2xx_lcdc_write +static const MemoryRegionOps pxa2xx_lcdc_ops = { + .read = pxa2xx_lcdc_read, + .write = pxa2xx_lcdc_write, + .endianness =DEVICE_NATIVE_ENDIAN , };/* Load new palette for a given DMA channel, convert to internal format */
@@ -983,7 +980,6 @@ static const VMStateDescription vmstate_pxa2xx_lcdc = {PXA2xxLCDState *pxa2xx_lcdc_init (target_phys_addr_t base,qemu_irq irq) { -int iomemtype;PXA2xxLCDState *s; s = (PXA2xxLCDState *)g_malloc0 (sizeof (PXA2xxLCDState));
@@ -992,9 +988,9 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)pxa2xx_lcdc_orientation (s, graphic_rotate); - iomemtype =cpu_register_io_memory (pxa2xx_lcdc_readfn, - pxa2xx_lcdc_writefn, s,DEVICE_NATIVE_ENDIAN ); -cpu_register_physical_memory (base,0x00100000 , iomemtype); +memory_region_init_io (&s->iomem, &pxa2xx_lcdc_ops, s, +"lcd-controller" ,0x00100000 ); +memory_region_add_subregion (get_system_memory (), base, &s->iomem); s->ds = graphic_console_init(pxa2xx_update_display, pxa2xx_invalidate_display,
Signature · 1 line
1.7.4.1
Quoted 5 lines · Benoît Canet
Convert most of pxa2xx periferal to memory API.
pxa2xx_dmai.cwas intact appart because it use cpu_physical_memory_read/write internal and seems special.
This patchset adds a lot of calls to get_system_memory(), which undermines one of the purposes of the memory API - to avoid global knowledge. Please make the various initialization functions accept a MemoryRegion parameter, and use get_system_memory() in just one place (the best place is the machine init callback).
Signature · 1 line
error compiling committee.c: too many arguments to function