From 9dc51afa2cc2b0d8310b540ae193edb37f148b8b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 21 Jul 2010 11:58:50 +0100 Subject: [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 --- src/include/ipxe/malloc.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/include/ipxe/malloc.h') 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 +#include 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 */ -- cgit v1.2.3-55-g7522