diff options
author | Michael Brown <mcb30@ipxe.org> | 2010-07-21 11:58:50 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-07-21 11:58:50 +0100 |
commit | 9dc51afa2cc2b0d8310b540ae193edb37f148b8b (patch) | |
tree | 1817e78cec04265e272af45876d4f0b29f43a3f8 /src/include/ipxe/malloc.h | |
parent | 68613047f0f33f7afff1a3373f0ef40a2ba67acf (diff) | |
download | ipxe-9dc51afa2cc2b0d8310b540ae193edb37f148b8b.tar.gz |
[malloc] Add cache discard mechanism
Add a facility allowing cached data to be discarded in order to
satisfy memory allocations that would otherwise fail.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/malloc.h')
-rw-r--r-- | src/include/ipxe/malloc.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h index a1b656c84..e8136a3ce 100644 --- a/src/include/ipxe/malloc.h +++ b/src/include/ipxe/malloc.h @@ -18,6 +18,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); * */ #include <stdlib.h> +#include <ipxe/tables.h> extern size_t freemem; @@ -56,4 +57,20 @@ static inline void free_dma ( void *ptr, size_t size ) { free_memblock ( ptr, size ); } +/** A cache discarder */ +struct cache_discarder { + /** + * Discard some cached data + * + * @ret discarded Number of cached items discarded + */ + unsigned int ( * discard ) ( void ); +}; + +/** Cache discarder table */ +#define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" ) + +/** Declare a cache discarder */ +#define __cache_discarder __table_entry ( CACHE_DISCARDERS, 01 ) + #endif /* _IPXE_MALLOC_H */ |