iPXE
|
External memory allocation. More...
#include <limits.h>
#include <errno.h>
#include <ipxe/uaccess.h>
#include <ipxe/hidemem.h>
#include <ipxe/io.h>
#include <ipxe/memblock.h>
#include <ipxe/umalloc.h>
Go to the source code of this file.
Data Structures | |
struct | external_memory |
An external memory block. More... | |
Macros | |
#define | EM_MAX_ADDRESS 0xffffffffUL |
Maximum usable address for external allocated memory. More... | |
#define | EM_ALIGN ( 4 * 1024 ) |
Alignment of external allocated memory. More... | |
#define | UNOWHERE ( ~UNULL ) |
Equivalent of NOWHERE for user pointers. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
size_t | largest_memblock (userptr_t *start) |
Find largest usable memory region. More... | |
static void | init_eheap (void) |
Initialise external heap. More... | |
static void | ecollect_free (void) |
Collect free blocks. More... | |
static userptr_t | memtop_urealloc (userptr_t ptr, size_t new_size) |
Reallocate external memory. More... | |
PROVIDE_UMALLOC (memtop, urealloc, memtop_urealloc) | |
Variables | |
struct external_memory | __attribute__ |
static userptr_t | top = UNULL |
Top of heap. More... | |
static userptr_t | bottom = UNULL |
Bottom of heap (current lowest allocated block) More... | |
static size_t | heap_size |
Remaining space on heap. More... | |
External memory allocation.
Definition in file memtop_umalloc.c.
#define EM_MAX_ADDRESS 0xffffffffUL |
Maximum usable address for external allocated memory.
Definition at line 42 of file memtop_umalloc.c.
#define EM_ALIGN ( 4 * 1024 ) |
Alignment of external allocated memory.
Definition at line 45 of file memtop_umalloc.c.
#define UNOWHERE ( ~UNULL ) |
Equivalent of NOWHERE for user pointers.
Definition at line 48 of file memtop_umalloc.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Find largest usable memory region.
start | Start of region |
len | Length of region |
Definition at line 73 of file memtop_umalloc.c.
References memory_map::count, DBG, EM_MAX_ADDRESS, memory_region::end, get_memmap(), len, max, phys_to_user(), memory_map::regions, start, memory_region::start, and UNULL.
Referenced by init_eheap(), and initrd_startup().
|
static |
Initialise external heap.
Definition at line 121 of file memtop_umalloc.c.
References base, bottom, DBG, heap_size, largest_memblock(), top, user_to_phys(), and userptr_add().
Referenced by memtop_urealloc().
|
static |
Collect free blocks.
Definition at line 134 of file memtop_umalloc.c.
References bottom, copy_from_user(), DBG, heap_size, len, external_memory::size, top, external_memory::used, user_to_phys(), and userptr_add().
Referenced by memtop_urealloc().
Reallocate external memory.
old_ptr | Memory previously allocated by umalloc(), or UNULL |
new_size | Requested size |
new_ptr | Allocated memory, or UNULL |
Calling realloc() with a new size of zero is a valid way to free a memory block.
Definition at line 162 of file memtop_umalloc.c.
References align, bottom, copy_from_user(), copy_to_user(), DBG, ecollect_free(), EM_ALIGN, heap_size, hide_umalloc(), init_eheap(), memmove_user(), external_memory::size, top, UNOWHERE, UNULL, external_memory::used, user_to_phys(), and userptr_add().
PROVIDE_UMALLOC | ( | memtop | , |
urealloc | , | ||
memtop_urealloc | |||
) |
struct external_memory __attribute__ |
Top of heap.
Definition at line 59 of file memtop_umalloc.c.
Referenced by bzimage_load_initrds(), ecollect_free(), fbcon_init(), init_eheap(), initrd_reshuffle(), initrd_reshuffle_check(), initrd_squash_high(), and memtop_urealloc().
Bottom of heap (current lowest allocated block)
Definition at line 62 of file memtop_umalloc.c.
Referenced by bzimage_check_initrds(), ecollect_free(), fbcon_init(), init_eheap(), initrd_reshuffle(), initrd_reshuffle_check(), and memtop_urealloc().
|
static |
Remaining space on heap.
Definition at line 65 of file memtop_umalloc.c.
Referenced by ecollect_free(), init_eheap(), and memtop_urealloc().