]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: config create: do not use the class file of pci devs anymore
authorHenning Schild <henning.schild@siemens.com>
Tue, 27 Jan 2015 14:05:30 +0000 (15:05 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 1 Feb 2015 11:47:10 +0000 (12:47 +0100)
The class file just contains the classcode. Since we started also using
the file containing the whole PCI config space we might as well get the
class information from there and copy/access less input files.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/jailhouse-config-create

index ed7db33513ac905ac3ec208115e1316180d944ac..e870d562d73be9d869f6884e9351d631f8403a19 100755 (executable)
@@ -77,7 +77,6 @@ inputs['files'].add('/proc/cpuinfo')
 inputs['files'].add('/proc/cmdline')
 inputs['files'].add('/proc/ioports')
 inputs['files'].add('/sys/bus/pci/devices/*/config')
-inputs['files'].add('/sys/bus/pci/devices/*/class')
 inputs['files'].add('/sys/devices/system/cpu/cpu*/uevent')
 inputs['files'].add('/sys/firmware/acpi/tables/APIC')
 inputs['files'].add('/sys/firmware/acpi/tables/MCFG')
@@ -254,8 +253,11 @@ class PCIDevice:
     @staticmethod
     def parse_pcidevice_sysfsdir(basedir, dir):
         dpath = os.path.join(basedir, dir)
-        dclass = input_readline(os.path.join(dpath, 'class'))
-        if re.match(r'0x0604..', dclass):
+        f = input_open(os.path.join(dpath, 'config'), 'rb')
+        f.seek(0x0A)
+        (classcode,) = struct.unpack('<H', f.read(2))
+        f.close()
+        if classcode == 0x0604:
             type = 'JAILHOUSE_PCI_TYPE_BRIDGE'
         else:
             type = 'JAILHOUSE_PCI_TYPE_DEVICE'
@@ -492,7 +494,7 @@ def parse_pcidevices():
     devices = []
     caps = []
     basedir = '/sys/bus/pci/devices'
-    list = input_listdir(basedir, ['*/class', '*/config'])
+    list = input_listdir(basedir, ['*/config'])
     for dir in list:
         d = PCIDevice.parse_pcidevice_sysfsdir(basedir, dir)
         if d is not None: