tools: don't exclude device-tree reserved memory

... from the device UT listed by platform_gen. The kernel itself
does not care about this memory, and it is just given as device UT.

We also just remove the reserved array entirely from the return of
`get_physical_memory` since it only seems to be a footgun, it's
only used internally to affect what memory the kernel wants to use.

Co-authored-by: Kent McLeod <kent@kry10.com>
Signed-off-by: julia <git.ts@trainwit.ch>
This commit is contained in:
julia
2025-10-16 17:02:38 +11:00
committed by Indan Zupancic
parent 97b25da8b1
commit f9eb65c9a5
4 changed files with 9 additions and 11 deletions

View File

@@ -212,7 +212,7 @@ def run(tree: FdtParser, hw_yaml: HardwareYaml, config: Config, kernel_config_di
if not args.header_out: if not args.header_out:
raise ValueError('You need to specify a header-out to use c header output') raise ValueError('You need to specify a header-out to use c header output')
physical_memory, reserved, physBase = hardware.utils.memory.get_physical_memory(tree, config) physical_memory, physBase = hardware.utils.memory.get_physical_memory(tree, config)
kernel_regions, kernel_macros = get_kernel_devices(tree, hw_yaml, kernel_config_dict) kernel_regions, kernel_macros = get_kernel_devices(tree, hw_yaml, kernel_config_dict)
create_c_header_file( create_c_header_file(

View File

@@ -56,10 +56,9 @@ def run(tree: FdtParser, hw_yaml: HardwareYaml, config: Config,
if not args.json_out: if not args.json_out:
raise ValueError('you need to provide a json-out to use the JSON output method') raise ValueError('you need to provide a json-out to use the JSON output method')
phys_mem, reserved, _ = hardware.utils.memory.get_physical_memory(tree, config) phys_mem, _ = hardware.utils.memory.get_physical_memory(tree, config)
kernel_devs = get_kernel_devices(tree, hw_yaml, kernel_config_dict) kernel_devs = get_kernel_devices(tree, hw_yaml, kernel_config_dict)
dev_mem = hardware.utils.memory.get_addrspace_exclude( dev_mem = hardware.utils.memory.get_addrspace_exclude(phys_mem + kernel_devs, config)
list(reserved) + phys_mem + kernel_devs, config)
create_json_file(dev_mem, phys_mem, args.json_out) create_json_file(dev_mem, phys_mem, args.json_out)

View File

@@ -61,10 +61,9 @@ def run(tree: FdtParser, hw_yaml: HardwareYaml, config: Config,
if not args.yaml_out: if not args.yaml_out:
raise ValueError('you need to provide a yaml-out to use the yaml output method') raise ValueError('you need to provide a yaml-out to use the yaml output method')
phys_mem, reserved, _ = hardware.utils.memory.get_physical_memory(tree, config) phys_mem, _ = hardware.utils.memory.get_physical_memory(tree, config)
kernel_devs = get_kernel_devices(tree, hw_yaml, kernel_config_dict) kernel_devs = get_kernel_devices(tree, hw_yaml, kernel_config_dict)
dev_mem = hardware.utils.memory.get_addrspace_exclude( dev_mem = hardware.utils.memory.get_addrspace_exclude(phys_mem + kernel_devs, config)
list(reserved) + phys_mem + kernel_devs, config)
create_yaml_file(dev_mem, phys_mem, args.yaml_out) create_yaml_file(dev_mem, phys_mem, args.yaml_out)

View File

@@ -4,7 +4,7 @@
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
# #
from typing import List, Set from typing import List, Set, Tuple
import hardware import hardware
from hardware.config import Config from hardware.config import Config
@@ -83,7 +83,7 @@ def reserve_regions(regions: Set[Region], reserved: Set[Region]) -> Set[Region]:
return ret return ret
def align_memory(regions: Set[Region], config: Config) -> List[Region]: def align_memory(regions: Set[Region], config: Config) -> Tuple[List[Region], int]:
''' Given a set of regions, sort them and align the first so that the ''' Given a set of regions, sort them and align the first so that the
ELF loader will be able to load the kernel into it. Will return the ELF loader will be able to load the kernel into it. Will return the
aligned memory region list, a set of any regions of memory that were aligned memory region list, a set of any regions of memory that were
@@ -99,14 +99,14 @@ def align_memory(regions: Set[Region], config: Config) -> List[Region]:
return ret, physBase return ret, physBase
def get_physical_memory(tree: FdtParser, config: Config) -> List[Region]: def get_physical_memory(tree: FdtParser, config: Config) -> Tuple[List[Region], int]:
''' returns a list of regions representing physical memory as used by the kernel ''' ''' returns a list of regions representing physical memory as used by the kernel '''
regions = merge_memory_regions(get_memory_regions(tree)) regions = merge_memory_regions(get_memory_regions(tree))
reserved = parse_reserved_regions(tree.get_path('/reserved-memory')) reserved = parse_reserved_regions(tree.get_path('/reserved-memory'))
regions = reserve_regions(regions, reserved) regions = reserve_regions(regions, reserved)
regions, physBase = align_memory(regions, config) regions, physBase = align_memory(regions, config)
return regions, reserved, physBase return regions, physBase
def get_addrspace_exclude(regions: List[Region], config: Config): def get_addrspace_exclude(regions: List[Region], config: Config):