From: Michael Brown Date: Fri, 16 May 2025 17:04:27 +0000 (+0100) Subject: [bios] Use memmap_describe() to find an external heap location X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=624d76e26d544f5517237c5e2524634cf901e01e;p=thirdparty%2Fipxe.git [bios] Use memmap_describe() to find an external heap location Signed-off-by: Michael Brown --- diff --git a/src/arch/x86/interface/pcbios/memtop_umalloc.c b/src/arch/x86/interface/pcbios/memtop_umalloc.c index 99d8f1460..3348263a5 100644 --- a/src/arch/x86/interface/pcbios/memtop_umalloc.c +++ b/src/arch/x86/interface/pcbios/memtop_umalloc.c @@ -34,7 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include #include #include @@ -85,35 +84,34 @@ static void hide_umalloc ( physaddr_t start, physaddr_t end ) { * @ret len Length of region */ size_t largest_memblock ( void **start ) { - struct memory_map memmap; - struct memory_region *region; + struct memmap_region region; physaddr_t max = EM_MAX_ADDRESS; physaddr_t region_start; physaddr_t region_end; size_t region_len; - unsigned int i; size_t len = 0; /* Avoid returning uninitialised data on error */ *start = NULL; /* Scan through all memory regions */ - get_memmap ( &memmap ); - for ( i = 0 ; i < memmap.count ; i++ ) { - region = &memmap.regions[i]; - DBG ( "Considering [%llx,%llx)\n", region->start, region->end ); + for_each_memmap ( ®ion, 1 ) { /* Truncate block to maximum physical address */ - if ( region->start > max ) { - DBG ( "...starts after maximum address %lx\n", max ); - continue; + memmap_dump ( ®ion ); + if ( region.addr > max ) { + DBGC ( ®ion, "...starts after maximum address " + "%lx\n", max ); + break; } - region_start = region->start; - if ( region->end > max ) { - DBG ( "...end truncated to maximum address %lx\n", max); + region_start = region.addr; + if ( ! memmap_is_usable ( ®ion ) ) + continue; + region_end = ( region_start + memmap_size ( ®ion ) ); + if ( region_end > max ) { + DBGC ( ®ion, "...end truncated to maximum address " + "%lx\n", max); region_end = 0; /* =max, given the wraparound */ - } else { - region_end = region->end; } region_len = ( region_end - region_start );