diff options
author | Michael Brown | 2010-07-21 12:58:50 +0200 |
---|---|---|
committer | Michael Brown | 2010-07-21 12:58:50 +0200 |
commit | 9dc51afa2cc2b0d8310b540ae193edb37f148b8b (patch) | |
tree | 1817e78cec04265e272af45876d4f0b29f43a3f8 /src/include/ipxe/malloc.h | |
parent | [tcp] Handle out-of-order received packets (diff) | |
download | ipxe-9dc51afa2cc2b0d8310b540ae193edb37f148b8b.tar.gz ipxe-9dc51afa2cc2b0d8310b540ae193edb37f148b8b.tar.xz ipxe-9dc51afa2cc2b0d8310b540ae193edb37f148b8b.zip |
[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 a1b656c8..e8136a3c 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 */ |