From 5fc983af8b20d69279f819efef2b340565d0e9a3 Mon Sep 17 00:00:00 2001 From: Alex Bennée Date: Fri, 25 Feb 2022 17:20:20 +0000 Subject: semihosting/arm-compat: replace heuristic for softmmu SYS_HEAPINFO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous numbers were a guess at best and rather arbitrary without taking into account anything that might be loaded. Instead of using guesses based on the state of registers implement a new function that: a) scans the MemoryRegions for the largest RAM block b) iterates through all "ROM" blobs looking for the biggest gap The "ROM" blobs include all code loaded via -kernel and the various -device loader techniques. Signed-off-by: Alex Bennée Cc: Andrew Strauss Cc: Keith Packard Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220225172021.3493923-18-alex.bennee@linaro.org> --- include/hw/loader.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/hw/loader.h b/include/hw/loader.h index 4fa485bd61..5572108ba5 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -343,4 +343,18 @@ int rom_add_option(const char *file, int32_t bootindex); * overflow on real hardware too. */ #define UBOOT_MAX_GUNZIP_BYTES (64 << 20) +typedef struct RomGap { + hwaddr base; + size_t size; +} RomGap; + +/** + * rom_find_largest_gap_between: return largest gap between ROMs in given range + * + * Given a range of addresses, this function finds the largest + * contiguous subrange which has no ROMs loaded to it. That is, + * it finds the biggest gap which is free for use for other things. + */ +RomGap rom_find_largest_gap_between(hwaddr base, size_t size); + #endif -- cgit 1.4.1