mirror of https://github.com/ipxe/ipxe.git
Fix the only bug (which was to use DBGC() in place of DBG()!) and add 4kB
alignment.pull/1/head
parent
132a8fe49d
commit
77b7640af4
|
@ -27,6 +27,9 @@
|
||||||
#include <gpxe/hidemem.h>
|
#include <gpxe/hidemem.h>
|
||||||
#include <gpxe/emalloc.h>
|
#include <gpxe/emalloc.h>
|
||||||
|
|
||||||
|
/** Alignment of external allocated memory */
|
||||||
|
#define EM_ALIGN ( 4 * 1024 )
|
||||||
|
|
||||||
/** Equivalent of NOWHERE for user pointers */
|
/** Equivalent of NOWHERE for user pointers */
|
||||||
#define UNOWHERE ( ~UNULL )
|
#define UNOWHERE ( ~UNULL )
|
||||||
|
|
||||||
|
@ -80,6 +83,7 @@ static void ecollect_free ( void ) {
|
||||||
userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
|
userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
|
||||||
struct external_memory extmem;
|
struct external_memory extmem;
|
||||||
userptr_t new = ptr;
|
userptr_t new = ptr;
|
||||||
|
size_t align;
|
||||||
|
|
||||||
/* Initialise external memory allocator if necessary */
|
/* Initialise external memory allocator if necessary */
|
||||||
if ( ! bottom )
|
if ( ! bottom )
|
||||||
|
@ -93,7 +97,7 @@ userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
|
||||||
} else {
|
} else {
|
||||||
/* Create a zero-length block */
|
/* Create a zero-length block */
|
||||||
ptr = bottom = userptr_add ( bottom, -sizeof ( extmem ) );
|
ptr = bottom = userptr_add ( bottom, -sizeof ( extmem ) );
|
||||||
DBGC ( "EXTMEM allocating [%lx,%lx)\n",
|
DBG ( "EXTMEM allocating [%lx,%lx)\n",
|
||||||
user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) );
|
user_to_phys ( ptr, 0 ), user_to_phys ( ptr, 0 ) );
|
||||||
extmem.size = 0;
|
extmem.size = 0;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +107,9 @@ userptr_t erealloc ( userptr_t ptr, size_t new_size ) {
|
||||||
if ( ptr == bottom ) {
|
if ( ptr == bottom ) {
|
||||||
/* Update block */
|
/* Update block */
|
||||||
new = userptr_add ( ptr, - ( new_size - extmem.size ) );
|
new = userptr_add ( ptr, - ( new_size - extmem.size ) );
|
||||||
|
align = ( user_to_phys ( new, 0 ) & ( EM_ALIGN - 1 ) );
|
||||||
|
new_size += align;
|
||||||
|
new = userptr_add ( new, -align );
|
||||||
DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n",
|
DBG ( "EXTMEM expanding [%lx,%lx) to [%lx,%lx)\n",
|
||||||
user_to_phys ( ptr, 0 ),
|
user_to_phys ( ptr, 0 ),
|
||||||
user_to_phys ( ptr, extmem.size ),
|
user_to_phys ( ptr, extmem.size ),
|
||||||
|
|
Loading…
Reference in New Issue