[comboot] Use memmap_describe() to obtain available memory

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-15 23:45:55 +01:00
parent d0adf3b4cc
commit dbc86458e5

View File

@@ -39,7 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/image.h> #include <ipxe/image.h>
#include <ipxe/segment.h> #include <ipxe/segment.h>
#include <ipxe/init.h> #include <ipxe/init.h>
#include <ipxe/io.h> #include <ipxe/memmap.h>
#include <ipxe/console.h> #include <ipxe/console.h>
/** /**
@@ -49,8 +49,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @ret rc Return status code * @ret rc Return status code
*/ */
static int com32_exec_loop ( struct image *image ) { static int com32_exec_loop ( struct image *image ) {
struct memory_map memmap; struct memmap_region region;
unsigned int i;
int state; int state;
uint32_t avail_mem_top; uint32_t avail_mem_top;
@@ -59,21 +58,12 @@ static int com32_exec_loop ( struct image *image ) {
switch ( state ) { switch ( state ) {
case 0: /* First time through; invoke COM32 program */ case 0: /* First time through; invoke COM32 program */
/* Get memory map */
get_memmap ( &memmap );
/* Find end of block covering COM32 image loading area */ /* Find end of block covering COM32 image loading area */
for ( i = 0, avail_mem_top = 0 ; i < memmap.count ; i++ ) { memmap_describe ( COM32_START_PHYS, 1, &region );
if ( (memmap.regions[i].start <= COM32_START_PHYS) && assert ( memmap_is_usable ( &region ) );
(memmap.regions[i].end > COM32_START_PHYS + image->len) ) { avail_mem_top = ( COM32_START_PHYS + memmap_size ( &region ) );
avail_mem_top = memmap.regions[i].end;
break;
}
}
DBGC ( image, "COM32 %p: available memory top = 0x%x\n", DBGC ( image, "COM32 %p: available memory top = 0x%x\n",
image, avail_mem_top ); image, avail_mem_top );
assert ( avail_mem_top != 0 ); assert ( avail_mem_top != 0 );
/* Hook COMBOOT API interrupts */ /* Hook COMBOOT API interrupts */