mirror of
https://github.com/ipxe/ipxe
synced 2026-01-27 01:53:22 +03:00
[bios] Describe umalloc() heap as an in-use memory area
Use the concept of an in-use memory region defined as part of the system memory map API to describe the umalloc() heap. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -27,9 +27,4 @@ static inline unsigned int get_fbms ( void ) {
|
|||||||
|
|
||||||
extern void set_fbms ( unsigned int new_fbms );
|
extern void set_fbms ( unsigned int new_fbms );
|
||||||
|
|
||||||
/* Actually in hidemem.c, but putting it here avoids polluting the
|
|
||||||
* architecture-independent include/hidemem.h.
|
|
||||||
*/
|
|
||||||
extern void hide_basemem ( void );
|
|
||||||
|
|
||||||
#endif /* _BASEMEM_H */
|
#endif /* _BASEMEM_H */
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void int15_intercept ( int intercept );
|
extern void int15_intercept ( int intercept );
|
||||||
|
extern void hide_basemem ( void );
|
||||||
|
|
||||||
#endif /* _IPXE_INT15_H */
|
#endif /* _IPXE_INT15_H */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <realmode.h>
|
#include <realmode.h>
|
||||||
#include <bios.h>
|
#include <bios.h>
|
||||||
#include <basemem.h>
|
#include <basemem.h>
|
||||||
#include <ipxe/hidemem.h>
|
#include <ipxe/memmap.h>
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/init.h>
|
#include <ipxe/init.h>
|
||||||
#include <ipxe/io.h>
|
#include <ipxe/io.h>
|
||||||
#include <ipxe/memmap.h>
|
#include <ipxe/memmap.h>
|
||||||
#include <ipxe/hidemem.h>
|
|
||||||
|
|
||||||
/** Set to true if you want to test a fake E820 map */
|
/** Set to true if you want to test a fake E820 map */
|
||||||
#define FAKE_E820 0
|
#define FAKE_E820 0
|
||||||
@@ -118,15 +117,6 @@ void hide_basemem ( void ) {
|
|||||||
hidemem_base.start = ( get_fbms() * 1024 );
|
hidemem_base.start = ( get_fbms() * 1024 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide umalloc() region
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
|
||||||
assert ( end <= virt_to_phys ( _textdata ) );
|
|
||||||
hide_region ( &hidemem_umalloc, start, end );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide .text and .data
|
* Hide .text and .data
|
||||||
*
|
*
|
||||||
@@ -136,6 +126,26 @@ void hide_textdata ( void ) {
|
|||||||
virt_to_phys ( _etextdata ) );
|
virt_to_phys ( _etextdata ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronise in-use regions with the externally visible system memory map
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void int15_sync ( void ) {
|
||||||
|
physaddr_t start;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
/* Besides our fixed base memory and textdata regions, we
|
||||||
|
* support hiding only a single in-use memory region (the
|
||||||
|
* umalloc region), which must be placed before the hidden
|
||||||
|
* textdata region (even if zero-length).
|
||||||
|
*/
|
||||||
|
start = umalloc_used.start;
|
||||||
|
size = umalloc_used.size;
|
||||||
|
if ( ! size )
|
||||||
|
start = virt_to_phys ( _textdata );
|
||||||
|
hide_region ( &hidemem_umalloc, start, ( start + size ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set INT 15 interception flag
|
* Set INT 15 interception flag
|
||||||
*
|
*
|
||||||
@@ -172,8 +182,8 @@ static void hide_etherboot ( void ) {
|
|||||||
|
|
||||||
/* Initialise the hidden regions */
|
/* Initialise the hidden regions */
|
||||||
hide_basemem();
|
hide_basemem();
|
||||||
hide_umalloc ( virt_to_phys ( _textdata ), virt_to_phys ( _textdata ) );
|
|
||||||
hide_textdata();
|
hide_textdata();
|
||||||
|
int15_sync();
|
||||||
|
|
||||||
/* Some really moronic BIOSes bring up the PXE stack via the
|
/* Some really moronic BIOSes bring up the PXE stack via the
|
||||||
* UNDI loader entry point and then don't bother to unload it
|
* UNDI loader entry point and then don't bother to unload it
|
||||||
@@ -250,3 +260,5 @@ struct startup_fn hide_etherboot_startup_fn __startup_fn ( STARTUP_EARLY ) = {
|
|||||||
.startup = hide_etherboot,
|
.startup = hide_etherboot,
|
||||||
.shutdown = unhide_etherboot,
|
.shutdown = unhide_etherboot,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PROVIDE_MEMMAP ( int15, memmap_sync, int15_sync );
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ipxe/uaccess.h>
|
#include <ipxe/uaccess.h>
|
||||||
#include <ipxe/hidemem.h>
|
|
||||||
#include <ipxe/io.h>
|
#include <ipxe/io.h>
|
||||||
#include <ipxe/memblock.h>
|
#include <ipxe/memblock.h>
|
||||||
|
#include <ipxe/memmap.h>
|
||||||
#include <ipxe/umalloc.h>
|
#include <ipxe/umalloc.h>
|
||||||
|
|
||||||
/** Maximum usable address for external allocated memory */
|
/** Maximum usable address for external allocated memory */
|
||||||
@@ -62,6 +62,22 @@ static void *bottom = NULL;
|
|||||||
/** Remaining space on heap */
|
/** Remaining space on heap */
|
||||||
static size_t heap_size;
|
static size_t heap_size;
|
||||||
|
|
||||||
|
/** In-use memory region */
|
||||||
|
struct used_region umalloc_used __used_region = {
|
||||||
|
.name = "umalloc",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide umalloc() region
|
||||||
|
*
|
||||||
|
* @v start Start of region
|
||||||
|
* @v end End of region
|
||||||
|
*/
|
||||||
|
static void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
||||||
|
|
||||||
|
memmap_use ( &umalloc_used, start, ( end - start ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find largest usable memory region
|
* Find largest usable memory region
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef _IPXE_HIDEMEM_H
|
|
||||||
#define _IPXE_HIDEMEM_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* Hidden memory regions
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
extern void hide_umalloc ( physaddr_t start, physaddr_t end );
|
|
||||||
|
|
||||||
#endif /* _IPXE_HIDEMEM_H */
|
|
||||||
@@ -228,6 +228,8 @@ static inline void memmap_dump_all ( int hide ) {
|
|||||||
memmap_dump ( ®ion );
|
memmap_dump ( ®ion );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern struct used_region umalloc_used __used_region;
|
||||||
|
|
||||||
extern void memmap_update ( struct memmap_region *region, uint64_t start,
|
extern void memmap_update ( struct memmap_region *region, uint64_t start,
|
||||||
uint64_t size, unsigned int flags,
|
uint64_t size, unsigned int flags,
|
||||||
const char *name );
|
const char *name );
|
||||||
|
|||||||
Reference in New Issue
Block a user