def DSDT(val): table_dir = os.path.dirname(val) if not table_dir: table_dir = "." ssdt = filter(lambda x: x.startswith("SSDT"), os.listdir(table_dir)) tables = [val] + list(map(lambda x: os.path.join(table_dir, x), ssdt)) context = Context() trees = [] try: for t in tables: logging.info(f"Loading {t}") context.switch_stream(t) tree = Tree() AMLCode.parse(context, tree) tree = DeferredExpansion(context).transform_topdown(tree) tree = FlattenTransformer().transform_bottomup(tree) trees.append(tree) except Exception as e: context.current_stream.dump() raise context.skip_external_on_lookup() visitor = ConditionallyUnregisterSymbolVisitor( ConcreteInterpreter(context)) for tree in trees: visitor.visit_topdown(tree) return context
def extract(args, board_etree): devices_node = get_node(board_etree, "//devices") try: namespace = parse_dsdt() except Exception as e: logging.warning(f"Parse ACPI DSDT/SSDT failed: {str(e)}") logging.warning(f"Will not extract information from ACPI DSDT/SSDT") return interpreter = ConcreteInterpreter(namespace) # With IOAPIC, Linux kernel will choose APIC mode as the IRQ model. Evalaute the \_PIC method (if exists) to inform the ACPI # namespace of this. try: interpreter.interpret_method_call("\\_PIC", 1) except: logging.info(f"\\_PIC is not evaluated.") for device in sorted(namespace.devices, key=lambda x:x.name): try: fetch_device_info(devices_node, interpreter, device.name, args) except Exception as e: logging.info(f"Fetch information about device object {device.name} failed: {str(e)}") visitor = GenerateBinaryVisitor() for dev, objs in device_objects.items(): element = get_node(devices_node, f"//device[acpi_object='{dev}']") if element is not None: tree = builder.DefDevice( builder.PkgLength(), dev, builder.TermList(*list(objs.values()))) add_child(element, "aml_template", visitor.generate(tree).hex()) for dev, deps in device_deps.items(): element = get_node(devices_node, f"//device[acpi_object='{dev}']") if element is not None: for kind, targets in deps.items(): for target in targets: if dev != target: add_child(element, "dependency", target, type=kind)
def extract(board_etree): devices_node = get_node(board_etree, "//devices") try: namespace = parse_dsdt() except Exception as e: logging.info(f"Parse ACPI DSDT/SSDT failed: {str(e)}") logging.info(f"Will not extract information from ACPI DSDT/SSDT") return interpreter = ConcreteInterpreter(namespace) for device in sorted(namespace.devices, key=lambda x: x.name): try: fetch_device_info(devices_node, interpreter, device.name) except Exception as e: logging.info( f"Fetch information about device object {device.name} failed: {str(e)}" )