1 /** 2 * \file 3 * \brief Simple list-based allocator. Taken from the Fiasco kernel. 4 * 5 * \date Alexander Warg <aw11os.inf.tu-dresden.de> 6 * Frank Mehnert <fm3@os.inf.tu-dresden.de> */ 7 8 /* 9 * (c) 2003-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>, 10 * Frank Mehnert <fm3@os.inf.tu-dresden.de> 11 * economic rights: Technische Universität Dresden (Germany) 12 * This file is part of TUD:OS and distributed under the terms of the 13 * GNU Lesser General Public License 2.1. 14 * Please see the COPYING-LGPL-2.1 file for details. 15 */ 16 17 #ifndef L4UTIL_L4LA_H 18 #define L4UTIL_L4LA_H 19 20 #include <l4/sys/l4int.h> 21 #include <l4/sys/compiler.h> 22 23 typedef struct l4la_free_t_s 24 { 25 struct l4la_free_t_s *next; 26 l4_size_t size; 27 } l4la_free_t; 28 29 #define L4LA_INITIALIZER { 0 } 30 31 EXTERN_C_BEGIN 32 33 /** Add free memory to memory pool. 34 * \param first list identifier 35 * \param block address of unused memory block 36 * \param size size of memory block */ 37 L4_CV void l4la_free(l4la_free_t **first, void *block, l4_size_t size); 38 39 /** Allocate memory from pool. 40 * \param first list identifier 41 * \param size length of memory block to allocate 42 * \param align alignment */ 43 L4_CV void* l4la_alloc(l4la_free_t **first, l4_size_t size, unsigned align); 44 45 /** Show all list members. 46 * \param first list identifier */ 47 L4_CV void l4la_dump(l4la_free_t **first); 48 49 /** Init memory pool. 50 * \param first list identifier */ 51 L4_CV void l4la_init(l4la_free_t **first); 52 53 /** Show available memory in pool. 54 * \param first list identifier */ 55 L4_CV l4_size_t l4la_avail(l4la_free_t **first); 56 57 EXTERN_C_END 58 59 #endif 60