]> xenbits.xensource.com Git - qemu-xen-4.5-testing.git/commitdiff
Merge branch 'pt.multifn'
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 25 Jun 2009 17:40:33 +0000 (18:40 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 25 Jun 2009 17:40:33 +0000 (18:40 +0100)
Conflicts:
hw/piix4acpi.c

1  2 
hw/piix4acpi.c

diff --cc hw/piix4acpi.c
index dc52b42f642afb73cc689d5001bcb65cd2127ff6,996e36a61218ef946ae4b13c9091e28c223d5414..9c5fdeeafb85d1371deb859f11485e435cadda12
  #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)
@@@ -247,10 -275,10 +279,11 @@@ static uint32_t acpi_php_readb(void *op
          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)
@@@ -463,14 -513,29 +519,29 @@@ static void acpi_sci_intr(GPEState *s
      }
  }
  
- 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;
      }
  
@@@ -486,14 -551,15 +557,16 @@@ void acpi_php_add(int devfn
  {
      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);
@@@ -580,8 -661,8 +668,9 @@@ i2c_bus *piix4_pm_init(PCIBus *bus, in
  }
  
  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);
  }