board_inspector: extract Compatible IDs of devices

In addition to the mandatory _HID (Hardware ID), the ACPI spec also defines
an optional _CID (Compatible ID) object for device identification.

This patch enhances the ACPI extractor by parsing the _CID objects of devices as
well.

Tracked-On: #6320
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2021-07-23 10:58:24 +08:00 committed by wenlingz
parent 879c6c11ca
commit 94d517b514
2 changed files with 22 additions and 1 deletions

View File

@ -142,11 +142,32 @@ def fetch_device_info(devices_node, interpreter, namepath):
else:
hid = "<unknown>"
# Compatible ID
cids = []
if interpreter.context.has_symbol(f"{namepath}._CID"):
cid_object = interpreter.interpret_method_call(f"{namepath}._CID")
if isinstance(cid_object, (datatypes.String, datatypes.Integer)):
cid_data = [cid_object]
elif isinstance(cid_object, datatypes.Package):
cid_data = cid_object.elements
for cid_datum in cid_data:
if isinstance(cid_datum, datatypes.Integer):
eisa_id = parse_eisa_id(cid_datum.get())
if eisa_id:
cids.append(eisa_id)
else:
cids.append(hex(cid_datum.get()))
elif isinstance(cid_datum, datatypes.String):
cids.append(cid_datum.get())
# Create the XML element for the device and create its ancestors if necessary
element = get_device_element(devices_node, namepath, hid)
if hid in buses.keys():
element.tag = "bus"
element.set("type", buses[hid])
for cid in cids:
add_child(element, "compatible_id", cid)
# Description
if interpreter.context.has_symbol(f"{namepath}._STR"):

View File

@ -23,7 +23,7 @@ def getkey(child):
return 0xFFFFFFFF
tags = ["vendor", "identifier", "subsystem_vendor", "subsystem_identifier", "class",
"acpi_object", "status",
"acpi_object", "compatible_id", "status",
"resource", "capability", "interrupt_pin_routing", "bus", "device"]
if child.tag == "resource":