qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 26/42] hw/isa/piix4: Make PIIX4's ACPI and USB functions opti


From: Bernhard Beschow
Subject: Re: [PATCH 26/42] hw/isa/piix4: Make PIIX4's ACPI and USB functions optional
Date: Sun, 18 Sep 2022 21:47:52 +0000

Am 18. September 2022 20:10:51 UTC schrieb Mark Cave-Ayland 
<mark.cave-ayland@ilande.co.uk>:
>On 01/09/2022 17:25, Bernhard Beschow wrote:
>
>> This aligns PIIX4 with PIIX3.
>> 
>> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
>> ---
>>   hw/isa/piix4.c  | 44 ++++++++++++++++++++++++++++++++------------
>>   hw/mips/malta.c |  6 ++++--
>>   2 files changed, 36 insertions(+), 14 deletions(-)
>> 
>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>> index 67881e3a75..ed9eca715f 100644
>> --- a/hw/isa/piix4.c
>> +++ b/hw/isa/piix4.c
>> @@ -50,9 +50,16 @@ struct PIIX4State {
>>       PCIIDEState ide;
>>       UHCIState uhci;
>>       PIIX4PMState pm;
>> +
>> +    uint32_t smb_io_base;
>> +
>>       /* Reset Control Register */
>>       MemoryRegion rcr_mem;
>>       uint8_t rcr;
>> +
>> +    bool has_acpi;
>> +    bool has_usb;
>> +    bool smm_enabled;
>>   };
>>     OBJECT_DECLARE_SIMPLE_TYPE(PIIX4State, PIIX4_PCI_DEVICE)
>> @@ -258,17 +265,26 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
>>       }
>>         /* USB */
>> -    qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
>> -    if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
>> -        return;
>> +    if (s->has_usb) {
>> +        object_initialize_child(OBJECT(dev), "uhci", &s->uhci,
>> +                                "piix4-usb-uhci");
>
>Can you use the relevant TYPE_ macro here for the USB-UHCI device?
>
>> +        qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
>> +        if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
>> +            return;
>> +        }
>>       }
>>         /* ACPI controller */
>> -    qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
>> -    if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
>> -        return;
>> +    if (s->has_acpi) {
>> +        object_initialize_child(OBJECT(s), "pm", &s->pm, TYPE_PIIX4_PM);
>> +        qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
>> +        qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", s->smb_io_base);
>> +        qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", s->smm_enabled);
>> +        if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
>> +            return;
>> +        }
>> +        qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
>>       }
>> -    qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
>>         pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, 
>> PIIX_NUM_PIRQS);
>>   }
>> @@ -279,13 +295,16 @@ static void piix4_init(Object *obj)
>>         object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
>>       object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
>
>... and same here for IDE?

Sure!

Best regards,
Bernhard
>
>> -    object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
>> -
>> -    object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM);
>> -    qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100);
>> -    qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0);
>>   }
>>   +static Property piix4_props[] = {
>> +    DEFINE_PROP_UINT32("smb_io_base", PIIX4State, smb_io_base, 0),
>> +    DEFINE_PROP_BOOL("has-acpi", PIIX4State, has_acpi, true),
>> +    DEFINE_PROP_BOOL("has-usb", PIIX4State, has_usb, true),
>> +    DEFINE_PROP_BOOL("smm-enabled", PIIX4State, smm_enabled, false),
>> +    DEFINE_PROP_END_OF_LIST(),
>> +};
>> +
>>   static void piix4_class_init(ObjectClass *klass, void *data)
>>   {
>>       DeviceClass *dc = DEVICE_CLASS(klass);
>> @@ -304,6 +323,7 @@ static void piix4_class_init(ObjectClass *klass, void 
>> *data)
>>        */
>>       dc->user_creatable = false;
>>       dc->hotpluggable = false;
>> +    device_class_set_props(dc, piix4_props);
>>   }
>>     static const TypeInfo piix4_info = {
>> diff --git a/hw/mips/malta.c b/hw/mips/malta.c
>> index a4b866a2cf..6339b0d66c 100644
>> --- a/hw/mips/malta.c
>> +++ b/hw/mips/malta.c
>> @@ -1400,8 +1400,10 @@ void mips_malta_init(MachineState *machine)
>>       empty_slot_init("GT64120", 0, 0x20000000);
>>         /* Southbridge */
>> -    piix4 = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0), true,
>> -                                            TYPE_PIIX4_PCI_DEVICE);
>> +    piix4 = pci_new_multifunction(PCI_DEVFN(10, 0), true,
>> +                                  TYPE_PIIX4_PCI_DEVICE);
>> +    qdev_prop_set_uint32(DEVICE(piix4), "smb_io_base", 0x1100);
>> +    pci_realize_and_unref(piix4, pci_bus, &error_fatal);
>>       isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix4), "isa.0"));
>>         dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "ide"));
>
>
>ATB,
>
>Mark.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]