From 065316ba1ec385a1b539a745583595ea83810919 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Mon, 9 Aug 2021 16:26:52 +0800 Subject: [PATCH] board-inspector: use the same _MIN and _MAX for 0-length regions It is typical in AML resource descriptors to have 0-length region descriptors which are typically templates of resources that are not assigned on the current platform. For such regions, the `base + length - 1` formula does not calculate the max of the region properly. This patch updates the resource descriptor parsers to use max = min when the length of the region is 0. Tracked-On: #6287 Signed-off-by: Junjie Mao --- misc/config_tools/board_inspector/extractors/50-acpi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/config_tools/board_inspector/extractors/50-acpi.py b/misc/config_tools/board_inspector/extractors/50-acpi.py index 5c970483c..1195cff10 100644 --- a/misc/config_tools/board_inspector/extractors/50-acpi.py +++ b/misc/config_tools/board_inspector/extractors/50-acpi.py @@ -86,13 +86,16 @@ def parse_irq(idx, item, elem): add_child(elem, "resource", id=f"res{idx}", type="irq", int=irqs) def parse_io_port(idx, item, elem): - add_child(elem, "resource", id=f"res{idx}", type="io_port", min=hex(item._MIN), max=hex(item._MAX), len=hex(item._LEN)) + add_child(elem, "resource", id=f"res{idx}", type="io_port", + min=hex(item._MIN), max=hex(item._MAX), len=hex(item._LEN)) def parse_fixed_io_port(idx, item, elem): - add_child(elem, "resource", id=f"res{idx}", type="io_port", min=hex(item._BAS), max=hex(item._BAS + item._LEN - 1), len=hex(item._LEN)) + add_child(elem, "resource", id=f"res{idx}", type="io_port", + min=hex(item._BAS), max=hex(item._BAS + item._LEN - 1 if item._LEN else 0), len=hex(item._LEN)) def parse_fixed_memory_range(idx, item, elem): - add_child(elem, "resource", id=f"res{idx}", type="memory", min=hex(item._BAS), max=hex(item._BAS + item._LEN - 1), len=hex(item._LEN)) + add_child(elem, "resource", id=f"res{idx}", type="memory", + min=hex(item._BAS), max=hex(item._BAS + item._LEN - 1 if item._LEN else 0), len=hex(item._LEN)) def parse_address_space_resource(idx, item, elem): if item._TYP == 0: