piolist: add owner argument to initialization functions and pass devices

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2013-06-06 21:19:53 -04:00
parent 3cd2cf4375
commit db10ca9057
10 changed files with 17 additions and 12 deletions

View File

@ -349,7 +349,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)
adlib_portio_list[1].offset = s->port; adlib_portio_list[1].offset = s->port;
adlib_portio_list[2].offset = s->port + 8; adlib_portio_list[2].offset = s->port + 8;
portio_list_init (port_list, adlib_portio_list, s, "adlib"); portio_list_init (port_list, OBJECT(s), adlib_portio_list, s, "adlib");
portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0); portio_list_add (port_list, isa_address_space_io(&s->parent_obj), 0);
} }

View File

@ -2070,7 +2070,8 @@ static int qxl_init_primary(PCIDevice *dev)
vga_common_init(vga, OBJECT(dev)); vga_common_init(vga, OBJECT(dev));
vga_init(vga, OBJECT(dev), vga_init(vga, OBJECT(dev),
pci_address_space(dev), pci_address_space_io(dev), false); pci_address_space(dev), pci_address_space_io(dev), false);
portio_list_init(qxl_vga_port_list, qxl_vga_portio_list, vga, "vga"); portio_list_init(qxl_vga_port_list, OBJECT(dev), qxl_vga_portio_list,
vga, "vga");
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0); portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
vga->con = graphic_console_init(DEVICE(dev), &qxl_ops, qxl); vga->con = graphic_console_init(DEVICE(dev), &qxl_ops, qxl);

View File

@ -2372,11 +2372,11 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
1); 1);
memory_region_set_coalescing(vga_io_memory); memory_region_set_coalescing(vga_io_memory);
if (init_vga_ports) { if (init_vga_ports) {
portio_list_init(vga_port_list, vga_ports, s, "vga"); portio_list_init(vga_port_list, obj, vga_ports, s, "vga");
portio_list_add(vga_port_list, address_space_io, 0x3b0); portio_list_add(vga_port_list, address_space_io, 0x3b0);
} }
if (vbe_ports) { if (vbe_ports) {
portio_list_init(vbe_port_list, vbe_ports, s, "vbe"); portio_list_init(vbe_port_list, obj, vbe_ports, s, "vbe");
portio_list_add(vbe_port_list, address_space_io, 0x1ce); portio_list_add(vbe_port_list, address_space_io, 0x1ce);
} }
} }

View File

@ -139,7 +139,7 @@ static void i82374_isa_realize(DeviceState *dev, Error **errp)
I82374State *s = &isa->state; I82374State *s = &isa->state;
PortioList *port_list = g_new(PortioList, 1); PortioList *port_list = g_new(PortioList, 1);
portio_list_init(port_list, i82374_portio_list, s, "i82374"); portio_list_init(port_list, OBJECT(isa), i82374_portio_list, s, "i82374");
portio_list_add(port_list, isa_address_space_io(&isa->parent_obj), portio_list_add(port_list, isa_address_space_io(&isa->parent_obj),
isa->iobase); isa->iobase);

View File

@ -115,7 +115,7 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start,
actually handled e.g. the FDC device. */ actually handled e.g. the FDC device. */
isa_init_ioport(dev, start); isa_init_ioport(dev, start);
portio_list_init(piolist, pio_start, opaque, name); portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name);
portio_list_add(piolist, isabus->address_space_io, start); portio_list_add(piolist, isabus->address_space_io, start);
} }

View File

@ -443,7 +443,7 @@ static int vt82c686b_initfn(PCIDevice *d)
} }
} }
memory_region_init_io(&vt82c->superio, NULL, &superio_ops, memory_region_init_io(&vt82c->superio, OBJECT(d), &superio_ops,
&vt82c->superio_conf, "superio", 2); &vt82c->superio_conf, "superio", 2);
memory_region_set_enabled(&vt82c->superio, false); memory_region_set_enabled(&vt82c->superio, false);
/* The floppy also uses 0x3f0 and 0x3f1. /* The floppy also uses 0x3f0 and 0x3f1.

View File

@ -653,7 +653,7 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET]; sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
portio_list_init(port_list, prep_portio_list, sysctrl, "prep"); portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep");
portio_list_add(port_list, get_system_io(), 0x0); portio_list_add(port_list, get_system_io(), 0x0);
/* PowerPC control and status register group */ /* PowerPC control and status register group */

View File

@ -112,7 +112,7 @@ static void wdt_ib700_realize(DeviceState *dev, Error **errp)
s->timer = qemu_new_timer_ns(vm_clock, ib700_timer_expired, s); s->timer = qemu_new_timer_ns(vm_clock, ib700_timer_expired, s);
portio_list_init(port_list, wdt_portio_list, s, "ib700"); portio_list_init(port_list, OBJECT(s), wdt_portio_list, s, "ib700");
portio_list_add(port_list, isa_address_space_io(&s->parent_obj), 0); portio_list_add(port_list, isa_address_space_io(&s->parent_obj), 0);
} }

View File

@ -25,6 +25,7 @@
#define IOPORT_H #define IOPORT_H
#include "qemu-common.h" #include "qemu-common.h"
#include "qom/object.h"
#include "exec/memory.h" #include "exec/memory.h"
typedef uint32_t pio_addr_t; typedef uint32_t pio_addr_t;
@ -53,6 +54,7 @@ uint32_t cpu_inl(pio_addr_t addr);
typedef struct PortioList { typedef struct PortioList {
const struct MemoryRegionPortio *ports; const struct MemoryRegionPortio *ports;
Object *owner;
struct MemoryRegion *address_space; struct MemoryRegion *address_space;
unsigned nr; unsigned nr;
struct MemoryRegion **regions; struct MemoryRegion **regions;
@ -60,7 +62,7 @@ typedef struct PortioList {
const char *name; const char *name;
} PortioList; } PortioList;
void portio_list_init(PortioList *piolist, void portio_list_init(PortioList *piolist, Object *owner,
const struct MemoryRegionPortio *callbacks, const struct MemoryRegionPortio *callbacks,
void *opaque, const char *name); void *opaque, const char *name);
void portio_list_destroy(PortioList *piolist); void portio_list_destroy(PortioList *piolist);

View File

@ -106,6 +106,7 @@ uint32_t cpu_inl(pio_addr_t addr)
} }
void portio_list_init(PortioList *piolist, void portio_list_init(PortioList *piolist,
Object *owner,
const MemoryRegionPortio *callbacks, const MemoryRegionPortio *callbacks,
void *opaque, const char *name) void *opaque, const char *name)
{ {
@ -120,6 +121,7 @@ void portio_list_init(PortioList *piolist,
piolist->regions = g_new0(MemoryRegion *, n); piolist->regions = g_new0(MemoryRegion *, n);
piolist->address_space = NULL; piolist->address_space = NULL;
piolist->opaque = opaque; piolist->opaque = opaque;
piolist->owner = owner;
piolist->name = name; piolist->name = name;
} }
@ -211,8 +213,8 @@ static void portio_list_add_1(PortioList *piolist,
* Use an alias so that the callback is called with an absolute address, * Use an alias so that the callback is called with an absolute address,
* rather than an offset relative to to start + off_low. * rather than an offset relative to to start + off_low.
*/ */
memory_region_init_io(&mrpio->mr, NULL, &portio_ops, mrpio, piolist->name, memory_region_init_io(&mrpio->mr, piolist->owner, &portio_ops, mrpio,
off_high - off_low); piolist->name, off_high - off_low);
memory_region_add_subregion(piolist->address_space, memory_region_add_subregion(piolist->address_space,
start + off_low, &mrpio->mr); start + off_low, &mrpio->mr);
piolist->regions[piolist->nr] = &mrpio->mr; piolist->regions[piolist->nr] = &mrpio->mr;