def dump_psram(config): print("\t<RTCT>", file=config) rtct = None if os.path.exists("/sys/firmware/acpi/tables/PTCT"): rtct = parse_rtct(path="/sys/firmware/acpi/tables/PTCT") elif os.path.exists("/sys/firmware/acpi/tables/RTCT"): rtct = parse_rtct(path="/sys/firmware/acpi/tables/RTCT") if rtct: for entry in rtct.entries: if entry.type == acpiparser.rtct.ACPI_RTCT_TYPE_SoftwareSRAM: print("\t\t<SoftwareSRAM>", file=config) print("\t\t\t<cache_level>{}</cache_level>".format( entry.cache_level), file=config) print("\t\t\t<base>{}</base>".format(hex(entry.base)), file=config) print("\t\t\t<ways>{}</ways>".format(hex(entry.ways)), file=config) print("\t\t\t<size>{}</size>".format(hex(entry.size)), file=config) for apic_id in entry.apic_id_tbl: print("\t\t\t<apic_id>{}</apic_id>".format(hex(apic_id)), file=config) print("\t\t</SoftwareSRAM>", file=config) else: parser_lib.print_yel( "No PTCT or RTCT found. The platform may not support pseudo RAM.") print("\t</RTCT>", file=config) print("", file=config)
def extract_tcc_capabilities(caches_node): try: rtct = parse_rtct() if rtct.version == 1: for entry in rtct.entries: if entry.type == acpiparser.rtct.ACPI_RTCT_V1_TYPE_SoftwareSRAM: cache_node = get_node( caches_node, f"cache[@level='{entry.cache_level}' and processors/processor='{hex(entry.apic_id_tbl[0])}']" ) if cache_node is None: logging.warning( f"Cannot find the level {entry.cache_level} cache of physical processor with apic ID {entry.apic_id_tbl[0]}" ) continue cap = add_child(cache_node, "capability", None, id="Software SRAM") add_child(cap, "start", "0x{:08x}".format(entry.base)) add_child(cap, "end", "0x{:08x}".format(entry.base + entry.size - 1)) add_child(cap, "size", str(entry.size)) elif rtct.version == 2: for entry in rtct.entries: if entry.type == acpiparser.rtct.ACPI_RTCT_V2_TYPE_SoftwareSRAM: cache_node = get_node( caches_node, f"cache[@level='{entry.level}' and @id='{hex(entry.cache_id)}']" ) if cache_node is None: logging.warning( f"Cannot find the level {entry.level} cache with cache ID {entry.cache_id}" ) continue cap = add_child(cache_node, "capability", None, id="Software SRAM") add_child(cap, "start", "0x{:08x}".format(entry.base)) add_child(cap, "end", "0x{:08x}".format(entry.base + entry.size - 1)) add_child(cap, "size", str(entry.size)) except FileNotFoundError: pass