@ -32,6 +32,7 @@
# include "hw/acpi/piix4.h"
# include "hw/acpi/pcihp.h"
# include "hw/acpi/cpu_hotplug.h"
# include "hw/hotplug.h"
//#define DEBUG
@ -44,8 +45,6 @@
# define GPE_BASE 0xafe0
# define GPE_LEN 4
# define PIIX4_PCI_HOTPLUG_STATUS 2
struct pci_status {
uint32_t up ; /* deprecated, maintained for migration compatibility */
uint32_t down ;
@ -311,24 +310,26 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque)
acpi_pm1_evt_power_down ( & s - > ar ) ;
}
static int piix4_acpi_pci_hotplug ( DeviceState * qdev , PCIDevice * dev ,
PCIHotplugState state )
static void piix4_pci_device_plug_cb ( HotplugHandler * hotplug_ dev,
DeviceState * dev , Error * * errp )
{
PIIX4PMState * s = PIIX4_PM ( qdev ) ;
int ret = acpi_pcihp_device_hotplug ( & s - > acpi_pci_hotplug , dev , state ) ;
if ( ret < 0 ) {
return ret ;
}
s - > ar . gpe . sts [ 0 ] | = PIIX4_PCI_HOTPLUG_STATUS ;
PIIX4PMState * s = PIIX4_PM ( hotplug_dev ) ;
acpi_pcihp_device_plug_cb ( & s - > ar , s - > irq , & s - > acpi_pci_hotplug , dev , errp ) ;
}
acpi_update_sci ( & s - > ar , s - > irq ) ;
return 0 ;
static void piix4_pci_device_unplug_cb ( HotplugHandler * hotplug_dev ,
DeviceState * dev , Error * * errp )
{
PIIX4PMState * s = PIIX4_PM ( hotplug_dev ) ;
acpi_pcihp_device_unplug_cb ( & s - > ar , s - > irq , & s - > acpi_pci_hotplug , dev ,
errp ) ;
}
static void piix4_update_bus_hotplug ( PCIBus * bus , void * opaque )
static void piix4_update_bus_hotplug ( PCIBus * pci_ bus, void * opaque )
{
PIIX4PMState * s = opaque ;
pci_bus_hotplug ( bus , piix4_acpi_pci_hotplug , DEVICE ( s ) ) ;
qbus_set_hotplug_handler ( BUS ( pci_bus ) , DEVICE ( s ) , & error_abort ) ;
}
static void piix4_pm_machine_ready ( Notifier * n , void * opaque )
@ -535,6 +536,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
{
DeviceClass * dc = DEVICE_CLASS ( klass ) ;
PCIDeviceClass * k = PCI_DEVICE_CLASS ( klass ) ;
HotplugHandlerClass * hc = HOTPLUG_HANDLER_CLASS ( klass ) ;
k - > init = piix4_pm_initfn ;
k - > config_write = pm_write_config ;
@ -551,6 +553,8 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
*/
dc - > cannot_instantiate_with_device_add_yet = true ;
dc - > hotpluggable = false ;
hc - > plug = piix4_pci_device_plug_cb ;
hc - > unplug = piix4_pci_device_unplug_cb ;
}
static const TypeInfo piix4_pm_info = {
@ -558,6 +562,10 @@ static const TypeInfo piix4_pm_info = {
. parent = TYPE_PCI_DEVICE ,
. instance_size = sizeof ( PIIX4PMState ) ,
. class_init = piix4_pm_class_init ,
. interfaces = ( InterfaceInfo [ ] ) {
{ TYPE_HOTPLUG_HANDLER } ,
{ }
}
} ;
static void piix4_pm_register_types ( void )