Blob Blame History Raw
From 54d6169eeaf46b220ca9a30f82cce282a304a456 Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Mon, 9 Jul 2018 17:46:39 +1000
Subject: [PATCH 05/10] Avoid very long IDE programming interface names as
 capabilities

Recent versions of the PCIID database added programming interface names
for IDE controllers, like this:

	01  IDE interface
		00  ISA Compatibility mode-only controller
		05  PCI native mode-only controller
		0a  ISA Compatibility mode controller, supports both channels switched to PCI native mode
		0f  PCI native mode controller, supports both channels switched to ISA compatibility mode
		80  ISA Compatibility mode-only controller, supports bus mastering
		85  PCI native mode-only controller, supports bus mastering
		8a  ISA Compatibility mode controller, supports both channels switched to PCI native mode, supports bus mastering
		8f  PCI native mode controller, supports both channels switched to ISA compatibility mode, supports bus mastering

resulting in an awkwardly named capability for the IDE controller:

    <capabilities>
     <capability id="ide" />
     <capability id="pci_native_mode_controller__supports_both_channels_switched_to_isa_compatibility_mode__supports_bus_mastering" />
     <capability id="bus_master" >bus mastering</capability>
    </capabilities>

This patch adds a special case for IDE controllers to avoid using the
programming interface name as a capability. Instead, separate
capabilities are added for the possible combinations:

    <capabilities>
     <capability id="ide" />
     <capability id="isa_compat_mode" >ISA compatibility mode</capability>
     <capability id="pci_native_mode" >PCI native mode</capability>
     <capability id="bus_master" >bus mastering</capability>
    </capabilities>

---
 src/core/pci.cc | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/core/pci.cc b/src/core/pci.cc
index 30359cc..8d60b2a 100644
--- a/src/core/pci.cc
+++ b/src/core/pci.cc
@@ -965,7 +965,21 @@ static hwNode *scan_pci_dev(struct pci_dev &d, hwNode & n)
           }
           device->setDescription(get_class_description(dclass));
 
-          if (moredescription != ""
+          if (dclass == PCI_CLASS_STORAGE_IDE)
+          {
+            // IDE programming interface names are really long and awkward,
+            // so don't add them as capabilities
+            if (progif == 0x00 || progif == 0x80)
+              device->addCapability("isa_compat_mode", "ISA compatibility mode");
+            else if (progif == 0x05 || progif == 0x85)
+              device->addCapability("pci_native_mode", "PCI native mode");
+            else if (progif == 0x0a || progif == 0x0f || progif == 0x8a || progif == 0x8f)
+            {
+              device->addCapability("isa_compat_mode", "ISA compatibility mode");
+              device->addCapability("pci_native_mode", "PCI native mode");
+            }
+          }
+          else if (moredescription != ""
             && moredescription != device->getDescription())
           {
             device->addCapability(moredescription);
-- 
2.17.1