00001 #ifndef _GPXE_UMALLOC_H 00002 #define _GPXE_UMALLOC_H 00003 00004 /** 00005 * @file 00006 * 00007 * User memory allocation 00008 * 00009 */ 00010 00011 FILE_LICENCE ( GPL2_OR_LATER ); 00012 00013 #include <gpxe/api.h> 00014 #include <config/umalloc.h> 00015 #include <gpxe/uaccess.h> 00016 00017 /** 00018 * Provide a user memory allocation API implementation 00019 * 00020 * @v _prefix Subsystem prefix 00021 * @v _api_func API function 00022 * @v _func Implementing function 00023 */ 00024 #define PROVIDE_UMALLOC( _subsys, _api_func, _func ) \ 00025 PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func ) 00026 00027 /* Include all architecture-independent I/O API headers */ 00028 #include <gpxe/efi/efi_umalloc.h> 00029 00030 /* Include all architecture-dependent I/O API headers */ 00031 #include <bits/umalloc.h> 00032 00033 /** 00034 * Reallocate external memory 00035 * 00036 * @v userptr Memory previously allocated by umalloc(), or UNULL 00037 * @v new_size Requested size 00038 * @ret userptr Allocated memory, or UNULL 00039 * 00040 * Calling realloc() with a new size of zero is a valid way to free a 00041 * memory block. 00042 */ 00043 userptr_t urealloc ( userptr_t userptr, size_t new_size ); 00044 00045 /** 00046 * Allocate external memory 00047 * 00048 * @v size Requested size 00049 * @ret userptr Memory, or UNULL 00050 * 00051 * Memory is guaranteed to be aligned to a page boundary. 00052 */ 00053 static inline __always_inline userptr_t umalloc ( size_t size ) { 00054 return urealloc ( UNULL, size ); 00055 } 00056 00057 /** 00058 * Free external memory 00059 * 00060 * @v userptr Memory allocated by umalloc(), or UNULL 00061 * 00062 * If @c ptr is UNULL, no action is taken. 00063 */ 00064 static inline __always_inline void ufree ( userptr_t userptr ) { 00065 urealloc ( userptr, 0 ); 00066 } 00067 00068 #endif /* _GPXE_UMALLOC_H */
1.5.7.1