summaryrefslogtreecommitdiff
path: root/gpxe/src/include/gpxe/umalloc.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-12-12 14:36:02 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-12-14 13:56:44 -0800
commite2ab9215d792d07cfb725de290f416e331b87627 (patch)
tree7fbf2b3f921ef78b277f5d89c1a9a14960a49edc /gpxe/src/include/gpxe/umalloc.h
parent36390f9712ac56be1dce7a635322bd96e15620c1 (diff)
downloadsyslinux-e2ab9215d792d07cfb725de290f416e331b87627.tar.gz
gPXE: update to the "kkpxe" branchkkpxe
Update gPXE to the "kkpxe" branch, an experimental branch of the gPXE tree which should let us eliminate the gpxelinux-specific hacks. Specifically, this corresponds to checkin 0963c883a9402bd5846e687a100e196f7e8a2ef7 of git://git.etherboot.org/scm/people/mcb30/gpxe.git. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'gpxe/src/include/gpxe/umalloc.h')
-rw-r--r--gpxe/src/include/gpxe/umalloc.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/gpxe/src/include/gpxe/umalloc.h b/gpxe/src/include/gpxe/umalloc.h
index 49ec22b4..e6fc7bf0 100644
--- a/gpxe/src/include/gpxe/umalloc.h
+++ b/gpxe/src/include/gpxe/umalloc.h
@@ -8,10 +8,59 @@
*
*/
+#include <gpxe/api.h>
+#include <config/umalloc.h>
#include <gpxe/uaccess.h>
-extern userptr_t umalloc ( size_t size );
-extern userptr_t urealloc ( userptr_t ptr, size_t new_size );
-extern void ufree ( userptr_t ptr );
+/**
+ * Provide a user memory allocation API implementation
+ *
+ * @v _prefix Subsystem prefix
+ * @v _api_func API function
+ * @v _func Implementing function
+ */
+#define PROVIDE_UMALLOC( _subsys, _api_func, _func ) \
+ PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func )
+
+/* Include all architecture-independent I/O API headers */
+#include <gpxe/efi/efi_umalloc.h>
+
+/* Include all architecture-dependent I/O API headers */
+#include <bits/umalloc.h>
+
+/**
+ * Reallocate external memory
+ *
+ * @v userptr Memory previously allocated by umalloc(), or UNULL
+ * @v new_size Requested size
+ * @ret userptr Allocated memory, or UNULL
+ *
+ * Calling realloc() with a new size of zero is a valid way to free a
+ * memory block.
+ */
+userptr_t urealloc ( userptr_t userptr, size_t new_size );
+
+/**
+ * Allocate external memory
+ *
+ * @v size Requested size
+ * @ret userptr Memory, or UNULL
+ *
+ * Memory is guaranteed to be aligned to a page boundary.
+ */
+static inline __always_inline userptr_t umalloc ( size_t size ) {
+ return urealloc ( UNULL, size );
+}
+
+/**
+ * Free external memory
+ *
+ * @v userptr Memory allocated by umalloc(), or UNULL
+ *
+ * If @c ptr is UNULL, no action is taken.
+ */
+static inline __always_inline void ufree ( userptr_t userptr ) {
+ urealloc ( userptr, 0 );
+}
#endif /* _GPXE_UMALLOC_H */