mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
serial: initial qom-ification
Make SerialState a device (the following patches will introduce IO/MM sysbus serial devices) None of the serial_{,mm}_init() callers actually free the returned value (even if they did, it would be quite harmless), so we can change the object allocation at will. However, the devices that embed SerialState must now have their field QOM-initialized manually (isa, pci, pci-multi). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
4305d4825c
commit
7781b88ee4
5 changed files with 70 additions and 8 deletions
|
@ -181,10 +181,24 @@ static void multi_4x_serial_pci_class_initfn(ObjectClass *klass, void *data)
|
|||
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
|
||||
}
|
||||
|
||||
static void multi_serial_init(Object *o)
|
||||
{
|
||||
PCIDevice *dev = PCI_DEVICE(o);
|
||||
PCIMultiSerialState *pms = DO_UPCAST(PCIMultiSerialState, dev, dev);
|
||||
size_t i, nports = multi_serial_get_port_count(PCI_DEVICE_GET_CLASS(dev));
|
||||
|
||||
for (i = 0; i < nports; i++) {
|
||||
object_initialize_child(o, "serial[*]", &pms->state[i],
|
||||
sizeof(pms->state[i]),
|
||||
TYPE_SERIAL, &error_abort, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static const TypeInfo multi_2x_serial_pci_info = {
|
||||
.name = "pci-serial-2x",
|
||||
.parent = TYPE_PCI_DEVICE,
|
||||
.instance_size = sizeof(PCIMultiSerialState),
|
||||
.instance_init = multi_serial_init,
|
||||
.class_init = multi_2x_serial_pci_class_initfn,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
||||
|
@ -196,6 +210,7 @@ static const TypeInfo multi_4x_serial_pci_info = {
|
|||
.name = "pci-serial-4x",
|
||||
.parent = TYPE_PCI_DEVICE,
|
||||
.instance_size = sizeof(PCIMultiSerialState),
|
||||
.instance_init = multi_serial_init,
|
||||
.class_init = multi_4x_serial_pci_class_initfn,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue