#include <xen/hvm/ioreq.h>
#include <xen/hvm/params.h>
+#define PIIX4ACPI_LOG_ERROR 0
+#define PIIX4ACPI_LOG_INFO 1
+#define PIIX4ACPI_LOG_DEBUG 2
+#define PIIX4ACPI_LOGLEVEL PIIX4ACPI_LOG_INFO
+#define PIIX4ACPI_LOG(level, fmt, ...) do { if (level <= PIIX4ACPI_LOGLEVEL) qemu_log(fmt, ## __VA_ARGS__); } while (0)
+
+ #include <pci/header.h>
+
/* PM1a_CNT bits, as defined in the ACPI specification. */
#define SCI_EN (1 << 0)
#define GBL_RLS (1 << 2)
break;
default:
num = addr - ACPI_PHP_IO_ADDR - 2;
- val = hotplug_slots->status[num];
+ val = hotplug_devfn->status[num];
}
- PIIX4ACPI_LOG(PIIX4ACPI_LOG_DEBUG, "ACPI PCI hotplug: read addr=0x%x, val=0x%x.\n",
- fprintf(logfile, "ACPI PCI hotplug: read addr=0x%x, val=0x%02x.\n",
++ PIIX4ACPI_LOG(PIIX4ACPI_LOG_DEBUG,
++ "ACPI PCI hotplug: read addr=0x%x, val=0x%02x.\n",
addr, val);
return val;
static void acpi_php_writeb(void *opaque, uint32_t addr, uint32_t val)
{
- PHPSlots *hotplug_slots = opaque;
- int slot;
+ PHPDevFn *hotplug_devfn = opaque;
+ int devfn, num, func, i;
- PIIX4ACPI_LOG(PIIX4ACPI_LOG_DEBUG, "ACPI PCI hotplug: write addr=0x%x, val=0x%x.\n",
- fprintf(logfile, "ACPI PCI hotplug: write addr=0x%x, val=0x%02x.\n",
++ PIIX4ACPI_LOG(PIIX4ACPI_LOG_DEBUG,
++ "ACPI PCI hotplug: write addr=0x%x, val=0x%02x.\n",
addr, val);
switch (addr)
}
}
- void acpi_php_del(int slot)
+ void acpi_php_del(int devfn)
{
GPEState *s = &gpe_state;
+ int slot, func;
- if ( test_pci_slot(slot) < 0 ) {
- PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR, "hot remove: pci slot %d "
- "is not used by a hotplug device.\n", slot);
+ slot = PCI_SLOT(devfn);
+ func = PCI_FUNC(devfn);
- fprintf(logfile, "hot remove: pci slot 0x%02x, function 0x%x "
+ if ( test_pci_devfn(devfn) < 0 ) {
-
++ PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR,
++ "hot remove: pci slot 0x%02x, function 0x%x "
+ "is not used by a hotplug device.\n", slot, func);
+ return;
+ }
+
+ /* ACPI PHP can only work on slots
+ * So only remove zero-functions -
+ * which will remove all other fucntions of the same device in the
+ * guest.
+ */
+ if ( func ) {
+ fprintf(logfile, "hot remove: Attempt to remove non-zero function "
+ "slot=0x%02x func=0x%0x.\n", slot, func);
return;
}
{
GPEState *s = &gpe_state;
char ret_str[30];
+ int slot, func;
- if ( slot < 0 ) {
- PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR, "hot add pci slot %d exceed.\n", slot);
+ if ( devfn < 0 ) {
- fprintf(logfile, "hot add pci devfn %d exceed.\n", devfn);
++ PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR,
++ "hot add pci devfn %d exceed.\n", devfn);
- if ( slot == -1 )
- sprintf(ret_str, "no free hotplug slots");
- else if ( slot == -2 )
- sprintf(ret_str, "wrong bdf or vslot");
+ if ( devfn == -1 )
+ sprintf(ret_str, "no free hotplug devfn");
+ else if ( devfn == -2 )
+ sprintf(ret_str, "wrong bdf or vdevfn");
if ( strlen(ret_str) > 0 )
xenstore_record_dm("parameter", ret_str);
}
void qemu_system_hot_add_init() { }
- void qemu_system_device_hot_add(int bus, int slot, int state) {
- PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR, "qemu-upstream PCI hotplug not supported in qemu-dm\n");
+ void qemu_system_device_hot_add(int bus, int devfn, int state) {
- fputs("qemu-upstream PCI hotplug not supported in qemu-dm\n",stderr);
++ PIIX4ACPI_LOG(PIIX4ACPI_LOG_ERROR,
++ "qemu-upstream PCI hotplug not supported in qemu-dm\n");
exit(-1);
}