1 #ifndef _GPXE_UMALLOC_H
2 #define _GPXE_UMALLOC_H
7 * User memory allocation
12 #include <config/umalloc.h>
13 #include <gpxe/uaccess.h>
16 * Provide a user memory allocation API implementation
18 * @v _prefix Subsystem prefix
19 * @v _api_func API function
20 * @v _func Implementing function
22 #define PROVIDE_UMALLOC( _subsys, _api_func, _func ) \
23 PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func )
25 /* Include all architecture-independent I/O API headers */
26 #include <gpxe/efi/efi_umalloc.h>
28 /* Include all architecture-dependent I/O API headers */
29 #include <bits/umalloc.h>
32 * Reallocate external memory
34 * @v userptr Memory previously allocated by umalloc(), or UNULL
35 * @v new_size Requested size
36 * @ret userptr Allocated memory, or UNULL
38 * Calling realloc() with a new size of zero is a valid way to free a
41 userptr_t
urealloc ( userptr_t userptr
, size_t new_size
);
44 * Allocate external memory
46 * @v size Requested size
47 * @ret userptr Memory, or UNULL
49 * Memory is guaranteed to be aligned to a page boundary.
51 static inline __always_inline userptr_t
umalloc ( size_t size
) {
52 return urealloc ( UNULL
, size
);
56 * Free external memory
58 * @v userptr Memory allocated by umalloc(), or UNULL
60 * If @c ptr is UNULL, no action is taken.
62 static inline __always_inline
void ufree ( userptr_t userptr
) {
63 urealloc ( userptr
, 0 );
66 #endif /* _GPXE_UMALLOC_H */