Simon Horman
2009-Feb-23 09:18 UTC
[Xen-devel] [patch 0/4] ioemu: clean up struct PHPSlots
Hi, this series extracts the struct struct PHPSlots portion of my previous series "[rfc 00/18] ioemu: use devfn instead of slots as the unit for passthrough". -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Feb-23 09:18 UTC
[Xen-devel] [patch 1/4] ioemu: piix4acpi.c: Simplfy PHPSlots structure
The anonymouys structure inside PHPSlots only has one element, so things can be simplified by moving the element into PHPSlots and removing the anonymous structure. Signed-off-by: Simon Horman <horms@verge.net.au> Index: ioemu-remote/hw/piix4acpi.c ==================================================================--- ioemu-remote.orig/hw/piix4acpi.c 2009-02-23 19:33:41.000000000 +1100 +++ ioemu-remote/hw/piix4acpi.c 2009-02-23 19:34:14.000000000 +1100 @@ -77,9 +77,7 @@ typedef struct GPEState { GPEState gpe_state; typedef struct PHPSlots { - struct { - uint8_t status; /* Apaptor stats */ - } slot[ACPI_PHP_SLOT_NUM]; + uint8_t status[ACPI_PHP_SLOT_NUM]; /* Apaptor stats */ uint8_t plug_evt; /* slot|event slot:0-no event;1-1st. event:0-remove;1-add */ } PHPSlots; @@ -240,7 +238,7 @@ static uint32_t acpi_php_readb(void *opa break; default: num = addr - ACPI_PHP_IO_ADDR - 1; - val = hotplug_slots->slot[num].status; + val = hotplug_slots->status[num]; } fprintf(logfile, "ACPI PCI hotplug: read addr=0x%x, val=0x%x.\n", @@ -265,7 +263,7 @@ static void acpi_php_writeb(void *opaque php_slot = addr - ACPI_PHP_IO_ADDR - 1; if ( val == 0x1 ) { /* Eject command */ /* make _STA of the slot 0 */ - hotplug_slots->slot[php_slot].status = 0; + hotplug_slots->status[php_slot] = 0; /* clear the hotplug event */ hotplug_slots->plug_evt = 0; @@ -284,7 +282,7 @@ static void pcislots_save(QEMUFile* f, v PHPSlots *s = (PHPSlots*)opaque; int i; for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { - qemu_put_8s( f, &s->slot[i].status); + qemu_put_8s( f, &s->status[i]); } qemu_put_8s(f, &s->plug_evt); } @@ -296,7 +294,7 @@ static int pcislots_load(QEMUFile* f, vo if (version_id != 1) return -EINVAL; for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { - qemu_get_8s( f, &s->slot[i].status); + qemu_get_8s( f, &s->status[i]); } qemu_get_8s(f, &s->plug_evt); return 0; @@ -311,7 +309,7 @@ static void php_slots_init(void) /* update the pci slot status */ for ( i = 0; i < PHP_SLOT_LEN; i++ ) { if ( test_pci_slot( PHP_TO_PCI_SLOT(i) ) == 1 ) - slots->slot[i].status = 0xf; + slots->status[i] = 0xf; } @@ -495,7 +493,7 @@ void acpi_php_add(int pci_slot) hotplug_slots->plug_evt = (((php_slot+1) << 4) | PHP_EVT_ADD); /* update the slot status as present */ - hotplug_slots->slot[php_slot].status = 0xf; + hotplug_slots->status[php_slot]= 0xf; /* power on the slot */ power_on_php_slot(php_slot); -- -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Feb-23 09:18 UTC
[Xen-devel] [patch 2/4] ioemu: piix4acpi.c: Consistently dont cast opaque to PHPSlots
Some instances were cast and others were not. This patch makes all instances not cast opaque into PHPSlots. Also consistently use hotplug_slots as the variable to which opaque is assigned. Signed-off-by: Simon Horman <horms@verge.net.au> Index: ioemu-remote/hw/piix4acpi.c ==================================================================--- ioemu-remote.orig/hw/piix4acpi.c 2009-02-23 19:31:54.000000000 +1100 +++ ioemu-remote/hw/piix4acpi.c 2009-02-23 19:32:36.000000000 +1100 @@ -279,24 +279,24 @@ static void acpi_php_writeb(void *opaque static void pcislots_save(QEMUFile* f, void* opaque) { - PHPSlots *s = (PHPSlots*)opaque; + PHPSlots *hotplug_slots = opaque; int i; for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { - qemu_put_8s( f, &s->status[i]); + qemu_put_8s( f, &hotplug_slots->status[i]); } - qemu_put_8s(f, &s->plug_evt); + qemu_put_8s(f, &hotplug_slots->plug_evt); } static int pcislots_load(QEMUFile* f, void* opaque, int version_id) { - PHPSlots *s = (PHPSlots*)opaque; + PHPSlots *hotplug_slots = opaque; int i; if (version_id != 1) return -EINVAL; for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { - qemu_get_8s( f, &s->status[i]); + qemu_get_8s( f, &hotplug_slots->status[i]); } - qemu_get_8s(f, &s->plug_evt); + qemu_get_8s(f, &hotplug_slots->plug_evt); return 0; } -- -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Feb-23 09:18 UTC
[Xen-devel] [patch 3/4] ioemu: piix4acpi.c: remove unnecessary assignment of pci_slots to local variables
Signed-off-by: Simon Horman <horms@verge.net.au> Index: ioemu-remote/hw/piix4acpi.c ==================================================================--- ioemu-remote/hw/piix4acpi.c 2009-01-02 16:13:05.000000000 +1100 +++ ioemu-remote/hw/piix4acpi.c 2009-01-02 16:15:29.000000000 +1100 @@ -302,21 +302,23 @@ static int pcislots_load(QEMUFile* f, vo static void php_slots_init(void) { - PHPSlots *slots = &php_slots; int i; - memset(slots, 0, sizeof(PHPSlots)); + memset(&php_slots, 0, sizeof(PHPSlots)); /* update the pci slot status */ for ( i = 0; i < PHP_SLOT_LEN; i++ ) { if ( test_pci_slot( PHP_TO_PCI_SLOT(i) ) == 1 ) - slots->status[i] = 0xf; + php_slots.status[i] = 0xf; } /* ACPI PCI hotplug controller */ - register_ioport_read(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, acpi_php_readb, slots); - register_ioport_write(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, acpi_php_writeb, slots); - register_savevm("pcislots", 0, 1, pcislots_save, pcislots_load, slots); + register_ioport_read(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, + acpi_php_readb, &php_slots); + register_ioport_write(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, + acpi_php_writeb, &php_slots); + register_savevm("pcislots", 0, 1, pcislots_save, pcislots_load, + &php_slots); } /* GPEx_STS occupy 1st half of the block, while GPEx_EN 2nd half */ @@ -452,7 +454,6 @@ static void acpi_sci_intr(GPEState *s) void acpi_php_del(int pci_slot) { GPEState *s = &gpe_state; - PHPSlots *hotplug_slots = &php_slots; int php_slot = PCI_TO_PHP_SLOT(pci_slot); if ( pci_slot < PHP_SLOT_START || pci_slot >= PHP_SLOT_END ) { @@ -462,7 +463,7 @@ void acpi_php_del(int pci_slot) } /* update the php controller status */ - hotplug_slots->plug_evt = (((php_slot+1) << 4) | PHP_EVT_REMOVE); + php_slots.plug_evt = (((php_slot+1) << 4) | PHP_EVT_REMOVE); /* generate a SCI interrupt */ acpi_sci_intr(s); @@ -471,7 +472,6 @@ void acpi_php_del(int pci_slot) void acpi_php_add(int pci_slot) { GPEState *s = &gpe_state; - PHPSlots *hotplug_slots = &php_slots; int php_slot = PCI_TO_PHP_SLOT(pci_slot); char ret_str[30]; @@ -490,10 +490,10 @@ void acpi_php_add(int pci_slot) } /* update the php controller status */ - hotplug_slots->plug_evt = (((php_slot+1) << 4) | PHP_EVT_ADD); + php_slots.plug_evt = (((php_slot+1) << 4) | PHP_EVT_ADD); /* update the slot status as present */ - hotplug_slots->status[php_slot]= 0xf; + php_slots.status[php_slot]= 0xf; /* power on the slot */ power_on_php_slot(php_slot); -- -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Feb-23 09:18 UTC
[Xen-devel] [patch 4/4] ioemu: piix4acpi.c: remove ACPI_PHP_SLOT_NUM
ACPI_PHP_SLOT_NUM is equivalent to PHP_SLOT_LEN and both are used inside piix4acpi.c. So for the sake of consistency remove ACPI_PHP_SLOT_NUM. Signed-off-by: Simon Horman <horms@verge.net.au> Index: ioemu-remote/hw/piix4acpi.c ==================================================================--- ioemu-remote.orig/hw/piix4acpi.c 2009-02-23 19:37:08.000000000 +1100 +++ ioemu-remote/hw/piix4acpi.c 2009-02-23 19:37:22.000000000 +1100 @@ -54,8 +54,6 @@ /* The bit in GPE0_STS/EN to notify the pci hotplug event */ #define ACPI_PHP_GPE_BIT 3 -#define ACPI_PHP_SLOT_NUM PHP_SLOT_LEN - typedef struct AcpiDeviceState AcpiDeviceState; AcpiDeviceState *acpi_device_table; @@ -77,7 +75,7 @@ typedef struct GPEState { GPEState gpe_state; typedef struct PHPSlots { - uint8_t status[ACPI_PHP_SLOT_NUM]; /* Apaptor stats */ + uint8_t status[PHP_SLOT_LEN]; /* Apaptor stats */ uint8_t plug_evt; /* slot|event slot:0-no event;1-1st. event:0-remove;1-add */ } PHPSlots; @@ -281,7 +279,7 @@ static void pcislots_save(QEMUFile* f, v { PHPSlots *hotplug_slots = opaque; int i; - for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { + for ( i = 0; i < PHP_SLOT_LEN; i++ ) { qemu_put_8s( f, &hotplug_slots->status[i]); } qemu_put_8s(f, &hotplug_slots->plug_evt); @@ -293,7 +291,7 @@ static int pcislots_load(QEMUFile* f, vo int i; if (version_id != 1) return -EINVAL; - for ( i = 0; i < ACPI_PHP_SLOT_NUM; i++ ) { + for ( i = 0; i < PHP_SLOT_LEN; i++ ) { qemu_get_8s( f, &hotplug_slots->status[i]); } qemu_get_8s(f, &hotplug_slots->plug_evt); @@ -313,9 +311,9 @@ static void php_slots_init(void) /* ACPI PCI hotplug controller */ - register_ioport_read(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, + register_ioport_read(ACPI_PHP_IO_ADDR, PHP_SLOT_LEN + 1, 1, acpi_php_readb, &php_slots); - register_ioport_write(ACPI_PHP_IO_ADDR, ACPI_PHP_SLOT_NUM + 1, 1, + register_ioport_write(ACPI_PHP_IO_ADDR, PHP_SLOT_LEN + 1, 1, acpi_php_writeb, &php_slots); register_savevm("pcislots", 0, 1, pcislots_save, pcislots_load, &php_slots); -- -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel