malloc.h

Go to the documentation of this file.
00001 #ifndef _GPXE_MALLOC_H
00002 #define _GPXE_MALLOC_H
00003 
00004 #include <stdint.h>
00005 
00006 /** @file
00007  *
00008  * Dynamic memory allocation
00009  *
00010  */
00011 
00012 FILE_LICENCE ( GPL2_OR_LATER );
00013 
00014 /*
00015  * Prototypes for the standard functions (malloc() et al) are in
00016  * stdlib.h.  Include <gpxe/malloc.h> only if you need the
00017  * non-standard functions, such as malloc_dma().
00018  *
00019  */
00020 #include <stdlib.h>
00021 
00022 extern size_t freemem;
00023 
00024 extern void * __malloc alloc_memblock ( size_t size, size_t align );
00025 extern void free_memblock ( void *ptr, size_t size );
00026 extern void mpopulate ( void *start, size_t len );
00027 extern void mdumpfree ( void );
00028 
00029 /**
00030  * Allocate memory for DMA
00031  *
00032  * @v size              Requested size
00033  * @v align             Physical alignment
00034  * @ret ptr             Memory, or NULL
00035  *
00036  * Allocates physically-aligned memory for DMA.
00037  *
00038  * @c align must be a power of two.  @c size may not be zero.
00039  */
00040 static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
00041         return alloc_memblock ( size, phys_align );
00042 }
00043 
00044 /**
00045  * Free memory allocated with malloc_dma()
00046  *
00047  * @v ptr               Memory allocated by malloc_dma(), or NULL
00048  * @v size              Size of memory, as passed to malloc_dma()
00049  *
00050  * Memory allocated with malloc_dma() can only be freed with
00051  * free_dma(); it cannot be freed with the standard free().
00052  *
00053  * If @c ptr is NULL, no action is taken.
00054  */
00055 static inline void free_dma ( void *ptr, size_t size ) {
00056         free_memblock ( ptr, size );
00057 }
00058 
00059 #endif /* _GPXE_MALLOC_H */

Generated on Tue Apr 6 20:01:08 2010 for gPXE by  doxygen 1.5.7.1