Skip to contentSkip to conversation

xm, xend, hvmloader: multi-function VT-d device pass-through

RFC In review Simon Horman 1 participant 11 messages Jun 17, 2009

lore
Share & tools
lore
#0 lore raw

cover xm, xend, hvmloader: multi-function VT-d device pass-through

This series of patches cleans up various aspects of the PCI pass-through code. This is working towards multi-function pass-through devices in guests. But most of these changes are useful in their own right, so I am posting this batch without the rest of the multi-function changes.

This series of patches extends VT-d pass-through to allow multi-function devices to appear in guests as multi-function devices.

The interface for this is a new extension to BDF notation that can be used in configuration files for boot-time (static) assignment and on the xm command like with pci-attach and pci-detach for hot-plug and hot-unplug respectively.

If the existing BDF notation, which only specifies a single function, is used then the existing single-function pass-through scheme is used. That is, when a function is passed-through its will appear as function zero of a vslot in the guest.

For example, the following physical to virtual mapping may occur. The critical part is the treatment of the function numbers which will always be consistent. That is, the virtual function number is always zero.

Physical | Virtual
-----------+--------

  00:1d.0    | 00:06.0
  00:1d.1    | 00:07.0
  00:1d.7    | 00:08.0

If the new extensions to BDF notation are used, thereby specifying multiple functions of a device, then a multi-function scheme is used. Two such schemes are proposed:

1. Identity mapping, whereby physical function numbers are identity mapped into virtual functions.

For example the following physical to virtual mapping may occur. Again, the treatment of the function numbers is critical and will always be consistent. That is it is the virtual function number is always the same as the physical function number. It is also important that both the physical and virtual device numbers are the same.

     Physical   | Virtual
     -----------+--------
     00:1d.0    | 00:07.0
     00:1d.1    | 00:07.1
     00:1d.7    | 00:07.7

2. Least mapping, whereby the lowest available virtual function is used. The example above would become:

     Physical   | Virtual
     -----------+--------
     00:1d.0    | 00:07.0
     00:1d.1    | 00:07.1
     00:1d.7    | 00:07.2

Unlike identity mapping, this scheme is dependant on the order that functions are supplied. So if the order in the above example was reversed, then the result would be:

     Physical   | Virtual
     -----------+--------
     00:1d.7    | 00:07.0
     00:1d.1    | 00:07.1
     00:1d.0    | 00:07.1

As physical function 0 need not be present, this scheme allows multiple virtual multi-function devices to be formed from functions of the same physical multi-function device.

It is not known if this scheme violates hardware restrictions.

This scheme is activated by applying the last patch in this series. There is no mechanism to switch schemes at this time.

Least mapping was proposed by Masaki Kanno.

The above multi-function mappings will occur when the following extension to the BDF notation is used. In the case of unplug the VSLOT and OPT must be omitted.

Existing: SEQ:BUS:DEV.FUNC[@VSLOT][,OPT...]
New: SEQ:BUS:DEV.FUNC0-FUNCN[@VSLOT][,OPT...]

            SEQ:BUS:DEV.FUNC0,FUNCM,FUNCN[@VSLOT][,OPT...]
            SEQ:BUS:DEV.*[@VSLOT][,OPT...]

This notation is expanded into more conventional parameters which are passed to qemu-xen.

E.g:

       0000:00:1d.0-2 becomes:
         0000:00:1d.0
         0000:00:1d.1
         0000:00:1d.2

       0000:00:1d.0,3,5,7 becomes:
         0000:00:0d.0
         0000:00:0d.3
         0000:00:0d.5
         0000:00:0d.7

       For a device that has functions 0, 1, 2, 3, 5 and 7,
       0000:00:1d.* becomes:
         0000:00:1d.00
         0000:00:1d.01
         0000:00:1d.02
         0000:00:1d.03
         0000:00:1d.05
         0000:00:1d.07

Limitation:

* This scheme does not allow for the physical and virtual function to be specified..

Bugs:

* Suspended domains with PCI pass-through devices may not be restored correctly because the vslot field is no longer honoured after these patches. This needs further investigation.

I will post a document that includes a fuller description of this code as a follow-up.

This patch series applies against:

http://xenbits.xensource.com/unstable/xen-unstable.hg

changeset: 19783:61ec78692b13
user: Keir Fraser <[email protected]>
date: Wed Jun 17 07:39:27 2009 +0100
summary: xend: pass-through: Clean up hvm_destroyPCIDevice()

Please apply the patches in order, many of the patches in this series depend on previous patches in the series to function correctly.

There are both xen and xen-qemu patch series relating to this change. Where they depend on each other this is noted in the patch's comment. Only applying one series will break pass-through.

I will be taking a holiday from the 24th June - 8th July.
I will not be able to make any fixes or answer email during that time.

#1 lore raw

RFC 1/9 xend: pass-through: use devfn instead of slots as the unit for pass-through

This is part of support for multi-function PCI devices in guests

Instead of suppling a slot number to qemu-xen, supply a devfn.

This and subsequent other changes will allow xend to ask for more than one function to be inserted into a single slot - by specifying which function of the slot should be used.

This is a minimal patch for this change. A subsequent patch that has a lot of noise to rename slot to devfn is intended to follow.

This patch breaks compatibility with qemu-xen and corresponding patches to qemu-xen are required.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

Co-dependent with xen-qemu patch
"qemu-xen: pass-through: use devfn instead of slots as the unit for
pass-through"

Changes

Wed, 20 May 2009 18:14:38 +1000
* Update for cset 19626:145e49b8574c

Thu, 28 May 2009 22:17:40 +1000
* Update for cset 19662:fe68405201d2

tools/python/xen/xend/XendConstants.py +4 -2
Index: xen-unstable.hg/tools/python/xen/xend/XendConstants.py
===================================================================
@@ -138,9 +138,11 @@ VTPM_DELETE_SCRIPT = auxbin.scripts_dir(
 
 XS_VMROOT = "/vm/"
 
+NR_PCI_FUNC = 8
 NR_PCI_DEV = 32
-AUTO_PHP_SLOT = NR_PCI_DEV
-AUTO_PHP_SLOT_STR = "%02x" % NR_PCI_DEV
+NR_PCI_DEVFN = NR_PCI_FUNC * NR_PCI_DEV
+AUTO_PHP_DEVFN = NR_PCI_DEVFN
+AUTO_PHP_DEVFN_STR = "%02x" % NR_PCI_DEVFN
 
 #
 # tmem
tools/python/xen/xend/XendDomainInfo.py +1 -1
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
@@ -644,7 +644,7 @@ class XendDomainInfo:
             pci_devs = pci_conf['devs']
             for x in pci_devs:
                 if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
-                   int(x['vslot'], 16) != AUTO_PHP_SLOT):
+                   int(x['vslot'], 16) != AUTO_PHP_DEVFN):
                     raise VmError("vslot %s already have a device." % (new_dev['vslot']))
 
                 if (pci_dict_cmp(x, new_dev)):
tools/python/xen/xend/server/pciif.py +1 -1
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
@@ -75,7 +75,7 @@ class PciController(DevController):
             slot = parse_hex(pci_config.get('slot', 0))
             func = parse_hex(pci_config.get('func', 0))            
             vslot = parse_hex(pci_config.get('vslot',
-                                             '0x' + AUTO_PHP_SLOT_STR))
+                                             '0x' + AUTO_PHP_DEVFN_STR))
 
             if pci_config.has_key('opts'):
                 opts = serialise_pci_opts(pci_config['opts'])
tools/python/xen/util/pci.py +11 -6
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
@@ -16,7 +16,7 @@ import threading
 from xen.util import utils
 from xen.xend import uuid
 from xen.xend import sxp
-from xen.xend.XendConstants import AUTO_PHP_SLOT
+from xen.xend.XendConstants import AUTO_PHP_DEVFN
 from xen.xend.XendSXPDev import dev_dict_to_sxp
 
 PROC_PCI_PATH = '/proc/bus/pci/devices'
@@ -115,6 +115,10 @@ PAGE_MASK=~(PAGE_SIZE - 1)
 # Definitions from Linux: include/linux/pci.h
 def PCI_DEVFN(slot, func):
     return ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+def PCI_SLOT(devfn):
+    return (devfn >> 3) & 0x1f
+def PCI_FUNC(devfn):
+    return devfn & 0x7
 
 def PCI_BDF(domain, bus, slot, func):
     return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) |
@@ -246,9 +250,9 @@ def parse_pci_name_extended(pci_dev_str)
     out['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
     out['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
     if pci_dev_info['vslot'] == '':
-        vslot = AUTO_PHP_SLOT
+        vslot = AUTO_PHP_DEVFN
     else:
-        vslot = int(pci_dev_info['vslot'], 16)
+        vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), 0)
     out['vslot'] = "0x%02x" % vslot
     if pci_dev_info['opts'] != '':
         out['opts'] = split_pci_opts(pci_dev_info['opts'])
@@ -259,10 +263,11 @@ def parse_pci_name_extended(pci_dev_str)
 def parse_pci_name(pci_name_string):
     pci = parse_pci_name_extended(pci_name_string)
 
-    if int(pci['vslot'], 16) != AUTO_PHP_SLOT:
+    if int(pci['vslot'], 16) != AUTO_PHP_DEVFN:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
-                                   "vslot provided where prohibited: %s") %
-                                  (pci_name_string, pci['vslot']))
+                                   "vslot provided where prohibited: 0x%02x") %
+                                  (pci_name_string,
+                                   PCI_SLOT(int(pci['vslot'], 16))))
     if 'opts' in pci:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
                                    "options provided where prohibited: %s") %
tools/python/xen/xm/main.py +6 -5
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2213,17 +2213,19 @@ def xm_pci_list(args):
 
     has_vslot = False
     for x in devs:
-        if x['vslot'] == AUTO_PHP_SLOT:
+        if x['vslot'] == AUTO_PHP_DEVFN:
             x['show_vslot'] = '-'
+            x['show_vfunc'] = '-'
         else:
-            x['show_vslot'] = "0x%02x" % x['vslot']
+            x['show_vslot'] = "0x%02x" % PCI_SLOT(x['vslot'])
+            x['show_vfunc'] = "0x%x" % PCI_FUNC(x['vslot'])
             has_vslot = True
 
     hdr_str = 'domain bus  slot func'
     fmt_str = '0x%(domain)04x 0x%(bus)02x 0x%(slot)02x 0x%(func)x'
     if has_vslot:
-        hdr_str = 'VSlt ' + hdr_str
-        fmt_str = '%(show_vslot)-4s ' + fmt_str
+        hdr_str = 'VSlt VFn ' + hdr_str
+        fmt_str = '%(show_vslot)-4s %(show_vfunc)-3s ' + fmt_str
 
     print hdr_str
     for x in devs:
@@ -2519,7 +2521,6 @@ def xm_pci_attach(args):
                      config_pci_opts)
 
     if serverType == SERVER_XEN_API:
-
         pci_dev = sxp.children(pci, 'dev')[0]
         domain = int(sxp.child_value(pci_dev, 'domain'), 16)
         bus = int(sxp.child_value(pci_dev, 'bus'), 16)
tools/python/xen/xend/XendConfig.py +2 -2
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI
 from xen.xend.XendError import VmError
 from xen.xend.XendDevices import XendDevices
 from xen.xend.PrettyPrint import prettyprintstring
-from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR
+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_DEVFN_STR
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.server.BlktapController import blktap_disk_types
 from xen.xend.server.netif import randomMAC
@@ -1237,7 +1237,7 @@ class XendConfig(dict):
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
                 'hotplug_slot': pci_dev.get('vslot',
-                                            '0x' + AUTO_PHP_SLOT_STR)
+                                            '0x' + AUTO_PHP_DEVFN_STR)
             }
 
             dpci_opts = pci_dev.get('opts')
#2 lore raw

RFC 2/9 hvmloader: pass-through: multi-function PCI hot-plug

In reply to Simon Horman

This registers information to allow guests to recognise non-zero functions when hot-plugged.

This patch breaks compatibility with qemu-xend and a companion patch is provided.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

This patch is co-dependent on
"qemu-xen: pass-through: multi-function PCI in ACPI"

tools/firmware/hvmloader/acpi/dsdt.asl +8670 -253
Index: xen-unstable.hg/tools/firmware/hvmloader/acpi/dsdt.asl
===================================================================
@@ -123,7 +123,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
            Name (_BBN, 0x00)
 
            /*
-            * Reserve the IO port ranges [0x10c0, 0x10e1] and [0xb044, 0xb047].
+            * Reserve the IO port ranges [0x10c0, 0x1101] and [0xb044, 0xb047].
             * Or else, for a hotplugged-in device, the port IO BAR assigned
             * by guest OS may conflict with the ranges here.
             */
@@ -131,7 +131,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
            {
                Name(_HID, EISAID("PNP0C02"))
                Name(_CRS, ResourceTemplate() {
-                   IO (Decode16, 0x10c0, 0x10c0, 0x00, 0x22)
+                   IO (Decode16, 0x10c0, 0x10c0, 0x00, 0x82)
                    IO (Decode16, 0xb044, 0xb044, 0x00, 0x04)
                })
            }
@@ -983,7 +983,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
              */
             Device(S00)
             {
-                Name (_ADR, 0x00000000) /* Dev 0, Func 0 */
+                Name (_ADR, 0x00000000) /* Dev 0x00, Func 0x0 */
                 Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
@@ -1002,21 +1002,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x00, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH00) /* eject php slot 0x00 */
+                    Store (0x01, \_GPE.PH00) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x00, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH00) /* IN status as the _STA */
+                    And (\_GPE.PH00, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S01)
             {
-                Name (_ADR, 0x00010000) /* Dev 1, Func 0 */
-                Name (_SUN, 0x00000001)
+                Name (_ADR, 0x00000001) /* Dev 0x00, Func 0x1 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1034,21 +1035,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x01, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH01) /* eject php slot 0x01 */
+                    Store (0x10, \_GPE.PH00) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x01, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH01) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH00, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S02)
             {
-                Name (_ADR, 0x00020000) /* Dev 2, Func 0 */
-                Name (_SUN, 0x00000002)
+                Name (_ADR, 0x00000002) /* Dev 0x00, Func 0x2 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1066,21 +1068,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x02, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH02) /* eject php slot 0x02 */
+                    Store (0x01, \_GPE.PH02) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x02, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH02) /* IN status as the _STA */
+                    And (\_GPE.PH02, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S03)
             {
-                Name (_ADR, 0x00030000) /* Dev 3, Func 0 */
-                Name (_SUN, 0x00000003)
+                Name (_ADR, 0x00000003) /* Dev 0x00, Func 0x3 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1098,21 +1101,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x03, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH03) /* eject php slot 0x03 */
+                    Store (0x10, \_GPE.PH02) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x03, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH03) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH02, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S04)
             {
-                Name (_ADR, 0x00040000) /* Dev 4, Func 0 */
-                Name (_SUN, 0x00000004)
+                Name (_ADR, 0x00000004) /* Dev 0x00, Func 0x4 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1130,21 +1134,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x04, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH04) /* eject php slot 0x04 */
+                    Store (0x01, \_GPE.PH04) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x04, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH04) /* IN status as the _STA */
+                    And (\_GPE.PH04, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S05)
             {
-                Name (_ADR, 0x00050000) /* Dev 5, Func 0 */
-                Name (_SUN, 0x00000005)
+                Name (_ADR, 0x00000005) /* Dev 0x00, Func 0x5 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1162,21 +1167,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x05, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH05) /* eject php slot 0x05 */
+                    Store (0x10, \_GPE.PH04) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x05, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH05) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH04, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S06)
             {
-                Name (_ADR, 0x00060000) /* Dev 6, Func 0 */
-                Name (_SUN, 0x00000006)
+                Name (_ADR, 0x00000006) /* Dev 0x00, Func 0x6 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1194,21 +1200,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x06, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH06) /* eject php slot 0x06 */
+                    Store (0x01, \_GPE.PH06) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x06, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH06) /* IN status as the _STA */
+                    And (\_GPE.PH06, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S07)
             {
-                Name (_ADR, 0x00070000) /* Dev 7, Func 0 */
-                Name (_SUN, 0x00000007)
+                Name (_ADR, 0x00000007) /* Dev 0x00, Func 0x7 */
+                Name (_SUN, 0x00000000)
 
                 Method (_PS0, 0)
                 {
@@ -1226,21 +1233,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x07, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH07) /* eject php slot 0x07 */
+                    Store (0x10, \_GPE.PH06) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x07, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH07) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH06, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S08)
             {
-                Name (_ADR, 0x00080000) /* Dev 8, Func 0 */
-                Name (_SUN, 0x00000008)
+                Name (_ADR, 0x00010000) /* Dev 0x01, Func 0x0 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1258,21 +1266,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x08, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH08) /* eject php slot 0x08 */
+                    Store (0x01, \_GPE.PH08) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x08, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH08) /* IN status as the _STA */
+                    And (\_GPE.PH08, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S09)
             {
-                Name (_ADR, 0x00090000) /* Dev 9, Func 0 */
-                Name (_SUN, 0x00000009)
+                Name (_ADR, 0x00010001) /* Dev 0x01, Func 0x1 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1290,21 +1299,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x09, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH09) /* eject php slot 0x09 */
+                    Store (0x10, \_GPE.PH08) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x09, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH09) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH08, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0A)
             {
-                Name (_ADR, 0x000a0000) /* Dev 10, Func 0 */
-                Name (_SUN, 0x0000000a)
+                Name (_ADR, 0x00010002) /* Dev 0x01, Func 0x2 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1322,21 +1332,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0a, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0A) /* eject php slot 0x0a */
+                    Store (0x01, \_GPE.PH0A) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0a, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0A) /* IN status as the _STA */
+                    And (\_GPE.PH0A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0B)
             {
-                Name (_ADR, 0x000b0000) /* Dev 11, Func 0 */
-                Name (_SUN, 0x0000000b)
+                Name (_ADR, 0x00010003) /* Dev 0x01, Func 0x3 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1354,21 +1365,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0b, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0B) /* eject php slot 0x0b */
+                    Store (0x10, \_GPE.PH0A) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0b, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0B) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH0A, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0C)
             {
-                Name (_ADR, 0x000c0000) /* Dev 12, Func 0 */
-                Name (_SUN, 0x0000000c)
+                Name (_ADR, 0x00010004) /* Dev 0x01, Func 0x4 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1386,21 +1398,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0c, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0C) /* eject php slot 0x0c */
+                    Store (0x01, \_GPE.PH0C) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0c, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0C) /* IN status as the _STA */
+                    And (\_GPE.PH0C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0D)
             {
-                Name (_ADR, 0x000d0000) /* Dev 13, Func 0 */
-                Name (_SUN, 0x0000000d)
+                Name (_ADR, 0x00010005) /* Dev 0x01, Func 0x5 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1418,21 +1431,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0d, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0D) /* eject php slot 0x0d */
+                    Store (0x10, \_GPE.PH0C) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0d, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0D) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH0C, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0E)
             {
-                Name (_ADR, 0x000e0000) /* Dev 14, Func 0 */
-                Name (_SUN, 0x0000000e)
+                Name (_ADR, 0x00010006) /* Dev 0x01, Func 0x6 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1450,21 +1464,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0e, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0E) /* eject php slot 0x0e */
+                    Store (0x01, \_GPE.PH0E) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0e, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0E) /* IN status as the _STA */
+                    And (\_GPE.PH0E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S0F)
             {
-                Name (_ADR, 0x000f0000) /* Dev 15, Func 0 */
-                Name (_SUN, 0x0000000f)
+                Name (_ADR, 0x00010007) /* Dev 0x01, Func 0x7 */
+                Name (_SUN, 0x00000001)
 
                 Method (_PS0, 0)
                 {
@@ -1482,21 +1497,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x0f, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH0F) /* eject php slot 0x0f */
+                    Store (0x10, \_GPE.PH0E) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x0f, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH0F) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH0E, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S10)
             {
-                Name (_ADR, 0x00100000) /* Dev 16, Func 0 */
-                Name (_SUN, 0x00000010)
+                Name (_ADR, 0x00020000) /* Dev 0x02, Func 0x0 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1514,21 +1530,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x10, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH10) /* eject php slot 0x10 */
+                    Store (0x01, \_GPE.PH10) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x10, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH10) /* IN status as the _STA */
+                    And (\_GPE.PH10, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S11)
             {
-                Name (_ADR, 0x00110000) /* Dev 17, Func 0 */
-                Name (_SUN, 0x00000011)
+                Name (_ADR, 0x00020001) /* Dev 0x02, Func 0x1 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1546,21 +1563,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x11, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH11) /* eject php slot 0x11 */
+                    Store (0x10, \_GPE.PH10) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x11, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH11) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH10, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S12)
             {
-                Name (_ADR, 0x00120000) /* Dev 18, Func 0 */
-                Name (_SUN, 0x00000012)
+                Name (_ADR, 0x00020002) /* Dev 0x02, Func 0x2 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1578,21 +1596,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x12, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH12) /* eject php slot 0x12 */
+                    Store (0x01, \_GPE.PH12) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x12, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH12) /* IN status as the _STA */
+                    And (\_GPE.PH12, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S13)
             {
-                Name (_ADR, 0x00130000) /* Dev 19, Func 0 */
-                Name (_SUN, 0x00000013)
+                Name (_ADR, 0x00020003) /* Dev 0x02, Func 0x3 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1610,21 +1629,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x13, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH13) /* eject php slot 0x13 */
+                    Store (0x10, \_GPE.PH12) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x13, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH13) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH12, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S14)
             {
-                Name (_ADR, 0x00140000) /* Dev 20, Func 0 */
-                Name (_SUN, 0x00000014)
+                Name (_ADR, 0x00020004) /* Dev 0x02, Func 0x4 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1642,21 +1662,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x14, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH14) /* eject php slot 0x14 */
+                    Store (0x01, \_GPE.PH14) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x14, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH14) /* IN status as the _STA */
+                    And (\_GPE.PH14, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S15)
             {
-                Name (_ADR, 0x00150000) /* Dev 21, Func 0 */
-                Name (_SUN, 0x00000015)
+                Name (_ADR, 0x00020005) /* Dev 0x02, Func 0x5 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1674,21 +1695,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x15, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH15) /* eject php slot 0x15 */
+                    Store (0x10, \_GPE.PH14) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x15, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH15) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH14, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S16)
             {
-                Name (_ADR, 0x00160000) /* Dev 22, Func 0 */
-                Name (_SUN, 0x00000016)
+                Name (_ADR, 0x00020006) /* Dev 0x02, Func 0x6 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1706,21 +1728,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x16, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH16) /* eject php slot 0x16 */
+                    Store (0x01, \_GPE.PH16) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x16, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH16) /* IN status as the _STA */
+                    And (\_GPE.PH16, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S17)
             {
-                Name (_ADR, 0x00170000) /* Dev 23, Func 0 */
-                Name (_SUN, 0x00000017)
+                Name (_ADR, 0x00020007) /* Dev 0x02, Func 0x7 */
+                Name (_SUN, 0x00000002)
 
                 Method (_PS0, 0)
                 {
@@ -1738,21 +1761,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x17, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH17) /* eject php slot 0x17 */
+                    Store (0x10, \_GPE.PH16) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x17, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH17) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH16, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S18)
             {
-                Name (_ADR, 0x00180000) /* Dev 24, Func 0 */
-                Name (_SUN, 0x00000018)
+                Name (_ADR, 0x00030000) /* Dev 0x03, Func 0x0 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1770,21 +1794,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x18, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH18) /* eject php slot 0x18 */
+                    Store (0x01, \_GPE.PH18) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x18, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH18) /* IN status as the _STA */
+                    And (\_GPE.PH18, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S19)
             {
-                Name (_ADR, 0x00190000) /* Dev 25, Func 0 */
-                Name (_SUN, 0x00000019)
+                Name (_ADR, 0x00030001) /* Dev 0x03, Func 0x1 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1802,21 +1827,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x19, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH19) /* eject php slot 0x19 */
+                    Store (0x10, \_GPE.PH18) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x19, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH19) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH18, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1A)
             {
-                Name (_ADR, 0x001a0000) /* Dev 26, Func 0 */
-                Name (_SUN, 0x0000001a)
+                Name (_ADR, 0x00030002) /* Dev 0x03, Func 0x2 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1834,21 +1860,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1a, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1A) /* eject php slot 0x1a */
+                    Store (0x01, \_GPE.PH1A) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1a, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1A) /* IN status as the _STA */
+                    And (\_GPE.PH1A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1B)
             {
-                Name (_ADR, 0x001b0000) /* Dev 27, Func 0 */
-                Name (_SUN, 0x0000001b)
+                Name (_ADR, 0x00030003) /* Dev 0x03, Func 0x3 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1866,21 +1893,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1b, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1B) /* eject php slot 0x1b */
+                    Store (0x10, \_GPE.PH1A) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1b, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1B) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH1A, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1C)
             {
-                Name (_ADR, 0x001c0000) /* Dev 28, Func 0 */
-                Name (_SUN, 0x0000001c)
+                Name (_ADR, 0x00030004) /* Dev 0x03, Func 0x4 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1898,21 +1926,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1c, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1C) /* eject php slot 0x1c */
+                    Store (0x01, \_GPE.PH1C) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1c, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1C) /* IN status as the _STA */
+                    And (\_GPE.PH1C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1D)
             {
-                Name (_ADR, 0x001d0000) /* Dev 29, Func 0 */
-                Name (_SUN, 0x0000001d)
+                Name (_ADR, 0x00030005) /* Dev 0x03, Func 0x5 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1930,21 +1959,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1d, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1D) /* eject php slot 0x1d */
+                    Store (0x10, \_GPE.PH1C) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1d, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1D) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH1C, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1E)
             {
-                Name (_ADR, 0x001e0000) /* Dev 30, Func 0 */
-                Name (_SUN, 0x0000001e)
+                Name (_ADR, 0x00030006) /* Dev 0x03, Func 0x6 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1962,21 +1992,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1e, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1E) /* eject php slot 0x1e */
+                    Store (0x01, \_GPE.PH1E) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1e, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1E) /* IN status as the _STA */
+                    And (\_GPE.PH1E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
 
             Device(S1F)
             {
-                Name (_ADR, 0x001f0000) /* Dev 31, Func 0 */
-                Name (_SUN, 0x0000001f)
+                Name (_ADR, 0x00030007) /* Dev 0x03, Func 0x7 */
+                Name (_SUN, 0x00000003)
 
                 Method (_PS0, 0)
                 {
@@ -1994,206 +2025,8592 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                 {
                     Store (0x1f, \_GPE.DPT1)
                     Store (0x88, \_GPE.DPT2)
-                    Store (0x1, \_GPE.PH1F) /* eject php slot 0x1f */
+                    Store (0x10, \_GPE.PH1E) /* eject */
                 }
 
                 Method (_STA, 0)
                 {
                     Store (0x1f, \_GPE.DPT1)
                     Store (0x89, \_GPE.DPT2)
-                    Return (\_GPE.PH1F) /* IN status as the _STA */
+                    ShiftRight (0x4, \_GPE.PH1E, Local1)
+                    Return (Local1) /* IN status as the _STA */
                 }
             }
-        }
-    }
 
-    Scope (\_GPE)
-    {
-        OperationRegion (PHP, SystemIO, 0x10c0, 0x22)
-        Field (PHP, ByteAcc, NoLock, Preserve)
-        {
-            PSTA,  8, /* hotplug controller event reg */
-            PSTB,  8, /* hotplug controller slot  reg */
-            PH00,  8, /* hotplug slot 0x00 control reg */
-            PH01,  8, /* hotplug slot 0x01 control reg */
-            PH02,  8, /* hotplug slot 0x02 control reg */
-            PH03,  8, /* hotplug slot 0x03 control reg */
-            PH04,  8, /* hotplug slot 0x04 control reg */
-            PH05,  8, /* hotplug slot 0x05 control reg */
-            PH06,  8, /* hotplug slot 0x06 control reg */
-            PH07,  8, /* hotplug slot 0x07 control reg */
-            PH08,  8, /* hotplug slot 0x08 control reg */
-            PH09,  8, /* hotplug slot 0x09 control reg */
-            PH0A,  8, /* hotplug slot 0x0a control reg */
-            PH0B,  8, /* hotplug slot 0x0b control reg */
-            PH0C,  8, /* hotplug slot 0x0c control reg */
-            PH0D,  8, /* hotplug slot 0x0d control reg */
-            PH0E,  8, /* hotplug slot 0x0e control reg */
-            PH0F,  8, /* hotplug slot 0x0f control reg */
-            PH10,  8, /* hotplug slot 0x10 control reg */
-            PH11,  8, /* hotplug slot 0x11 control reg */
-            PH12,  8, /* hotplug slot 0x12 control reg */
-            PH13,  8, /* hotplug slot 0x13 control reg */
-            PH14,  8, /* hotplug slot 0x14 control reg */
-            PH15,  8, /* hotplug slot 0x15 control reg */
-            PH16,  8, /* hotplug slot 0x16 control reg */
-            PH17,  8, /* hotplug slot 0x17 control reg */
-            PH18,  8, /* hotplug slot 0x18 control reg */
-            PH19,  8, /* hotplug slot 0x19 control reg */
-            PH1A,  8, /* hotplug slot 0x1a control reg */
-            PH1B,  8, /* hotplug slot 0x1b control reg */
-            PH1C,  8, /* hotplug slot 0x1c control reg */
-            PH1D,  8, /* hotplug slot 0x1d control reg */
-            PH1E,  8, /* hotplug slot 0x1e control reg */
-            PH1F,  8  /* hotplug slot 0x1f control reg */
-       }
-        OperationRegion (DG1, SystemIO, 0xb044, 0x04)
-        Field (DG1, ByteAcc, NoLock, Preserve)
-        {
-            DPT1,   8,
-            DPT2,   8
-        }
-        Method (_L03, 0, Serialized)
-        {
-            /* detect slot and event(remove/add) */
-            Name (SLT, 0x0)
-            Name (EVT, 0x0)
-            Store (PSTA, Local1)
-            And (Local1, 0xf, EVT)
-            Store (PSTB, Local1)           /* XXX: Store (PSTB, SLT) ? */
-            And (Local1, 0xff, SLT)
+            Device(S20)
+            {
+                Name (_ADR, 0x00040000) /* Dev 0x04, Func 0x0 */
+                Name (_SUN, 0x00000004)
 
-            /* debug */
-            Store (SLT, DPT1)
-            Store (EVT, DPT2)
+                Method (_PS0, 0)
+                {
+                    Store (0x20, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
 
-            If ( LEqual(SLT, 0x00) )
-            {
-                Notify (\_SB.PCI0.S00, EVT)
+                Method (_PS3, 0)
+                {
+                    Store (0x20, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x20, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH20) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x20, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH20, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x01) )
+
+            Device(S21)
             {
-                Notify (\_SB.PCI0.S01, EVT)
+                Name (_ADR, 0x00040001) /* Dev 0x04, Func 0x1 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x21, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x21, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x21, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH20) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x21, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH20, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x02) )
+
+            Device(S22)
             {
-                Notify (\_SB.PCI0.S02, EVT)
+                Name (_ADR, 0x00040002) /* Dev 0x04, Func 0x2 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x22, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x22, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x22, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH22) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x22, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH22, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x03) )
+
+            Device(S23)
             {
-                Notify (\_SB.PCI0.S03, EVT)
+                Name (_ADR, 0x00040003) /* Dev 0x04, Func 0x3 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x23, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x23, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x23, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH22) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x23, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH22, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x04) )
+
+            Device(S24)
             {
-                Notify (\_SB.PCI0.S04, EVT)
+                Name (_ADR, 0x00040004) /* Dev 0x04, Func 0x4 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x24, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x24, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x24, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH24) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x24, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH24, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x05) )
+
+            Device(S25)
             {
-                Notify (\_SB.PCI0.S05, EVT)
+                Name (_ADR, 0x00040005) /* Dev 0x04, Func 0x5 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x25, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x25, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x25, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH24) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x25, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH24, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x06) )
+
+            Device(S26)
             {
-                Notify (\_SB.PCI0.S06, EVT)
+                Name (_ADR, 0x00040006) /* Dev 0x04, Func 0x6 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x26, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x26, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x26, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH26) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x26, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH26, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
             }
-            ElseIf ( LEqual(SLT, 0x07) )
+
+            Device(S27)
+            {
+                Name (_ADR, 0x00040007) /* Dev 0x04, Func 0x7 */
+                Name (_SUN, 0x00000004)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x27, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x27, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x27, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH26) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x27, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH26, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S28)
+            {
+                Name (_ADR, 0x00050000) /* Dev 0x05, Func 0x0 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x28, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x28, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x28, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH28) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x28, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH28, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S29)
+            {
+                Name (_ADR, 0x00050001) /* Dev 0x05, Func 0x1 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x29, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x29, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x29, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH28) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x29, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH28, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2A)
+            {
+                Name (_ADR, 0x00050002) /* Dev 0x05, Func 0x2 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2a, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2a, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2a, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH2A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2a, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH2A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2B)
+            {
+                Name (_ADR, 0x00050003) /* Dev 0x05, Func 0x3 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2b, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2b, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2b, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH2A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2b, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH2A, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2C)
+            {
+                Name (_ADR, 0x00050004) /* Dev 0x05, Func 0x4 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2c, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2c, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2c, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH2C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2c, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH2C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2D)
+            {
+                Name (_ADR, 0x00050005) /* Dev 0x05, Func 0x5 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2d, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2d, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2d, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH2C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2d, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH2C, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2E)
+            {
+                Name (_ADR, 0x00050006) /* Dev 0x05, Func 0x6 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2e, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2e, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2e, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH2E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2e, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH2E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S2F)
+            {
+                Name (_ADR, 0x00050007) /* Dev 0x05, Func 0x7 */
+                Name (_SUN, 0x00000005)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x2f, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x2f, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x2f, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH2E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x2f, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH2E, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S30)
+            {
+                Name (_ADR, 0x00060000) /* Dev 0x06, Func 0x0 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x30, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x30, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x30, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH30) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x30, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH30, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S31)
+            {
+                Name (_ADR, 0x00060001) /* Dev 0x06, Func 0x1 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x31, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x31, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x31, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH30) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x31, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH30, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S32)
+            {
+                Name (_ADR, 0x00060002) /* Dev 0x06, Func 0x2 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x32, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x32, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x32, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH32) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x32, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH32, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S33)
+            {
+                Name (_ADR, 0x00060003) /* Dev 0x06, Func 0x3 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x33, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x33, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x33, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH32) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x33, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH32, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S34)
+            {
+                Name (_ADR, 0x00060004) /* Dev 0x06, Func 0x4 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x34, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x34, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x34, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH34) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x34, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH34, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S35)
+            {
+                Name (_ADR, 0x00060005) /* Dev 0x06, Func 0x5 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x35, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x35, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x35, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH34) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x35, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH34, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S36)
+            {
+                Name (_ADR, 0x00060006) /* Dev 0x06, Func 0x6 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x36, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x36, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x36, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH36) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x36, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH36, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S37)
+            {
+                Name (_ADR, 0x00060007) /* Dev 0x06, Func 0x7 */
+                Name (_SUN, 0x00000006)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x37, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x37, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x37, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH36) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x37, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH36, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S38)
+            {
+                Name (_ADR, 0x00070000) /* Dev 0x07, Func 0x0 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x38, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x38, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x38, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH38) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x38, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH38, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S39)
+            {
+                Name (_ADR, 0x00070001) /* Dev 0x07, Func 0x1 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x39, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x39, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x39, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH38) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x39, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH38, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3A)
+            {
+                Name (_ADR, 0x00070002) /* Dev 0x07, Func 0x2 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3a, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3a, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3a, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH3A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3a, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH3A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3B)
+            {
+                Name (_ADR, 0x00070003) /* Dev 0x07, Func 0x3 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3b, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3b, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3b, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH3A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3b, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH3A, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3C)
+            {
+                Name (_ADR, 0x00070004) /* Dev 0x07, Func 0x4 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3c, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3c, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3c, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH3C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3c, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH3C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3D)
+            {
+                Name (_ADR, 0x00070005) /* Dev 0x07, Func 0x5 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3d, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3d, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3d, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH3C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3d, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH3C, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3E)
+            {
+                Name (_ADR, 0x00070006) /* Dev 0x07, Func 0x6 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3e, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3e, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3e, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH3E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3e, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH3E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S3F)
+            {
+                Name (_ADR, 0x00070007) /* Dev 0x07, Func 0x7 */
+                Name (_SUN, 0x00000007)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x3f, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x3f, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x3f, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH3E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x3f, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH3E, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S40)
+            {
+                Name (_ADR, 0x00080000) /* Dev 0x08, Func 0x0 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x40, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x40, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x40, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH40) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x40, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH40, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S41)
+            {
+                Name (_ADR, 0x00080001) /* Dev 0x08, Func 0x1 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x41, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x41, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x41, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH40) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x41, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH40, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S42)
+            {
+                Name (_ADR, 0x00080002) /* Dev 0x08, Func 0x2 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x42, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x42, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x42, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH42) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x42, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH42, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S43)
+            {
+                Name (_ADR, 0x00080003) /* Dev 0x08, Func 0x3 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x43, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x43, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x43, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH42) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x43, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH42, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S44)
+            {
+                Name (_ADR, 0x00080004) /* Dev 0x08, Func 0x4 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x44, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x44, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x44, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH44) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x44, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH44, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S45)
+            {
+                Name (_ADR, 0x00080005) /* Dev 0x08, Func 0x5 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x45, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x45, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x45, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH44) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x45, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH44, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S46)
+            {
+                Name (_ADR, 0x00080006) /* Dev 0x08, Func 0x6 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x46, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x46, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x46, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH46) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x46, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH46, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S47)
+            {
+                Name (_ADR, 0x00080007) /* Dev 0x08, Func 0x7 */
+                Name (_SUN, 0x00000008)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x47, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x47, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x47, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH46) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x47, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH46, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S48)
+            {
+                Name (_ADR, 0x00090000) /* Dev 0x09, Func 0x0 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x48, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x48, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x48, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH48) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x48, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH48, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S49)
+            {
+                Name (_ADR, 0x00090001) /* Dev 0x09, Func 0x1 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x49, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x49, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x49, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH48) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x49, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH48, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4A)
+            {
+                Name (_ADR, 0x00090002) /* Dev 0x09, Func 0x2 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4a, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4a, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4a, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH4A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4a, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH4A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4B)
+            {
+                Name (_ADR, 0x00090003) /* Dev 0x09, Func 0x3 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4b, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4b, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4b, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH4A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4b, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH4A, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4C)
+            {
+                Name (_ADR, 0x00090004) /* Dev 0x09, Func 0x4 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4c, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4c, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4c, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH4C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4c, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH4C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4D)
+            {
+                Name (_ADR, 0x00090005) /* Dev 0x09, Func 0x5 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4d, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4d, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4d, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH4C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4d, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH4C, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4E)
+            {
+                Name (_ADR, 0x00090006) /* Dev 0x09, Func 0x6 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4e, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4e, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4e, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH4E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4e, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH4E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S4F)
+            {
+                Name (_ADR, 0x00090007) /* Dev 0x09, Func 0x7 */
+                Name (_SUN, 0x00000009)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x4f, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x4f, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x4f, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH4E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x4f, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH4E, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S50)
+            {
+                Name (_ADR, 0x000a0000) /* Dev 0x0a, Func 0x0 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x50, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x50, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x50, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH50) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x50, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH50, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S51)
+            {
+                Name (_ADR, 0x000a0001) /* Dev 0x0a, Func 0x1 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x51, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x51, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x51, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH50) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x51, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH50, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S52)
+            {
+                Name (_ADR, 0x000a0002) /* Dev 0x0a, Func 0x2 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x52, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x52, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x52, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH52) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x52, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH52, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S53)
+            {
+                Name (_ADR, 0x000a0003) /* Dev 0x0a, Func 0x3 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x53, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x53, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x53, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH52) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x53, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH52, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S54)
+            {
+                Name (_ADR, 0x000a0004) /* Dev 0x0a, Func 0x4 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x54, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x54, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x54, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH54) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x54, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH54, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S55)
+            {
+                Name (_ADR, 0x000a0005) /* Dev 0x0a, Func 0x5 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x55, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x55, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x55, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH54) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x55, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH54, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S56)
+            {
+                Name (_ADR, 0x000a0006) /* Dev 0x0a, Func 0x6 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x56, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x56, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x56, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH56) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x56, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH56, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S57)
+            {
+                Name (_ADR, 0x000a0007) /* Dev 0x0a, Func 0x7 */
+                Name (_SUN, 0x0000000a)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x57, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x57, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x57, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH56) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x57, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH56, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S58)
+            {
+                Name (_ADR, 0x000b0000) /* Dev 0x0b, Func 0x0 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x58, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x58, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x58, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH58) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x58, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH58, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S59)
+            {
+                Name (_ADR, 0x000b0001) /* Dev 0x0b, Func 0x1 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x59, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x59, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x59, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH58) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x59, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH58, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S5A)
+            {
+                Name (_ADR, 0x000b0002) /* Dev 0x0b, Func 0x2 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x5a, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x5a, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x5a, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH5A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x5a, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH5A, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S5B)
+            {
+                Name (_ADR, 0x000b0003) /* Dev 0x0b, Func 0x3 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x5b, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x5b, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x5b, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH5A) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x5b, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH5A, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S5C)
+            {
+                Name (_ADR, 0x000b0004) /* Dev 0x0b, Func 0x4 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x5c, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x5c, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x5c, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH5C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x5c, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH5C, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S5D)
+            {
+                Name (_ADR, 0x000b0005) /* Dev 0x0b, Func 0x5 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x5d, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x5d, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x5d, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x10, \_GPE.PH5C) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x5d, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    ShiftRight (0x4, \_GPE.PH5C, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
+            }
+
+            Device(S5E)
+            {
+                Name (_ADR, 0x000b0006) /* Dev 0x0b, Func 0x6 */
+                Name (_SUN, 0x0000000b)
+
+                Method (_PS0, 0)
+                {
+                    Store (0x5e, \_GPE.DPT1)
+                    Store (0x80, \_GPE.DPT2)
+                }
+
+                Method (_PS3, 0)
+                {
+                    Store (0x5e, \_GPE.DPT1)
+                    Store (0x83, \_GPE.DPT2)
+                }
+
+                Method (_EJ0, 1)
+                {
+                    Store (0x5e, \_GPE.DPT1)
+                    Store (0x88, \_GPE.DPT2)
+                    Store (0x01, \_GPE.PH5E) /* eject */
+                }
+
+                Method (_STA, 0)
+                {
+                    Store (0x5e, \_GPE.DPT1)
+                    Store (0x89, \_GPE.DPT2)
+                    And (\_GPE.PH5E, 0x0f, Local1)
+                    Return (Local1) /* IN status as the _STA */
+                }
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

tools/firmware/hvmloader/acpi/dsdt.c +7052 -868

7,920 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#3 lore raw

RFC 3/9 xend: pass-through: Allow multi-function device specifications to be parsed

In reply to Simon Horman

The general format is as follows:

Now: SEQ:BUS:DEV.FUNC[@VSLOT][,OPT...]
New: SEQ:BUS:DEV.FUNC0-FUNCN[@VSLOT][,OPT...]

       SEQ:BUS:DEV.FUNC0,FUNCM,FUNCN[@VSLOT][,OPT...]
       SEQ:BUS:DEV.*[@VSLOT][,OPT...]

In the case of unplug the VSLOT and OPT must be omitted.

Xm expands this notation notation out and passes more conventional parameters to qemu-xen.

E.g:

       0000:00:01.00-03 becomes:
         0000:00:01.00
         0000:00:01.01
         0000:00:01.02
         0000:00:01.03

       0000:00:01.00,03,05,07 becomes:
         0000:00:01.00
         0000:00:01.03
         0000:00:01.05
         0000:00:01.07

       For a device that has functions 0, 1, 2, 3, 5 and 7,
       0000:00:01.* becomes:
         0000:00:01.00
         0000:00:01.01
         0000:00:01.02
         0000:00:01.03
         0000:00:01.05
         0000:00:01.07
Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>
Cc Akio Takebe <[email protected]>

---

Wed, 20 May 2009 23:28:45 +1000
* Update for recent changes to the preceeding patch "xm: Common parse_pci_name()"
* Enhance error reporting in parse_pci_name()

Fri, 29 May 2009 09:15:23 +1000
* Up-port

Tue, 16 Jun 2009 20:40:24 +1000
* pci_func_list_map_fn() bugs, thanks to Takebe-san
- Fix syntax error in filter in pci_func_list_map_fn()
- pci_list_cmp() should be pci_dict_cmp
- return a list of integers not strings

tools/python/xen/util/pci.py +85 -20
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
@@ -16,7 +16,7 @@ import threading
 from xen.util import utils
 from xen.xend import uuid
 from xen.xend import sxp
-from xen.xend.XendConstants import AUTO_PHP_DEVFN
+from xen.xend.XendConstants import AUTO_PHP_SLOT
 from xen.xend.XendSXPDev import dev_dict_to_sxp
 
 PROC_PCI_PATH = '/proc/bus/pci/devices'
@@ -227,11 +227,39 @@ def parse_hex(val):
     except ValueError:
         return None
 
+def pci_func_list_map_fn(key, func_str):
+    if func_str == "*":
+        return map(lambda x: int(x['func'], 16),
+                   filter(lambda x:
+                          pci_dict_cmp(x, key, ['domain', 'bus', 'slot']),
+                          get_all_pci_dict()))
+    l = map(int, func_str.split("-"))
+    if len(l) == 1:
+        return l
+    if len(l) == 2:
+        if l[0] < l[1]:
+            return range(l[0], l[1] + 1)
+        else:
+            x = range(l[1], l[0] + 1)
+            x.reverse()
+            return x
+    return []
+
+def pci_func_list_process(pci_dev_str, template, func_str):
+    l = reduce(lambda x, y: x + y,
+               (map(lambda x: pci_func_list_map_fn(template, x),
+                    func_str.split(","))))
+
+    if len(l) != len(set(l)):
+        raise PciDeviceParseError("Duplicate functions: %s" % pci_dev_str)
+
+    return l
+
 def parse_pci_name_extended(pci_dev_str):
     pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" +
                          r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" +
                          r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" +
-                         r"(?P<func>(\*|[0-7]))" +
+                         r"(?P<func>(\*|[0-7]([,-][0-7])*))" +
                          r"(@(?P<vslot>[01]?[0-9a-fA-F]))?" +
                          r"(,(?P<opts>.*))?$", pci_dev_str)
 
@@ -239,31 +267,65 @@ def parse_pci_name_extended(pci_dev_str)
         raise PciDeviceParseError("Failed to parse pci device: %s" %
                                   pci_dev_str)
 
-    out = {}
     pci_dev_info = pci_match.groupdict('')
-    if pci_dev_info['domain'] == '':
-        domain = 0
-    else:
+
+    template = {}
+    if pci_dev_info['domain'] != '':
         domain = int(pci_dev_info['domain'], 16)
-    out['domain'] = "0x%04x" % domain
-    out['bus']    = "0x%02x" % int(pci_dev_info['bus'], 16)
-    out['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
-    out['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
-    if pci_dev_info['vslot'] == '':
-        vslot = AUTO_PHP_DEVFN
     else:
-        vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), 0)
-    out['vslot'] = "0x%02x" % vslot
+        domain = 0
+    template['domain'] = "0x%04x" % domain
+    template['bus']    = "0x%02x" % int(pci_dev_info['bus'], 16)
+    template['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
+    template['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
     if pci_dev_info['opts'] != '':
-        out['opts'] = split_pci_opts(pci_dev_info['opts'])
-        check_pci_opts(out['opts'])
+        template['opts'] = split_pci_opts(pci_dev_info['opts'])
+        check_pci_opts(template['opts'])
 
-    return out
+    # This is where virtual function assignment takes place
+    # Virtual slot assignment takes place here if specified in the bdf,
+    # else it is done inside qemu-xen, as it knows which slots are free
+    pci = []
+    func_list = pci_func_list_process(pci_dev_str, template,
+                                      pci_dev_info['func'])
+    for func in func_list:
+        pci_dev = template.copy()
+
+        if len(func_list) == 1:
+            # For single-function devices vfunc must be 0
+            vfunc = 0
+        else:
+            # For multi-function virtual devices,
+            # identity map the func to vfunc
+            vfunc = func
+        if pci_dev_info['vslot'] == '':
+            vslot = AUTO_PHP_SLOT | vfunc
+        else:
+            vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), vfunc)
+        pci_dev['vslot'] = "0x%02x" % vslot
+
+        pci.append(pci_dev)
+
+    # For pci attachment and detachment is it important that virtual
+    # function 0 is done last. This is because is virtual function 0 that
+    # is used to singnal changes to the guest using ACPI
+    #
+    # By arranging things so that virtual function 0 is first,
+    # attachemnt can use the returned list as is. And detachment
+    # can just reverse the list.
+    pci.sort(None, lambda x: int(x['vslot'], 16), 1)
+    return pci
 
 def parse_pci_name(pci_name_string):
-    pci = parse_pci_name_extended(pci_name_string)
+    dev = parse_pci_name_extended(pci_name_string)
 
-    if int(pci['vslot'], 16) != AUTO_PHP_DEVFN:
+    if len(dev) != 1:
+        raise PciDeviceParseError(("Failed to parse pci device: %s: "
+                                   "multiple functions specified prohibited") %
+                                    pci_name_string)
+
+    pci = dev[0]
+    if not int(pci['vslot'], 16) & AUTO_PHP_SLOT:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
                                    "vslot provided where prohibited: 0x%02x") %
                                   (pci_name_string,
@@ -321,8 +383,11 @@ def get_all_pci_names():
     pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH).read().split()
     return pci_names
 
+def get_all_pci_dict():
+    return map(parse_pci_name, get_all_pci_names())
+
 def get_all_pci_devices():
-    return map(PciDevice, map(parse_pci_name, get_all_pci_names()))
+    return map(PciDevice, get_all_pci_dict())
 
 def _create_lspci_info():
     """Execute 'lspci' command and parse the result.
tools/python/xen/xm/create.py +2 -2
Index: xen-unstable.hg/tools/python/xen/xm/create.py
===================================================================
@@ -1060,8 +1060,8 @@ def preprocess_pci(vals):
     if not vals.pci:
         return
     try:
-        vals.pci = map(pci_dict_to_tuple,
-                       map(parse_pci_name_extended, vals.pci))
+        vals.pci = map(pci_dict_to_tuple, reduce(lambda x, y: x + y,
+                       map(parse_pci_name_extended, vals.pci)))
     except PciDeviceParseError, ex:
         err(str(ex))
 
tools/python/xen/xend/XendConstants.py +1 -2
Index: xen-unstable.hg/tools/python/xen/xend/XendConstants.py
===================================================================
@@ -141,8 +141,7 @@ XS_VMROOT = "/vm/"
 NR_PCI_FUNC = 8
 NR_PCI_DEV = 32
 NR_PCI_DEVFN = NR_PCI_FUNC * NR_PCI_DEV
-AUTO_PHP_DEVFN = NR_PCI_DEVFN
-AUTO_PHP_DEVFN_STR = "%02x" % NR_PCI_DEVFN
+AUTO_PHP_SLOT = 0x100
 
 #
 # tmem
tools/python/xen/xend/XendDomainInfo.py +1 -1
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
@@ -644,7 +644,7 @@ class XendDomainInfo:
             pci_devs = pci_conf['devs']
             for x in pci_devs:
                 if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
-                   int(x['vslot'], 16) != AUTO_PHP_DEVFN):
+                    not int(x['vslot'], 16) & AUTO_PHP_SLOT):
                     raise VmError("vslot %s already have a device." % (new_dev['vslot']))
 
                 if (pci_dict_cmp(x, new_dev)):
tools/python/xen/xm/main.py +2 -2
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2210,7 +2210,7 @@ def xm_pci_list(args):
 
     has_vslot = False
     for x in devs:
-        if x['vslot'] == AUTO_PHP_DEVFN:
+        if x['vslot'] & AUTO_PHP_SLOT:
             x['show_vslot'] = '-'
             x['show_vfunc'] = '-'
         else:
@@ -2493,7 +2493,7 @@ def parse_pci_configuration(args, state,
         pci_dev_str += ',' + serialise_pci_opts(opts)
 
     try:
-        pci_dev = parse_pci_name_extended(pci_dev_str)
+        pci_dev = parse_pci_name_extended(pci_dev_str)[0]
     except PciDeviceParseError, ex:
         raise OptionError(str(ex))
 
tools/python/xen/xend/XendConfig.py +2 -3
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI
 from xen.xend.XendError import VmError
 from xen.xend.XendDevices import XendDevices
 from xen.xend.PrettyPrint import prettyprintstring
-from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_DEVFN_STR
+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.server.BlktapController import blktap_disk_types
 from xen.xend.server.netif import randomMAC
@@ -1237,8 +1237,7 @@ class XendConfig(dict):
             dpci_record = {
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
-                'hotplug_slot': pci_dev.get('vslot',
-                                            '0x' + AUTO_PHP_DEVFN_STR)
+                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT)
             }
 
             dpci_opts = pci_dev.get('opts')
tools/python/xen/xend/server/pciif.py +1 -2
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
@@ -74,8 +74,7 @@ class PciController(DevController):
             bus = parse_hex(pci_config.get('bus', 0))
             slot = parse_hex(pci_config.get('slot', 0))
             func = parse_hex(pci_config.get('func', 0))            
-            vslot = parse_hex(pci_config.get('vslot',
-                                             '0x' + AUTO_PHP_DEVFN_STR))
+            vslot = parse_hex(pci_config.get('vslot', '0x%02x' % AUTO_PHP_SLOT))
 
             if pci_config.has_key('opts'):
                 opts = serialise_pci_opts(pci_config['opts'])
#4 lore raw

RFC 4/9 xend: pass-through: Only tell qemu-xen to unplug function 0

In reply to Simon Horman

When unplugging a function, all functions in the same vslot must be unplugged, and function 0 must be one of the functions present when a vslot is hot-plugged. Telling qemu-dm to unplug function 0 also tells it to unplug all other functions in the same vslot.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

Fri, 29 May 2009 09:17:10 +1000
* Remove PCI_FUNC() fragement for tools/python/xen/util/pci.py It has been moved into an earlier patch.

Fri, 22 May 2009 14:45:40 +1000
* Rediff for bdf6->bdf4 changes in previous patches

tools/python/xen/xend/XendDomainInfo.py +10 -2
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
@@ -42,7 +42,7 @@ from xen.util import xsconstants
 from xen.util.pci import serialise_pci_opts, pci_opts_list_to_sxp, \
                          pci_dict_to_bdf_str, pci_dict_to_xc_str, \
                          pci_convert_sxp_to_dict, pci_convert_dict_to_sxp, \
-                         pci_dict_cmp
+                         pci_dict_cmp, PCI_FUNC
 
 from xen.xend import balloon, sxp, uuid, image, arch
 from xen.xend import XendOptions, XendNode, XendConfig
@@ -844,7 +844,15 @@ class XendDomainInfo:
                     raise VmError("Device %s is not connected" %
                                   pci_dict_to_bdf_str(dev))
                 new_dev = new_devs[0]
-                self.hvm_destroyPCIDevice(new_dev)
+                # Only tell qemu-dm to unplug function 0.
+                # When unplugging a function, all functions in the
+                # same vslot must be unplugged, and function 0 must
+                # be one of the functions present when a vslot is
+                # hot-plugged. Telling qemu-dm to unplug function 0
+                # also tells it to unplug all other functions in the
+                # same vslot.
+                if (PCI_FUNC(int(new_dev['vslot'], 16)) == 0):
+                    self.hvm_destroyPCIDevice(new_dev)
                 # Update vslot
                 dev['vslot'] = new_dev['vslot']
                 for n in sxp.children(pci_dev):
#5 lore raw

RFC 5/9 xend: pass-through: Add pci_dict_bin_to_str()

In reply to Simon Horman

Break out the device list gathering code from xm_pci_list() so that it can be re-used by subsequent changes.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

 tools/python/xen/xm/main.py |   47 ++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 16 deletions(-)
tools/python/xen/xm/main.py +31 -16
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2171,37 +2171,52 @@ def xm_vtpm_list(args):
                    "%(be-path)-30s  "
                    % ni)
 
-
-def xm_pci_list(args):
-    (use_long, params) = arg_check_for_resource_list(args, "pci-list")
-
-    dom = params[0]
-
+def attached_pci_dict_bin(dom):
     devs = []
     if serverType == SERVER_XEN_API:
         for dpci_ref in server.xenapi.VM.get_DPCIs(get_single_vm(dom)):
             ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
             ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
             dev = {
-                "domain":   int(ppci_record["domain"]),
-                "bus":      int(ppci_record["bus"]),
-                "slot":     int(ppci_record["slot"]),
-                "func":     int(ppci_record["func"]),
-                "vslot":    int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
+                'domain': int(ppci_record['domain']),
+                'bus':    int(ppci_record['bus']),
+                'slot':   int(ppci_record['slot']),
+                'func':   int(ppci_record['func']),
+                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
             }
             devs.append(dev)
 
     else:
         for x in server.xend.domain.getDeviceSxprs(dom, 'pci'):
             dev = {
-                "domain":   int(x["domain"], 16),
-                "bus":      int(x["bus"], 16),
-                "slot":     int(x["slot"], 16),
-                "func":     int(x["func"], 16),
-                "vslot":    int(x["vslot"], 16)
+                'domain': int(x['domain'], 16),
+                'bus':    int(x['bus'], 16),
+                'slot':   int(x['slot'], 16),
+                'func':   int(x['func'], 16),
+                'vslot':  int(x['vslot'], 16)
             }
             devs.append(dev)
 
+    return devs
+
+def pci_dict_bin_to_str(pci_dev):
+    new_dev = pci_dev.copy()
+
+    new_dev['domain'] = '0x%04x' % pci_dev['domain']
+    new_dev['bus']    = '0x%02x' % pci_dev['bus']
+    new_dev['slot']   = '0x%02x' % pci_dev['slot']
+    new_dev['func']   = '0x%x'   % pci_dev['func']
+    new_dev['vslot']  = '0x%02x' % pci_dev['vslot']
+
+    return new_dev
+
+def attached_pci_dict(dom):
+    return map(pci_dict_bin_to_str, attached_pci_dict_bin(dom))
+
+def xm_pci_list(args):
+    (use_long, params) = arg_check_for_resource_list(args, "pci-list")
+
+    devs = attached_pci_dict_bin(params[0])
     if len(devs) == 0:
         return
 
#6 lore raw

RFC 6/9 xend: pass-through: Add key to pci device dictionary

In reply to Simon Horman

This will be used to identify the functions belonging to a multi-function device.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

 tools/python/xen/util/pci.py            |    3 ++-
 tools/python/xen/xend/XendConfig.py     |    3 ++-
 tools/python/xen/xend/XendDPCI.py       |    8 +++++++-
 tools/python/xen/xend/XendDomainInfo.py |    1 +
 tools/python/xen/xend/server/pciif.py   |    8 ++++++--
 tools/python/xen/xm/create.dtd          |    3 ++-
 tools/python/xen/xm/create.py           |    7 ++++---
 tools/python/xen/xm/main.py             |   10 +++++++---
 tools/python/xen/xm/xenapi_create.py    |    6 +++++-
 9 files changed, 36 insertions(+), 13 deletions(-)
tools/python/xen/xend/XendDomainInfo.py +1 -0
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
@@ -3733,6 +3733,7 @@ class XendDomainInfo:
                    ['slot', '0x%02x' % ppci.get_slot()],
                    ['func', '0x%1x' % ppci.get_func()],
                    ['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
+                   ['key', xenapi_pci['key']],
                    ['uuid', dpci_uuid]]
         dev_sxp = sxp.merge(dev_sxp, opts_sxp)
 
tools/python/xen/xm/main.py +7 -3
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2182,7 +2182,8 @@ def attached_pci_dict_bin(dom):
                 'bus':    int(ppci_record['bus']),
                 'slot':   int(ppci_record['slot']),
                 'func':   int(ppci_record['func']),
-                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
+                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)),
+                'key':    server.xenapi.DPCI.get_key(dpci_ref)
             }
             devs.append(dev)
 
@@ -2193,7 +2194,8 @@ def attached_pci_dict_bin(dom):
                 'bus':    int(x['bus'], 16),
                 'slot':   int(x['slot'], 16),
                 'func':   int(x['func'], 16),
-                'vslot':  int(x['vslot'], 16)
+                'vslot':  int(x['vslot'], 16),
+                'key':    x['key']
             }
             devs.append(dev)
 
@@ -2539,6 +2541,7 @@ def xm_pci_attach(args):
         slot = int(sxp.child_value(pci_dev, 'slot'), 16)
         func = int(sxp.child_value(pci_dev, 'func'), 16)
         vslot = int(sxp.child_value(pci_dev, 'vslot'), 16)
+        key = sxp.child_value(pci_dev, 'key')
         name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func)
 
         target_ref = None
@@ -2553,7 +2556,8 @@ def xm_pci_attach(args):
             "VM":           get_single_vm(dom),
             "PPCI":         target_ref,
             "hotplug_slot": vslot,
-            "options":      dict(config_pci_opts)
+            "options":      dict(config_pci_opts),
+            "key":          key
         }
         server.xenapi.DPCI.create(dpci_record)
 
tools/python/xen/util/pci.py +2 -1
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
@@ -284,7 +284,7 @@ def parse_pci_name_extended(pci_dev_str)
     template['domain'] = "0x%04x" % domain
     template['bus']    = "0x%02x" % int(pci_dev_info['bus'], 16)
     template['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
-    template['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
+    template['key']    = pci_dev_str
     if pci_dev_info['opts'] != '':
         template['opts'] = split_pci_opts(pci_dev_info['opts'])
         check_pci_opts(template['opts'])
@@ -297,6 +297,7 @@ def parse_pci_name_extended(pci_dev_str)
                                       pci_dev_info['func'])
     for func in func_list:
         pci_dev = template.copy()
+        pci_dev['func'] = "0x%x" % func
 
         if len(func_list) == 1:
             # For single-function devices vfunc must be 0
tools/python/xen/xend/XendConfig.py +2 -1
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
@@ -1237,7 +1237,8 @@ class XendConfig(dict):
             dpci_record = {
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
-                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT)
+                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT),
+                'key': pci_dev['key']
             }
 
             dpci_opts = pci_dev.get('opts')
tools/python/xen/xend/XendDPCI.py +7 -1
Index: xen-unstable.hg/tools/python/xen/xend/XendDPCI.py
===================================================================
@@ -42,6 +42,7 @@ class XendDPCI(XendBase):
                   'VM',
                   'PPCI',
                   'hotplug_slot',
+                  'key',
                   'options']
         return XendBase.getAttrRO() + attrRO
 
@@ -52,7 +53,8 @@ class XendDPCI(XendBase):
     def getAttrInst(self):
         attrInst = ['VM',
                     'PPCI',
-                    'hotplug_slot']
+                    'hotplug_slot',
+                    'key']
         return XendBase.getAttrInst() + attrInst
 
     def getMethods(self):
@@ -120,6 +122,7 @@ class XendDPCI(XendBase):
         self.VM = record['VM']
         self.PPCI = record['PPCI']
         self.hotplug_slot = int(record['hotplug_slot'], 16)
+        self.key = record['key']
         if 'options' in record.keys():
             self.options = record['options']
 
@@ -155,5 +158,8 @@ class XendDPCI(XendBase):
     def get_hotplug_slot(self):
         return "%d" % self.hotplug_slot
 
+    def get_key(self):
+        return self.key
+
     def get_options(self):
         return self.options
tools/python/xen/xend/server/pciif.py +6 -2
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
@@ -83,6 +83,7 @@ class PciController(DevController):
             back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
                                         (domain, bus, slot, func)
             back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
+            back['key-%i' % pcidevid] = pci_config.get('key', '')
             back['vslot-%i' % pcidevid] = "%02x" % vslot
             pcidevid += 1
 
@@ -113,6 +114,7 @@ class PciController(DevController):
                 dev = back['dev-%i' % i]
                 state = states[i]
                 uuid = back['uuid-%i' %i]
+                key = back['key-%i' %i]
                 opts = ''
                 if 'opts-%i' % i in back:
                     opts = back['opts-%i' % i]
@@ -135,6 +137,7 @@ class PciController(DevController):
                 self.writeBackend(devid, 'state-%i' % devno,
                                   str(xenbusState['Initialising']))
                 self.writeBackend(devid, 'uuid-%i' % devno, uuid)
+                self.writeBackend(devid, 'key-%i' % devno, key)
                 if len(opts) > 0:
                     self.writeBackend(devid, 'opts-%i' % devno, opts)
                 if back.has_key('vslot-%i' % i):
@@ -173,6 +176,7 @@ class PciController(DevController):
 
             # Per device uuid info
             pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
+            pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
             pci_dev['vslot'] = '0x%s' % self.readBackend(devid, 'vslot-%d' % i)
 
             #append opts info
@@ -500,7 +504,7 @@ class PciController(DevController):
                 # In HVM case, I/O resources are disabled in ioemu.
                 self.cleanupOneDevice(pci_dev)
                 # Remove xenstore nodes.
-                list = ['dev', 'vdev', 'state', 'uuid', 'vslot']
+                list = ['dev', 'vdev', 'state', 'uuid', 'vslot', 'key']
                 if self.readBackend(devid, 'opts-%i' % i) is not None:
                     list.append('opts')
                 for key in list:
@@ -510,7 +514,7 @@ class PciController(DevController):
                 if new_num_devs == i + 1:
                     continue
 
-                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot']
+                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key']
                 for key in list:
                     tmp = self.readBackend(devid, '%s-%i' % (key, i))
                     if tmp is None:
tools/python/xen/xm/create.dtd +2 -1
Index: xen-unstable.hg/tools/python/xen/xm/create.dtd
===================================================================
@@ -90,7 +90,8 @@
                  slot            CDATA #REQUIRED
                  func            CDATA #REQUIRED
                  opts_str        CDATA #IMPLIED
-                 vslot           CDATA #IMPLIED>
+                 vslot           CDATA #IMPLIED
+                 key             CDATA #IMPLIED>
 
 <!ELEMENT vscsi  EMPTY>
 <!ATTLIST vscsi  p-dev           CDATA #REQUIRED
tools/python/xen/xm/xenapi_create.py +5 -1
Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
===================================================================
@@ -543,7 +543,9 @@ class xenapi_create:
                 int(pci.attributes["vslot"].value, 16),
             "options":
                 get_child_nodes_as_dict(pci,
-                  "pci_opt", "key", "value")
+                  "pci_opt", "key", "value"),
+            "key":
+                pci.attributes["key"].value
         }
 
         return server.xenapi.DPCI.create(dpci_record)
@@ -946,6 +948,8 @@ class sxp2xml:
                     = get_child_by_name(dev_sxp, "func", "0")
                 pci.attributes["vslot"] \
                     = get_child_by_name(dev_sxp, "vslot", "0")
+                pci.attributes["key"] \
+                    = get_child_by_name(dev_sxp, "key", "0")
                 for opt in pci_opts_list_from_sxp(dev_sxp):
                     pci_opt = document.createElement("pci_opt")
                     pci_opt.attributes["key"] = opt[0]
tools/python/xen/xm/create.py +4 -3
Index: xen-unstable.hg/tools/python/xen/xm/create.py
===================================================================
@@ -1044,14 +1044,15 @@ def preprocess_cpuid(vals, attr_name):
 
 def pci_dict_to_tuple(dev):
     return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
-            dev['vslot'], dev.get('opts', []))
+            dev['vslot'], dev.get('opts', []), dev['key'])
 
-def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts)):
+def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts, key)):
     pci_dev = { 'domain': domain,
                 'bus':    bus,
                 'slot':   slot,
                 'func':   func,
-                'vslot':  vslot}
+                'vslot':  vslot,
+                'key':    key}
     if len(opts) > 0:
         pci_dev['opts'] = opts
     return pci_dev
#7 lore raw

RFC 7/9 xend: pass-through: Parse command line for multi-function hot-plug and unplug

In reply to Simon Horman

Hook things up to allow multi-function pass-through.

This includes making sure that request is valid.
In the case of pci-detach:

* All the functions requested must be attached to the same virtual slot * and;
* A request must include the functions attached to a virtual slot

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

Wed, 20 May 2009 18:14:38 +1000
* Update for cset 19626:145e49b8574c

Fri, 22 May 2009 14:49:21 +1000
* Update for for bdf6->bdf4 changes in previous patches
* Remove bogus bdf6_to_bdf_string() hunk
* Move bdf6_to_sxp_request() call out of parse_pci_configuration()
- This saves subsequently reversing the conversion
* Refactor bdf6_find_attached_devfn() to work on attached being a list of sprs
- This saves a to bdf6 format
* Rename bdf6_find_attached_devfn bdf4_find_attached_devfn
* Move parse_pci_configuration() to main.py
- It is only ever used in main.py

Fri, 29 May 2009 09:18:15 +1000
* Remove "from xen.xend import sxp" hunk from tools/python/xen/util/pci.py. It is present in an earlier patch by Kanno-san.

tools/python/xen/xm/main.py +84 -28
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2222,8 +2222,9 @@ def xm_pci_list(args):
     if len(devs) == 0:
         return
 
-    devs.sort(None, lambda x: x['vslot'] << 32 | PCI_BDF(x['domain'], x['bus'],
-                                                         x['slot'], x['func']))
+    devs.sort(None,
+              lambda x: (x['vslot'] - PCI_FUNC(x['vslot'])) << 32 |
+                        PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
 
     has_vslot = False
     for x in devs:
@@ -2501,7 +2502,7 @@ def xm_network_attach(args):
             vif.append(vif_param)
         server.xend.domain.device_create(dom, vif)
 
-def parse_pci_configuration(args, state, opts = ''):
+def parse_pci_configuration(args, opts = ''):
     dom = args[0]
     pci_dev_str = args[1]
     if len(args) == 3:
@@ -2510,11 +2511,11 @@ def parse_pci_configuration(args, state,
         pci_dev_str += ',' + serialise_pci_opts(opts)
 
     try:
-        pci_dev = parse_pci_name_extended(pci_dev_str)[0]
+        pci_dev = parse_pci_name_extended(pci_dev_str)
     except PciDeviceParseError, ex:
         raise OptionError(str(ex))
 
-    return (dom, pci_convert_dict_to_sxp(pci_dev, state))
+    return (dom, pci_dev)
 
 def xm_pci_attach(args):
     config_pci_opts = []
@@ -2531,19 +2532,31 @@ def xm_pci_attach(args):
         err("Invalid argument for 'xm pci-attach'")
         usage('pci-attach')
 
-    (dom, pci) = parse_pci_configuration(params, 'Initialising',
-                     config_pci_opts)
+    (dom, dev) = parse_pci_configuration(params, config_pci_opts)
 
-    if serverType == SERVER_XEN_API:
-        pci_dev = sxp.children(pci, 'dev')[0]
-        domain = int(sxp.child_value(pci_dev, 'domain'), 16)
-        bus = int(sxp.child_value(pci_dev, 'bus'), 16)
-        slot = int(sxp.child_value(pci_dev, 'slot'), 16)
-        func = int(sxp.child_value(pci_dev, 'func'), 16)
-        vslot = int(sxp.child_value(pci_dev, 'vslot'), 16)
-        key = sxp.child_value(pci_dev, 'key')
-        name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func)
+    head_dev = dev.pop(0)
+    xm_pci_attach_one(dom, head_dev)
+
+    # That is all for single-function virtual devices
+    if len(dev) == 0:
+        return
 
+    # If the slot wasn't spefified in the args then use the slot
+    # assigned to the head by qemu-xen for the rest of the functions
+    if int(head_dev['vslot'], 16) & AUTO_PHP_SLOT:
+        vdevfn = int(find_attached_devfn(attached_pci_dict(dom), head_dev), 16)
+        if not vdevfn & AUTO_PHP_SLOT:
+            vslot = PCI_SLOT(vdevfn)
+            for i in dev:
+                i['vslot'] = '0x%02x' % \
+		             PCI_DEVFN(vslot, PCI_FUNC(int(i['vslot'], 16)))
+
+    for i in dev:
+        xm_pci_attach_one(dom, i)
+
+def xm_pci_attach_one(dom, pci_dev):
+    if serverType == SERVER_XEN_API:
+        name = pci_dict_to_bdf_str(pci_dev)
         target_ref = None
         for ppci_ref in server.xenapi.PPCI.get_all():
             if name == server.xenapi.PPCI.get_name(ppci_ref):
@@ -2555,13 +2568,14 @@ def xm_pci_attach(args):
         dpci_record = {
             "VM":           get_single_vm(dom),
             "PPCI":         target_ref,
-            "hotplug_slot": vslot,
-            "options":      dict(config_pci_opts),
-            "key":          key
+            "hotplug_slot": int(pci_dev['vslot'], 16),
+            "options":      dict(pci_dev.get('opts', [])),
+            "key":          pci_dev['key']
         }
         server.xenapi.DPCI.create(dpci_record)
 
     else:
+        pci = pci_convert_dict_to_sxp(pci_dev, 'Initialising')
         server.xend.domain.device_configure(dom, pci)
 
 def parse_scsi_configuration(p_scsi, v_hctl, state):
@@ -2704,20 +2718,61 @@ def xm_network_detach(args):
         arg_check(args, 'network-detach', 2, 3)
         detach(args, 'vif')
 
+def find_attached(attached, key):
+    l = filter(lambda dev: pci_dict_cmp(dev, key), attached)
+
+    if len(l) == 0:
+         raise OptionError("pci: device is not attached: " +
+                           pci_dict_to_bdf_str(key))
+
+    # There shouldn't ever be more than one match,
+    # but perhaps an exception should be thrown if there is
+    return l[0]
+
+def find_attached_devfn(attached, key):
+    pci_dev = find_attached(attached, key)
+    return pci_dev['vslot']
+
 def xm_pci_detach(args):
     arg_check(args, 'pci-detach', 2)
-    (dom, pci) = parse_pci_configuration(args, 'Closing')
 
-    if serverType == SERVER_XEN_API:
+    (dom, dev) = parse_pci_configuration(args)
+    attached = attached_pci_dict(dom)
 
-        pci_dev = sxp.children(pci, 'dev')[0]
-        domain = int(sxp.child_value(pci_dev, 'domain'), 16)
-        bus = int(sxp.child_value(pci_dev, 'bus'), 16)
-        slot = int(sxp.child_value(pci_dev, 'slot'), 16)
-        func = int(sxp.child_value(pci_dev, 'func'), 16)
-        vslot = int(sxp.child_value(pci_dev, 'vslot'), 16)
-        name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func)
+    attached_dev = map(lambda x: find_attached(attached, x), dev)
 
+    def f(pci_dev):
+        vdevfn = int(pci_dev['vslot'], 16)
+        return PCI_SLOT(vdevfn) | (vdevfn & AUTO_PHP_SLOT)
+    vslots = map(f, attached_dev)
+    if len(set(vslots)) > 1:
+        err_str = map(lambda x: "\t%s is in slot 0x%02x\n" %
+                                (pci_dict_to_bdf_str(x),
+                                 PCI_SLOT(int(x['vslot'], 16))), dev)
+        raise OptionError("More than one slot used by specified devices\n"
+                          + ''.join(err_str))
+
+    attached_to_slot = filter(lambda x:
+                              f(x) == vslots[0] and
+                              attached_dev[0]["key"] ==
+                                      x["key"], attached_dev)
+
+    if len(attached_to_slot) != len(dev):
+        err_str_ = map(lambda x: '\t%s\n' % pci_dict_to_bdf_str(x), dev)
+        err_str = "Requested:\n" + ''.join(err_str_)
+        err_str_ = map(lambda x: '\t%s (%s)\n' %
+                       (pci_dict_to_bdf_str(x), x['key']),
+                       attached_to_slot)
+        err_str += "Present:\n" + ''.join(err_str_)
+        raise OptionError(("Not all functions in slot 0x%02x have had "
+                           "detachment requested.\n" % vslots[0]) + err_str)
+
+    for i in dev:
+        xm_pci_detach_one(dom, i)
+
+def xm_pci_detach_one(dom, pci_dev):
+    if serverType == SERVER_XEN_API:
+        name = pci_dict_to_bdf_str(pci_dev)
         target_ref = None
         for dpci_ref in server.xenapi.VM.get_DPCIs(get_single_vm(dom)):
             ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
@@ -2729,6 +2784,7 @@ def xm_pci_detach(args):
             raise OptionError("Device %s not assigned" % name)
 
     else:
+        pci = pci_convert_dict_to_sxp(pci_dev, 'Closing')
         server.xend.domain.device_configure(dom, pci)
 
 def xm_scsi_detach(args):
tools/python/xen/xend/XendDomainInfo.py +46 -6

65 lines not on this page · raw message

#8 lore raw

RFC 8/9 xend: pass-through: rename vslot to vdevfn and vslots to vdevfns

In reply to Simon Horman

This is a noisy patch that makes not functional changes. It renames vslot to vdevfn and vslots to vdevfns.

This breaks compatibility with qemu-xen and a companion patch for that code will be posted separately.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>

---

Co-Dependent on
"qemu-xen: pass-through: rename vslot to vdevfn and vslots to vdevfns"

Changes

Wed, 13 May 2009 11:33:37 +1000
* Rediff for "[patch] passthrough: Fix PCI hot-plug option parsing"

Fri, 22 May 2009 17:35:07 +1000
* Rediff for recent changes to previous patches
* sxp_to_bdf6(): stringify opts

tools/python/xen/util/pci.py +12 -12
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
@@ -187,10 +187,10 @@ def pci_convert_sxp_to_dict(dev_sxp):
     # extendend like this:
     #
     # [device, [pci, [dev, [domain, 0], [bus, 0], [slot, 1], [func, 2],
-    #                      [vslot, 0]],
+    #                      [vdevfn, 0]],
     #                [state, 'Initialising']]]
     #
-    # 'vslot' shows the virtual hotplug slot number which the PCI device
+    # 'vdevfn' shows the virtual hotplug slot number which the PCI device
     # is inserted in. This is only effective for HVM domains.
     #
     # state 'Initialising' indicates that the device is being attached,
@@ -198,7 +198,7 @@ def pci_convert_sxp_to_dict(dev_sxp):
     #
     # The Dict looks like this:
     #
-    # { devs: [{domain: 0, bus: 0, slot: 1, func: 2, vslot: 0}],
+    # { devs: [{domain: 0, bus: 0, slot: 1, func: 2, vdevfn: 0}],
     #   states: ['Initialising'] }
 
     dev_config = {}
@@ -267,7 +267,7 @@ def parse_pci_name_extended(pci_dev_str)
                          r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" +
                          r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" +
                          r"(?P<func>(\*|[0-7]([,-][0-7])*))" +
-                         r"(@(?P<vslot>[01]?[0-9a-fA-F]))?" +
+                         r"(@(?P<vdevfn>[01]?[0-9a-fA-F]))?" +
                          r"(,(?P<opts>.*))?$", pci_dev_str)
 
     if pci_match == None:
@@ -306,11 +306,11 @@ def parse_pci_name_extended(pci_dev_str)
             # For multi-function virtual devices,
             # identity map the func to vfunc
             vfunc = func
-        if pci_dev_info['vslot'] == '':
-            vslot = AUTO_PHP_SLOT | vfunc
+        if pci_dev_info['vdevfn'] == '':
+            vdevfn = AUTO_PHP_SLOT | vfunc
         else:
-            vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), vfunc)
-        pci_dev['vslot'] = "0x%02x" % vslot
+            vdevfn = PCI_DEVFN(int(pci_dev_info['vdevfn'], 16), vfunc)
+        pci_dev['vdevfn'] = "0x%02x" % vdevfn
 
         pci.append(pci_dev)
 
@@ -321,7 +321,7 @@ def parse_pci_name_extended(pci_dev_str)
     # By arranging things so that virtual function 0 is first,
     # attachemnt can use the returned list as is. And detachment
     # can just reverse the list.
-    pci.sort(None, lambda x: int(x['vslot'], 16), 1)
+    pci.sort(None, lambda x: int(x['vdevfn'], 16), 1)
     return pci
 
 def parse_pci_name(pci_name_string):
@@ -333,11 +333,11 @@ def parse_pci_name(pci_name_string):
                                     pci_name_string)
 
     pci = dev[0]
-    if not int(pci['vslot'], 16) & AUTO_PHP_SLOT:
+    if not int(pci['vdevfn'], 16) & AUTO_PHP_SLOT:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
-                                   "vslot provided where prohibited: 0x%02x") %
+                                   "vdevfn provided where prohibited: 0x%02x") %
                                   (pci_name_string,
-                                   PCI_SLOT(int(pci['vslot'], 16))))
+                                   PCI_SLOT(int(pci['vdevfn'], 16))))
     if 'opts' in pci:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
                                    "options provided where prohibited: %s") %
tools/python/xen/xend/server/pciif.py +10 -8
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
@@ -74,7 +74,8 @@ class PciController(DevController):
             bus = parse_hex(pci_config.get('bus', 0))
             slot = parse_hex(pci_config.get('slot', 0))
             func = parse_hex(pci_config.get('func', 0))            
-            vslot = parse_hex(pci_config.get('vslot', '0x%02x' % AUTO_PHP_SLOT))
+            vdevfn = parse_hex(pci_config.get('vdevfn', \
+                                              '0x%02x' % AUTO_PHP_SLOT))
 
             if pci_config.has_key('opts'):
                 opts = serialise_pci_opts(pci_config['opts'])
@@ -84,7 +85,7 @@ class PciController(DevController):
                                         (domain, bus, slot, func)
             back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
             back['key-%i' % pcidevid] = pci_config.get('key', '')
-            back['vslot-%i' % pcidevid] = "%02x" % vslot
+            back['vdevfn-%i' % pcidevid] = "%02x" % vdevfn
             pcidevid += 1
 
         back['num_devs']=str(pcidevid)
@@ -140,9 +141,9 @@ class PciController(DevController):
                 self.writeBackend(devid, 'key-%i' % devno, key)
                 if len(opts) > 0:
                     self.writeBackend(devid, 'opts-%i' % devno, opts)
-                if back.has_key('vslot-%i' % i):
-                    self.writeBackend(devid, 'vslot-%i' % devno,
-                                      back['vslot-%i' % i])
+                if back.has_key('vdevfn-%i' % i):
+                    self.writeBackend(devid, 'vdevfn-%i' % devno,
+                                      back['vdevfn-%i' % i])
 
                 # If a device is being attached then num_devs will grow
                 if attaching:
@@ -177,7 +178,8 @@ class PciController(DevController):
             # Per device uuid info
             pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
             pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
-            pci_dev['vslot'] = '0x%s' % self.readBackend(devid, 'vslot-%d' % i)
+            pci_dev['vdevfn'] = '0x%s' % self.readBackend(devid,
+                                                          'vdevfn-%d' % i)
 
             #append opts info
             opts = self.readBackend(devid, 'opts-%d' % i)
@@ -504,7 +506,7 @@ class PciController(DevController):
                 # In HVM case, I/O resources are disabled in ioemu.
                 self.cleanupOneDevice(pci_dev)
                 # Remove xenstore nodes.
-                list = ['dev', 'vdev', 'state', 'uuid', 'vslot', 'key']
+                list = ['dev', 'vdev', 'state', 'uuid', 'vdevfn', 'key']
                 if self.readBackend(devid, 'opts-%i' % i) is not None:
                     list.append('opts')
                 for key in list:
@@ -514,7 +516,7 @@ class PciController(DevController):
                 if new_num_devs == i + 1:
                     continue
 
-                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key']
+                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vdevfn', 'key']
                 for key in list:
                     tmp = self.readBackend(devid, '%s-%i' % (key, i))
                     if tmp is None:
tools/python/xen/xm/main.py +21 -21

116 lines not on this page · raw message

tools/python/xen/xend/XendConfig.py +3 -3
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
@@ -1237,7 +1237,7 @@ class XendConfig(dict):
             dpci_record = {
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
-                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT),
+                'hotplug_slot': pci_dev.get('vdevfn', '0x%02x' % AUTO_PHP_SLOT),
                 'key': pci_dev['key']
             }
 
@@ -2038,8 +2038,8 @@ class XendConfig(dict):
                 bus = sxp.child_value(dev, 'bus')
                 slot = sxp.child_value(dev, 'slot')
                 func = sxp.child_value(dev, 'func')
-                vslot = sxp.child_value(dev, 'vslot')
+                vdevfn = sxp.child_value(dev, 'vdevfn')
                 opts = pci_opts_list_from_sxp(dev)
-                pci.append([domain, bus, slot, func, vslot, opts])
+                pci.append([domain, bus, slot, func, vdevfn, opts])
         self['platform']['pci'] = pci
 
tools/python/xen/xend/XendDomainInfo.py +28 -26

114 lines not on this page · raw message

tools/python/xen/xm/create.dtd +1 -1
Index: xen-unstable.hg/tools/python/xen/xm/create.dtd
===================================================================
@@ -90,7 +90,7 @@
                  slot            CDATA #REQUIRED
                  func            CDATA #REQUIRED
                  opts_str        CDATA #IMPLIED
-                 vslot           CDATA #IMPLIED
+                 vdevfn          CDATA #IMPLIED
                  key             CDATA #IMPLIED>
 
 <!ELEMENT vscsi  EMPTY>
tools/python/xen/xm/create.py +3 -3
Index: xen-unstable.hg/tools/python/xen/xm/create.py
===================================================================
@@ -1044,14 +1044,14 @@ def preprocess_cpuid(vals, attr_name):
 
 def pci_dict_to_tuple(dev):
     return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
-            dev['vslot'], dev.get('opts', []), dev['key'])
+            dev['vdevfn'], dev.get('opts', []), dev['key'])
 
-def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts, key)):
+def pci_tuple_to_dict((domain, bus, slot, func, vdevfn, opts, key)):
     pci_dev = { 'domain': domain,
                 'bus':    bus,
                 'slot':   slot,
                 'func':   func,
-                'vslot':  vslot,
+                'vdevfn': vdevfn,
                 'key':    key}
     if len(opts) > 0:
         pci_dev['opts'] = opts
tools/python/xen/xm/xenapi_create.py +3 -3
Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
===================================================================
@@ -540,7 +540,7 @@ class xenapi_create:
             "PPCI":
                 target_ref,
             "hotplug_slot":
-                int(pci.attributes["vslot"].value, 16),
+                int(pci.attributes["vdevfn"].value, 16),
             "options":
                 get_child_nodes_as_dict(pci,
                   "pci_opt", "key", "value"),
@@ -946,8 +946,8 @@ class sxp2xml:
                     = get_child_by_name(dev_sxp, "slot", "0")
                 pci.attributes["func"] \
                     = get_child_by_name(dev_sxp, "func", "0")
-                pci.attributes["vslot"] \
-                    = get_child_by_name(dev_sxp, "vslot", "0")
+                pci.attributes["vdevfn"] \
+                    = get_child_by_name(dev_sxp, "vdevfn", "0")
                 pci.attributes["key"] \
                     = get_child_by_name(dev_sxp, "key", "0")
                 for opt in pci_opts_list_from_sxp(dev_sxp):
#9 lore raw

RFC 9/9 xend: pass-through: Implement least-mapping of virtual functions

In reply to Simon Horman

This is an alternative to identity mapping virtual functions.

It works by assigning the numerically lowest virtual function that is available.

* The order of assignment is thus dependent on the order that physical functions are specified.

e.g.

  config         physical     virtual
  01.00.0,2  ->  01:00.0  ->  00:07.0
             ->  01:00.2  ->  00:07.1

is different to

  config         physical     virtual
  01.00.2,0  ->  01:00.2  ->  00:07.0
             ->  01:00.0  ->  00:07.1

* Physical function 0 need not be present

e.g.

  config         physical     virtual
  01.00.1,2  ->  01:00.1  ->  00:07.0
             ->  01:00.2  ->  00:07.1

* Functions from the same physical multi-function device
may be exported as multiple multi-function and single-function devices

e.g.

  01.00.0,2  ->  01:00.0  ->  00:07.0
             ->  01:00.2  ->  00:07.1
  and
  01.00.1,3  ->  01:00.1  ->  00:08.1
             ->  01:00.3  ->  00:08.1

and
01.00.5 -> 01:00.5 -> 00:09.0

N.B: This is intended for testing and discussion,
it may well violate hardware constraints.

Cc Dexuan Cui <[email protected]>
Cc Masaki Kanno <[email protected]>
tools/python/xen/xm/main.py +11 -3
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
@@ -2222,9 +2222,17 @@ def xm_pci_list(args):
     if len(devs) == 0:
         return
 
-    devs.sort(None,
-              lambda x: (x['vdevfn'] - PCI_FUNC(x['vdevfn'])) << 32 |
-                        PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
+    def f(x):
+	# The vfunc shouldn't be used for ordering if the vslot hasn't been
+	# assigned as the output looks odd beacuse the vfunc isn't reported
+	# but the (physical) function is.
+	if x['vdevfn'] & AUTO_PHP_SLOT:
+	    vdevfn = AUTO_PHP_SLOT
+	else:
+	    vdevfn = x['vdevfn']
+        return (vdevfn << 32) | \
+	       PCI_BDF(x['domain'], x['bus'], x['slot'], x['func'])
+    devs.sort(None, f)
 
     has_vdevfn = False
     for x in devs:
tools/python/xen/util/pci.py +2 -7
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
@@ -293,19 +293,13 @@ def parse_pci_name_extended(pci_dev_str)
     # Virtual slot assignment takes place here if specified in the bdf,
     # else it is done inside qemu-xen, as it knows which slots are free
     pci = []
+    vfunc = 0;
     func_list = pci_func_list_process(pci_dev_str, template,
                                       pci_dev_info['func'])
     for func in func_list:
         pci_dev = template.copy()
         pci_dev['func'] = "0x%x" % func
 
-        if len(func_list) == 1:
-            # For single-function devices vfunc must be 0
-            vfunc = 0
-        else:
-            # For multi-function virtual devices,
-            # identity map the func to vfunc
-            vfunc = func
         if pci_dev_info['vdevfn'] == '':
             vdevfn = AUTO_PHP_SLOT | vfunc
         else:
@@ -313,6 +307,7 @@ def parse_pci_name_extended(pci_dev_str)
         pci_dev['vdevfn'] = "0x%02x" % vdevfn
 
         pci.append(pci_dev)
+        vfunc += 1
 
     # For pci attachment and detachment is it important that virtual
     # function 0 is done last. This is because is virtual function 0 that