On 04/02/2012 05:37 PM, Julien Grall wrote:
> Replace register_ioport* by portio_list_*.
> All ioports registered by the previous functions don't call memory callback.
>
> Signed-off-by: Julien Grall
> ---
> hw/acpi_piix4.c | 22 +++---
> hw/cirrus_vga.c | 31 ++-
> hw/pc.c | 39 +--
> hw/serial.c | 13 +++--
Please split into separate patches.
> @@ -27,6 +27,7 @@
> #include "sysemu.h"
> #include "range.h"
> #include "ioport.h"
> +#include "exec-memory.h"
>
Remove please.
> //#define DEBUG
>
> @@ -325,10 +326,23 @@ static void piix4_pm_machine_ready(Notifier *n, void
> *opaque)
>
> }
>
> +static const MemoryRegionPortio piix4_portio_list[] = {
> +{ 0x00, 64, 1, .read = smb_ioport_readb, }, /* s->smb_io_base */
> +{ 0x00, 64, 1, .write = smb_ioport_writeb, }, /* s->smb_io_base */
> +PORTIO_END_OF_LIST(),
> +};
> +
> +static const MemoryRegionPortio acpi_portio_list[] = {
> +{ 0x00, 4, 4, .write = acpi_dbg_writel, }, /* ACPI_DBG_IO_ADDR */
> +PORTIO_END_OF_LIST(),
> +};
> +
> static int piix4_pm_initfn(PCIDevice *dev)
> {
> PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
> uint8_t *pci_conf;
> +PortioList *piix4_port_list = g_new(PortioList, 1);
> +PortioList *acpi_port_list = g_new(PortioList, 1);
>
Make these fields in PIIX4PMState to avoid the allocation.
> pci_conf = s->dev.config;
> pci_conf[0x06] = 0x80;
> @@ -341,7 +355,8 @@ static int piix4_pm_initfn(PCIDevice *dev)
> /* APM */
> apm_init(&s->apm, apm_ctrl_changed, s);
>
> -register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);
> +portio_list_init(acpi_port_list, acpi_portio_list, s, "piix4-acpi");
> +portio_list_add(acpi_port_list, get_system_io(), ACPI_DBG_IO_ADDR);
Use pci_address_space_io() instead.
>
> if (s->kvm_enabled) {
> /* Mark SMM as already inited to prevent SMM from running. KVM does
> not
> @@ -354,8 +369,9 @@ static int piix4_pm_initfn(PCIDevice *dev)
> pci_conf[0x90] = s->smb_io_base | 1;
> pci_conf[0x91] = s->smb_io_base >> 8;
> pci_conf[0xd2] = 0x09;
> -register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb);
> -register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
> +
> +portio_list_init(piix4_port_list, piix4_portio_list, s, "piix4-acpi");
> +portio_list_add(piix4_port_list, get_system_io(), s->smb_io_base);
pci_address_space_io()
>
> acpi_pm_tmr_init(&s->ar, pm_tmr_timer);
> acpi_gpe_init(&s->ar, GPE_LEN);
> diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
> index afedaa4..aae82d5 100644
> --- a/hw/cirrus_vga.c
> +++ b/hw/cirrus_vga.c
> @@ -32,6 +32,7 @@
> #include "console.h"
> #include "vga_int.h"
> #include "loader.h"
> +#include "exec-memory.h"
>
Remove.
> /*
> * TODO:
> @@ -2781,11 +2782,26 @@ static const MemoryRegionOps cirrus_linear_io_ops = {
> },
> };
>
> +static const MemoryRegionPortio cirrus_portio_list[] = {
> +{ 0x04, 2, 1, .write = cirrus_vga_ioport_write,
> +.read = cirrus_vga_ioport_read, }, /* 0x3b4 */
> +{ 0x0a, 1, 1, .write = cirrus_vga_ioport_write,
> +.read = cirrus_vga_ioport_read, }, /* 0x3ba */
> +{ 0x10, 16, 1, .write = cirrus_vga_ioport_write,
> +.read = cirrus_vga_ioport_read, }, /* 0x3c0 */
> +{ 0x24, 2, 1, .write = cirrus_vga_ioport_write,
> +.read = cirrus_vga_ioport_read, }, /* 0x3d4 */
> +{ 0x2a, 1, 1, .write = cirrus_vga_ioport_write,
> +.read = cirrus_vga_ioport_read, }, /* 0x3da */
> +PORTIO_END_OF_LIST (),
> +};
> +
> static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci,
> MemoryRegion *system_memory)
> {
> int i;
> static int inited;
> +PortioList *cirrus_port_list = g_new(PortioList, 1);
>
Into CirrusVGAState.
> if (!inited) {
> inited = 1;
> @@ -2814,19 +2830,8 @@ static void cirrus_init_common(CirrusVGAState * s, int
> device_id, int is_pci,
> s->bustype = CIRRUS_BUSTYPE_ISA;
> }
>
> -register_ioport_write(0x3c0, 16, 1, cirrus_vga_ioport_write, s);
> -
> -register_ioport_write(0x3b4, 2, 1, cirrus_vga_ioport_write, s);
> -register_ioport_write(0x3d4, 2, 1, cirrus_vga_ioport_write, s);
> -register_ioport_write(0x3ba, 1, 1, cirrus_vga_ioport_write, s);
> -register_ioport_write(0x3da, 1, 1, cirrus_vga_ioport_write, s);
> -
> -register_ioport_read(0x3c0, 16, 1, cirrus_vga_ioport_read, s);
> -
> -register_ioport_read(0x3b4, 2, 1, cirrus_vga_ioport_read, s);
> -register_ioport_read(0x3d4, 2, 1, cirrus_vga_ioport_read, s);
> -register_ioport_read(0x3ba, 1, 1, cirrus_vga_ioport_read, s);
> -register_ioport_read(0x3da, 1, 1, cirrus_vga_ioport_read, s);
> +portio_list_init(cirrus_port_list, cirrus_portio_list, s, "cirrus-io");
> +portio_list_add(cirrus_port_list, get