Skip to contentSkip to conversation

ioport conversions to memory API

PATCH In review Benoît Canet 2 participants 6 messages Dec 1, 2011 – Dec 5, 2011

lore
Share & tools
lore
#0 lore raw

cover ioport conversions to memory API

These patches convert two files ioports to memory API.

Benoît Canet (2):
applesmc: convert portio to memory API
ppc_prep: convert ioport to memory API

 hw/applesmc.c |   20 ++++++++-----
 hw/ppc_prep.c |   80 ++++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 74 insertions(+), 26 deletions(-)
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 1/2 applesmc: convert portio to memory API

---
 hw/applesmc.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
hw/applesmc.c +12 -8
index c47b592..fb11bdf 100644
@@ -165,6 +165,16 @@ static uint32_t applesmc_io_cmd_readb(void *opaque, uint32_t addr1)
     return s->status;
 }
 
+static const MemoryRegionPortio applesmc_portio_list[] = {
+    { APPLESMC_DATA_PORT, 4, 1,
+      .read = applesmc_io_data_readb,
+      .write = applesmc_io_data_writeb },
+    { APPLESMC_CMD_PORT, 4, 1,
+      .read = applesmc_io_cmd_readb,
+      .write = applesmc_io_cmd_writeb },
+    PORTIO_END_OF_LIST(),
+};
+
 static void applesmc_add_key(struct AppleSMCStatus *s, const char *key,
                              int len, const char *data)
 {
@@ -200,14 +210,8 @@ static int applesmc_isa_init(ISADevice *dev)
 {
     struct AppleSMCStatus *s = DO_UPCAST(struct AppleSMCStatus, dev, dev);
 
-    register_ioport_read(s->iobase + APPLESMC_DATA_PORT, 4, 1,
-                         applesmc_io_data_readb, s);
-    register_ioport_read(s->iobase + APPLESMC_CMD_PORT, 4, 1,
-                         applesmc_io_cmd_readb, s);
-    register_ioport_write(s->iobase + APPLESMC_DATA_PORT, 4, 1,
-                          applesmc_io_data_writeb, s);
-    register_ioport_write(s->iobase + APPLESMC_CMD_PORT, 4, 1,
-                          applesmc_io_cmd_writeb, s);
+    isa_register_portio_list(dev, s->iobase, applesmc_portio_list, s,
+                             "applesmc");
 
     if (!s->osk || (strlen(s->osk) != 64)) {
         fprintf(stderr, "WARNING: Using AppleSMC with invalid key\n");
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 2/2 ppc_prep: convert ioport to memory API

In reply to Benoît Canet
---
 hw/ppc_prep.c |   80 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 18 deletions(-)
hw/ppc_prep.c +62 -18
index f22d5b9..299305b 100644
@@ -94,7 +94,8 @@ static int speaker_data_on;
 static int dummy_refresh_clock;
 #endif
 
-static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)
+static void speaker_ioport_write(void *opaque, target_phys_addr_t addr,
+                                 uint64_t val, unsigned size)
 {
 #if 0
     speaker_data_on = (val >> 1) & 1;
@@ -102,7 +103,8 @@ static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)
 #endif
 }
 
-static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
+static uint64_t speaker_ioport_read(void *opaque, target_phys_addr_t addr,
+                                    unsigned size)
 {
 #if 0
     int out;
@@ -114,6 +116,16 @@ static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
     return 0;
 }
 
+static const MemoryRegionOps speaker_ioport_ops = {
+    .read = speaker_ioport_read,
+    .write = speaker_ioport_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 /* PCI intack register */
 /* Read-only register (?) */
 static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -251,7 +263,8 @@ enum {
 
 static sysctrl_t *sysctrl;
 
-static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
+static void PREP_io_write(void *opaque, target_phys_addr_t addr,
+                          uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -260,7 +273,8 @@ static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
     sysctrl->fake_io[addr - 0x0398] = val;
 }
 
-static uint32_t PREP_io_read (void *opaque, uint32_t addr)
+static uint64_t PREP_io_read(void *opaque, target_phys_addr_t addr,
+                             unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -269,7 +283,18 @@ static uint32_t PREP_io_read (void *opaque, uint32_t addr)
     return sysctrl->fake_io[addr - 0x0398];
 }
 
-static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
+static const MemoryRegionOps PREP_io_ops = {
+    .read = PREP_io_read,
+    .write = PREP_io_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
+static void PREP_io_800_writeb(void *opaque, target_phys_addr_t addr,
+                               uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -330,13 +355,14 @@ static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
         sysctrl->contiguous_map = val & 0x01;
         break;
     default:
-        printf("ERROR: unaffected IO port write: %04" PRIx32
-               " => %02" PRIx32"\n", addr, val);
+        printf("ERROR: unaffected IO port write: %04" PRIx64
+               " => %02" PRIx64 "\n", addr, val);
         break;
     }
 }
 
-static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
+static uint64_t PREP_io_800_readb(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
     uint32_t retval = 0xFF;
@@ -393,15 +419,25 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
         retval = sysctrl->contiguous_map;
         break;
     default:
-        printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr);
+        printf("ERROR: unaffected IO port: %04" PRIx64 " read\n", addr);
         break;
     }
-    PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n",
+    PPC_IO_DPRINTF("0x%08" PRIx64 " <= 0x%02" PRIx64 "\n",
                    addr - PPC_IO_BASE, retval);
 
     return retval;
 }
 
+static const MemoryRegionOps PREP_io_800_ops = {
+    .read = PREP_io_800_readb,
+    .write = PREP_io_800_writeb,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl,
                                                  target_phys_addr_t addr)
 {
@@ -514,6 +550,10 @@ static void ppc_prep_init (ram_addr_t ram_size,
     M48t59State *m48t59;
     MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
     MemoryRegion *intack = g_new(MemoryRegion, 1);
+    MemoryRegion *io_speaker = g_new(MemoryRegion, 1);
+    MemoryRegion *io_fake = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_092 = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_800 = g_new(MemoryRegion, 1);
 #if 0
     MemoryRegion *xcsr = g_new(MemoryRegion, 1);
 #endif
@@ -679,17 +719,21 @@ static void ppc_prep_init (ram_addr_t ram_size,
     fdctrl_init_isa(fd);
 
     /* Register speaker port */
-    register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
-    register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
+    memory_region_init_io(io_speaker, &speaker_ioport_ops, NULL,
+                          "speaker", 1);
+    memory_region_add_subregion(sysmem, 0x61, io_speaker);
     /* Register fake IO ports for PREP */
     sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
-    register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
-    register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
+    memory_region_init_io(io_fake, &PREP_io_ops, sysctrl, "prep-fake", 2);
+    memory_region_add_subregion(sysmem, 0x398, io_fake);
     /* System control ports */
-    register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
-    register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
+    memory_region_init_io(io_control_092, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x92", 1);
+    memory_region_add_subregion(sysmem, 0x0092, io_control_092);
+
+    memory_region_init_io(io_control_800, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x800", 52);
+    memory_region_add_subregion(sysmem, 0x0800, io_control_800);
     /* PCI intack location */
     memory_region_init_io(intack, &PPC_intack_ops, NULL, "ppc-intack", 4);
     memory_region_add_subregion(sysmem, 0xBFFFFFF0, intack);
Signature · 1 line
1.7.7.3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] ppc_prep: convert ioport to memory API

Benoît,

Just spotted this.

Am 01.12.2011 17:57, schrieb Benoît Canet:

Quoted 1 line

You should've cc'ed me here as maintainer. As indicated to you, I have pending patches for PReP (e.g., moving io800 and dropping speaker in favor of qdev), which this conflicts with once again. I'm in favor of merging your conversions as a short-term solution though, so that it can go through Avi's tree.

The patch itself looks okay on brief look, except that io_fake and prep-fake should better be io_fakeio and prep-fakeio respectively (still ugly as hell, but the real Super I/O we prepared for 40P turned out incompatible somehow).

I'll test later. Did you in some way?

Regards,
Andreas

Quoted 172 lines
---
 hw/ppc_prep.c |   80 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 18 deletions(-)
hw/ppc_prep.c +62 -18
index f22d5b9..299305b 100644
@@ -94,7 +94,8 @@ static int speaker_data_on;
 static int dummy_refresh_clock;
 #endif
 
-static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)
+static void speaker_ioport_write(void *opaque, target_phys_addr_t addr,
+                                 uint64_t val, unsigned size)
 {
 #if 0
     speaker_data_on = (val >> 1) & 1;
@@ -102,7 +103,8 @@ static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)
 #endif
 }
 
-static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
+static uint64_t speaker_ioport_read(void *opaque, target_phys_addr_t addr,
+                                    unsigned size)
 {
 #if 0
     int out;
@@ -114,6 +116,16 @@ static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
     return 0;
 }
 
+static const MemoryRegionOps speaker_ioport_ops = {
+    .read = speaker_ioport_read,
+    .write = speaker_ioport_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 /* PCI intack register */
 /* Read-only register (?) */
 static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -251,7 +263,8 @@ enum {
 
 static sysctrl_t *sysctrl;
 
-static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
+static void PREP_io_write(void *opaque, target_phys_addr_t addr,
+                          uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -260,7 +273,8 @@ static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
     sysctrl->fake_io[addr - 0x0398] = val;
 }
 
-static uint32_t PREP_io_read (void *opaque, uint32_t addr)
+static uint64_t PREP_io_read(void *opaque, target_phys_addr_t addr,
+                             unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -269,7 +283,18 @@ static uint32_t PREP_io_read (void *opaque, uint32_t addr)
     return sysctrl->fake_io[addr - 0x0398];
 }
 
-static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
+static const MemoryRegionOps PREP_io_ops = {
+    .read = PREP_io_read,
+    .write = PREP_io_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
+static void PREP_io_800_writeb(void *opaque, target_phys_addr_t addr,
+                               uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -330,13 +355,14 @@ static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
         sysctrl->contiguous_map = val & 0x01;
         break;
     default:
-        printf("ERROR: unaffected IO port write: %04" PRIx32
-               " => %02" PRIx32"\n", addr, val);
+        printf("ERROR: unaffected IO port write: %04" PRIx64
+               " => %02" PRIx64 "\n", addr, val);
         break;
     }
 }
 
-static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
+static uint64_t PREP_io_800_readb(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
     uint32_t retval = 0xFF;
@@ -393,15 +419,25 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
         retval = sysctrl->contiguous_map;
         break;
     default:
-        printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr);
+        printf("ERROR: unaffected IO port: %04" PRIx64 " read\n", addr);
         break;
     }
-    PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n",
+    PPC_IO_DPRINTF("0x%08" PRIx64 " <= 0x%02" PRIx64 "\n",
                    addr - PPC_IO_BASE, retval);
 
     return retval;
 }
 
+static const MemoryRegionOps PREP_io_800_ops = {
+    .read = PREP_io_800_readb,
+    .write = PREP_io_800_writeb,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl,
                                                  target_phys_addr_t addr)
 {
@@ -514,6 +550,10 @@ static void ppc_prep_init (ram_addr_t ram_size,
     M48t59State *m48t59;
     MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
     MemoryRegion *intack = g_new(MemoryRegion, 1);
+    MemoryRegion *io_speaker = g_new(MemoryRegion, 1);
+    MemoryRegion *io_fake = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_092 = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_800 = g_new(MemoryRegion, 1);
 #if 0
     MemoryRegion *xcsr = g_new(MemoryRegion, 1);
 #endif
@@ -679,17 +719,21 @@ static void ppc_prep_init (ram_addr_t ram_size,
     fdctrl_init_isa(fd);
 
     /* Register speaker port */
-    register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
-    register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
+    memory_region_init_io(io_speaker, &speaker_ioport_ops, NULL,
+                          "speaker", 1);
+    memory_region_add_subregion(sysmem, 0x61, io_speaker);
     /* Register fake IO ports for PREP */
     sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
-    register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
-    register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
+    memory_region_init_io(io_fake, &PREP_io_ops, sysctrl, "prep-fake", 2);
+    memory_region_add_subregion(sysmem, 0x398, io_fake);
     /* System control ports */
-    register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
-    register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
+    memory_region_init_io(io_control_092, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x92", 1);
+    memory_region_add_subregion(sysmem, 0x0092, io_control_092);
+
+    memory_region_init_io(io_control_800, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x800", 52);
+    memory_region_add_subregion(sysmem, 0x0800, io_control_800);
     /* PCI intack location */
     memory_region_init_io(intack, &PPC_intack_ops, NULL, "ppc-intack", 4);
     memory_region_add_subregion(sysmem, 0xBFFFFFF0, intack);
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] ppc_prep: convert ioport to memory API

Quoted 6 lines

The patch itself looks okay on brief look, except that io_fake and prep-fake should better be io_fakeio and prep-fakeio respectively (still ugly as hell, but the real Super I/O we prepared for 40P turned out incompatible somehow).

I'll make the required changes and test them with buildroot (just a few compilation time).

Regards

Benoît

Quoted 189 lines
Quoted 2 lines
---
 hw/ppc_prep.c |   80

++++++++++++++++++++++++++++++++++++++++++++-------------

hw/ppc_prep.c static int speaker_data_on; · line 97

Quoted 11 lines
 1 files changed, 62 insertions(+), 18 deletions(-)
hw/ppc_prep.c +0 -1
index f22d5b9..299305b 100644
@@ -94,7 +94,8 @@ static int speaker_data_on;
 static int dummy_refresh_clock;
 #endif
 
-static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t

val)

hw/ppc_prep.c static void speaker_ioport_write (void *opaque,

Quoted 6 lines
hw/ppc_prep.c +2 -0
+static void speaker_ioport_write(void *opaque, target_phys_addr_t addr,
+                                 uint64_t val, unsigned size)
 {
 #if 0
     speaker_data_on = (val >> 1) & 1;
@@ -102,7 +103,8 @@ static void speaker_ioport_write (void *opaque,

uint32_t addr, uint32_t val)

hw/ppc_prep.c static void speaker_ioport_write (void *opaque, uint32_t addr, uint32_t val)

Quoted 5 lines
hw/ppc_prep.c +1 -1
 #endif
 }
 
-static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
+static uint64_t speaker_ioport_read(void *opaque, target_phys_addr_t

addr,

hw/ppc_prep.c static uint32_t speaker_ioport_read (void *opaque,

Quoted 5 lines
hw/ppc_prep.c +1 -0
+                                    unsigned size)
 {
 #if 0
     int out;
@@ -114,6 +116,16 @@ static uint32_t speaker_ioport_read (void *opaque,

uint32_t addr)

hw/ppc_prep.c static void PREP_io_write (void *opaque, uint32_t

Quoted 27 lines
hw/ppc_prep.c +12 -1
     return 0;
 }
 
+static const MemoryRegionOps speaker_ioport_ops = {
+    .read = speaker_ioport_read,
+    .write = speaker_ioport_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 /* PCI intack register */
 /* Read-only register (?) */
 static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -251,7 +263,8 @@ enum {
 
 static sysctrl_t *sysctrl;
 
-static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
+static void PREP_io_write(void *opaque, target_phys_addr_t addr,
+                          uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -260,7 +273,8 @@ static void PREP_io_write (void *opaque, uint32_t

addr, uint32_t val)

hw/ppc_prep.c static uint32_t PREP_io_read (void *opaque,

Quoted 10 lines
hw/ppc_prep.c +2 -1
     sysctrl->fake_io[addr - 0x0398] = val;
 }
 
-static uint32_t PREP_io_read (void *opaque, uint32_t addr)
+static uint64_t PREP_io_read(void *opaque, target_phys_addr_t addr,
+                             unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -269,7 +283,18 @@ static uint32_t PREP_io_read (void *opaque,

uint32_t addr)

hw/ppc_prep.c static uint32_t PREP_io_read (void *opaque, uint32_t addr)

Quoted 4 lines
hw/ppc_prep.c +0 -1
     return sysctrl->fake_io[addr - 0x0398];
 }
 
-static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t

val)

hw/ppc_prep.c static void PREP_io_800_writeb (void *opaque,

Quoted 16 lines
hw/ppc_prep.c +12 -0
+static const MemoryRegionOps PREP_io_ops = {
+    .read = PREP_io_read,
+    .write = PREP_io_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
+static void PREP_io_800_writeb(void *opaque, target_phys_addr_t addr,
+                               uint64_t val, unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
 
@@ -330,13 +355,14 @@ static void PREP_io_800_writeb (void *opaque,

uint32_t addr, uint32_t val)

hw/ppc_prep.c static uint32_t PREP_io_800_readb (void *opaque,

Quoted 18 lines
hw/ppc_prep.c +4 -3
         sysctrl->contiguous_map = val & 0x01;
         break;
     default:
-        printf("ERROR: unaffected IO port write: %04" PRIx32
-               " => %02" PRIx32"\n", addr, val);
+        printf("ERROR: unaffected IO port write: %04" PRIx64
+               " => %02" PRIx64 "\n", addr, val);
         break;
     }
 }
 
-static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
+static uint64_t PREP_io_800_readb(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
 {
     sysctrl_t *sysctrl = opaque;
     uint32_t retval = 0xFF;
@@ -393,15 +419,25 @@ static uint32_t PREP_io_800_readb (void *opaque,

uint32_t addr)

Quoted 16 lines
hw/ppc_prep.c +4 -2
         retval = sysctrl->contiguous_map;
         break;
     default:
-        printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr);
+        printf("ERROR: unaffected IO port: %04" PRIx64 " read\n", addr);
         break;
     }
-    PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n",
+    PPC_IO_DPRINTF("0x%08" PRIx64 " <= 0x%02" PRIx64 "\n",
                    addr - PPC_IO_BASE, retval);
 
     return retval;
 }
 
+static const MemoryRegionOps PREP_io_800_ops = {
+    .read = PREP_io_800_readb,

hw/ppc_prep.c static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)

Quoted 10 lines
hw/ppc_prep.c +8 -0
+    .write = PREP_io_800_writeb,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 1,
+    },
+};
+
 static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl,
                                                  target_phys_addr_t

addr)

Quoted 16 lines
hw/ppc_prep.c +4 -0
 {
@@ -514,6 +550,10 @@ static void ppc_prep_init (ram_addr_t ram_size,
     M48t59State *m48t59;
     MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
     MemoryRegion *intack = g_new(MemoryRegion, 1);
+    MemoryRegion *io_speaker = g_new(MemoryRegion, 1);
+    MemoryRegion *io_fake = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_092 = g_new(MemoryRegion, 1);
+    MemoryRegion *io_control_800 = g_new(MemoryRegion, 1);
 #if 0
     MemoryRegion *xcsr = g_new(MemoryRegion, 1);
 #endif
@@ -679,17 +719,21 @@ static void ppc_prep_init (ram_addr_t ram_size,
     fdctrl_init_isa(fd);
 
     /* Register speaker port */

hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 727

Quoted 10 lines
hw/ppc_prep.c +4 -4
-    register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
-    register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
+    memory_region_init_io(io_speaker, &speaker_ioport_ops, NULL,
+                          "speaker", 1);
+    memory_region_add_subregion(sysmem, 0x61, io_speaker);
     /* Register fake IO ports for PREP */
     sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
-    register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
-    register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
+    memory_region_init_io(io_fake, &PREP_io_ops, sysctrl, "prep-fake",

2);

hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size,

Quoted 4 lines
hw/ppc_prep.c +1 -2
+    memory_region_add_subregion(sysmem, 0x398, io_fake);
     /* System control ports */
-    register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb,

sysctrl);

hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 692

Quoted 2 lines
hw/ppc_prep.c +0 -2
-    register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
-    register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb,

sysctrl);

hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size,

Quoted 9 lines
hw/ppc_prep.c +7 -0
+    memory_region_init_io(io_control_092, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x92", 1);
+    memory_region_add_subregion(sysmem, 0x0092, io_control_092);
+
+    memory_region_init_io(io_control_800, &PREP_io_800_ops, sysctrl,
+                          "prep-control-0x800", 52);
+    memory_region_add_subregion(sysmem, 0x0800, io_control_800);
     /* PCI intack location */
     memory_region_init_io(intack, &PPC_intack_ops, NULL, "ppc-intack",

4);

Quoted 1 line
hw/ppc_prep.c +0 -0
     memory_region_add_subregion(sysmem, 0xBFFFFFF0, intack);
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] ppc_prep: convert ioport to memory API

In reply to Andreas Färber
Quoted 2 lines

I'll test later. Did you in some way?

After testing it occurs this patch is plain wrong.It make qemu segfault. I'll try to fix it.

Regards

Benoit