All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ioapic: Convert to memory API
@ 2011-10-16 17:21 Jan Kiszka
  2011-10-17 10:35 ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2011-10-16 17:21 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

From: Jan Kiszka <jan.kiszka@siemens.com>

Dispatching byte and word accesses like dwords looks strange, but let's
just convert mechanically.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/ioapic.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/hw/ioapic.c b/hw/ioapic.c
index 61991d7..5786b86 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -86,6 +86,7 @@ typedef struct IOAPICState IOAPICState;
 
 struct IOAPICState {
     SysBusDevice busdev;
+    MemoryRegion io_memory;
     uint8_t id;
     uint8_t ioregsel;
     uint32_t irr;
@@ -309,32 +310,25 @@ static void ioapic_reset(DeviceState *d)
     }
 }
 
-static CPUReadMemoryFunc * const ioapic_mem_read[3] = {
-    ioapic_mem_readl,
-    ioapic_mem_readl,
-    ioapic_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const ioapic_mem_write[3] = {
-    ioapic_mem_writel,
-    ioapic_mem_writel,
-    ioapic_mem_writel,
+static const MemoryRegionOps ioapic_io_ops = {
+    .old_mmio = {
+        .read = { ioapic_mem_readl, ioapic_mem_readl, ioapic_mem_readl, },
+        .write = { ioapic_mem_writel, ioapic_mem_writel, ioapic_mem_writel, },
+    },
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static int ioapic_init1(SysBusDevice *dev)
 {
     IOAPICState *s = FROM_SYSBUS(IOAPICState, dev);
-    int io_memory;
     static int ioapic_no;
 
     if (ioapic_no >= MAX_IOAPICS) {
         return -1;
     }
 
-    io_memory = cpu_register_io_memory(ioapic_mem_read,
-                                       ioapic_mem_write, s,
-                                       DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, 0x1000, io_memory);
+    memory_region_init_io(&s->io_memory, &ioapic_io_ops, s, "ioapic", 0x1000);
+    sysbus_init_mmio_region(dev, &s->io_memory);
 
     qdev_init_gpio_in(&dev->qdev, ioapic_set_irq, IOAPIC_NUM_PINS);
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] ioapic: Convert to memory API
  2011-10-16 17:21 [Qemu-devel] [PATCH] ioapic: Convert to memory API Jan Kiszka
@ 2011-10-17 10:35 ` Avi Kivity
  2011-10-17 11:11   ` [Qemu-devel] [PATCH v2 1/2] " Jan Kiszka
  2011-10-17 11:11   ` [Qemu-devel] [PATCH 2/2] ioapic: Reject non-dword accesses to IOWIN register Jan Kiszka
  0 siblings, 2 replies; 5+ messages in thread
From: Avi Kivity @ 2011-10-17 10:35 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

On 10/16/2011 07:21 PM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Dispatching byte and word accesses like dwords looks strange, but let's
> just convert mechanically.
>
>  
> -static CPUReadMemoryFunc * const ioapic_mem_read[3] = {
> -    ioapic_mem_readl,
> -    ioapic_mem_readl,
> -    ioapic_mem_readl,
> -};
> -
> -static CPUWriteMemoryFunc * const ioapic_mem_write[3] = {
> -    ioapic_mem_writel,
> -    ioapic_mem_writel,
> -    ioapic_mem_writel,
> +static const MemoryRegionOps ioapic_io_ops = {
> +    .old_mmio = {
> +        .read = { ioapic_mem_readl, ioapic_mem_readl, ioapic_mem_readl, },
> +        .write = { ioapic_mem_writel, ioapic_mem_writel, ioapic_mem_writel, },
> +    },
> +    .endianness = DEVICE_NATIVE_ENDIAN,
>  };

Why use old_mmio?  Use the ordinary .read and .write, and ignore the
size parameter.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] ioapic: Convert to memory API
  2011-10-17 10:35 ` Avi Kivity
@ 2011-10-17 11:11   ` Jan Kiszka
  2011-10-17 14:57     ` Avi Kivity
  2011-10-17 11:11   ` [Qemu-devel] [PATCH 2/2] ioapic: Reject non-dword accesses to IOWIN register Jan Kiszka
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2011-10-17 11:11 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

This maintains the old imprecise access size handling.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Changes in v2:
 - use new-style handlers

 hw/ioapic.c |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/hw/ioapic.c b/hw/ioapic.c
index 61991d7..56b1612 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -86,6 +86,7 @@ typedef struct IOAPICState IOAPICState;
 
 struct IOAPICState {
     SysBusDevice busdev;
+    MemoryRegion io_memory;
     uint8_t id;
     uint8_t ioregsel;
     uint32_t irr;
@@ -195,7 +196,8 @@ void ioapic_eoi_broadcast(int vector)
     }
 }
 
-static uint32_t ioapic_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t
+ioapic_mem_read(void *opaque, target_phys_addr_t addr, unsigned int size)
 {
     IOAPICState *s = opaque;
     int index;
@@ -234,7 +236,8 @@ static uint32_t ioapic_mem_readl(void *opaque, target_phys_addr_t addr)
 }
 
 static void
-ioapic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
+ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,
+                 unsigned int size)
 {
     IOAPICState *s = opaque;
     int index;
@@ -309,32 +312,23 @@ static void ioapic_reset(DeviceState *d)
     }
 }
 
-static CPUReadMemoryFunc * const ioapic_mem_read[3] = {
-    ioapic_mem_readl,
-    ioapic_mem_readl,
-    ioapic_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const ioapic_mem_write[3] = {
-    ioapic_mem_writel,
-    ioapic_mem_writel,
-    ioapic_mem_writel,
+static const MemoryRegionOps ioapic_io_ops = {
+    .read = ioapic_mem_read,
+    .write = ioapic_mem_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static int ioapic_init1(SysBusDevice *dev)
 {
     IOAPICState *s = FROM_SYSBUS(IOAPICState, dev);
-    int io_memory;
     static int ioapic_no;
 
     if (ioapic_no >= MAX_IOAPICS) {
         return -1;
     }
 
-    io_memory = cpu_register_io_memory(ioapic_mem_read,
-                                       ioapic_mem_write, s,
-                                       DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(dev, 0x1000, io_memory);
+    memory_region_init_io(&s->io_memory, &ioapic_io_ops, s, "ioapic", 0x1000);
+    sysbus_init_mmio_region(dev, &s->io_memory);
 
     qdev_init_gpio_in(&dev->qdev, ioapic_set_irq, IOAPIC_NUM_PINS);
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] ioapic: Reject non-dword accesses to IOWIN register
  2011-10-17 10:35 ` Avi Kivity
  2011-10-17 11:11   ` [Qemu-devel] [PATCH v2 1/2] " Jan Kiszka
@ 2011-10-17 11:11   ` Jan Kiszka
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-10-17 11:11 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel

Aligns the model with the spec.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/ioapic.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/ioapic.c b/hw/ioapic.c
index 56b1612..eb75766 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -208,6 +208,9 @@ ioapic_mem_read(void *opaque, target_phys_addr_t addr, unsigned int size)
         val = s->ioregsel;
         break;
     case IOAPIC_IOWIN:
+        if (size != 4) {
+            break;
+        }
         switch (s->ioregsel) {
         case IOAPIC_REG_ID:
             val = s->id << IOAPIC_ID_SHIFT;
@@ -247,6 +250,9 @@ ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,
         s->ioregsel = val;
         break;
     case IOAPIC_IOWIN:
+        if (size != 4) {
+            break;
+        }
         DPRINTF("write: %08x = %08x\n", s->ioregsel, val);
         switch (s->ioregsel) {
         case IOAPIC_REG_ID:
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] ioapic: Convert to memory API
  2011-10-17 11:11   ` [Qemu-devel] [PATCH v2 1/2] " Jan Kiszka
@ 2011-10-17 14:57     ` Avi Kivity
  0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2011-10-17 14:57 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

On 10/17/2011 01:11 PM, Jan Kiszka wrote:
> This maintains the old imprecise access size handling.
>

Thanks, applied both to memory/queue.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-17 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-16 17:21 [Qemu-devel] [PATCH] ioapic: Convert to memory API Jan Kiszka
2011-10-17 10:35 ` Avi Kivity
2011-10-17 11:11   ` [Qemu-devel] [PATCH v2 1/2] " Jan Kiszka
2011-10-17 14:57     ` Avi Kivity
2011-10-17 11:11   ` [Qemu-devel] [PATCH 2/2] ioapic: Reject non-dword accesses to IOWIN register Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.