Files
acrn-hypervisor/misc/config_tools/board_inspector/acpiparser/prt.py
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00

35 lines
1.1 KiB
Python

# Copyright (C) 2021 Intel Corporation.
#
# SPDX-License-Identifier: BSD-3-Clause
#
from collections import namedtuple
from .aml import datatypes, context
class PRTMappingPackage(namedtuple("PRTMappingPackage", ["address", "pin", "source", "source_index"])):
def __repr__(self):
if isinstance(self.source, context.DeviceDecl):
s = self.source.name
else:
s = str(self.source)
return "address=0x{0:08x}, pin=0x{1:02x}, source={2}, source_index=0x{3:08x}".format(
self.address, self.pin, s, self.source_index)
def parse_prt_mapping(x):
address = x.elements[0].get()
pin = x.elements[1].get()
source = x.elements[2]
if isinstance(source, datatypes.Device):
source = source.get_sym()
elif isinstance(source, datatypes.Integer):
source = source.get()
else:
source = "unknown"
source_index = x.elements[3].get()
return PRTMappingPackage(address, pin, source, source_index)
def parse_pci_routing(package):
"""Parse ACPI PCI routing table returned by _PRT control methods."""
return list(map(parse_prt_mapping, package.elements))