mirror of
https://github.com/ipxe/ipxe
synced 2026-01-28 03:28:36 +03:00
[bios] Use memmap_describe() to find an external heap location
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -34,7 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ipxe/uaccess.h>
|
||||
#include <ipxe/io.h>
|
||||
#include <ipxe/memblock.h>
|
||||
#include <ipxe/memmap.h>
|
||||
#include <ipxe/umalloc.h>
|
||||
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user