From 7d689a5fae4f0950c8cb8e291744465ea5d2ca93 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 20 Oct 2009 17:26:27 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1242 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/heap.h | 4 ++-- os/kernel/include/memcore.h | 1 + os/kernel/include/mempools.h | 49 ++++++++++++++++---------------------------- 3 files changed, 21 insertions(+), 33 deletions(-) (limited to 'os/kernel/include') diff --git a/os/kernel/include/heap.h b/os/kernel/include/heap.h index 1f07faa91..aa2f7458e 100644 --- a/os/kernel/include/heap.h +++ b/os/kernel/include/heap.h @@ -19,8 +19,8 @@ /** * @file heap.h - * @brief Heap macros and structures. - * @addtogroup heap + * @brief Heaps macros and structures. + * @addtogroup heaps * @{ */ diff --git a/os/kernel/include/memcore.h b/os/kernel/include/memcore.h index c60d3ad9d..7c11e03c3 100644 --- a/os/kernel/include/memcore.h +++ b/os/kernel/include/memcore.h @@ -34,6 +34,7 @@ typedef void *align_t; /** * @brief Memory get function. + * * @note This type must be assignment compatible with the @p chMemAlloc() * function. */ diff --git a/os/kernel/include/mempools.h b/os/kernel/include/mempools.h index a458b8e34..553534dd3 100644 --- a/os/kernel/include/mempools.h +++ b/os/kernel/include/mempools.h @@ -40,12 +40,11 @@ struct pool_header { * @brief Memory pool descriptor. */ typedef struct { - struct pool_header *mp_next; /**< Pointer to the header. */ - size_t mp_object_size; /**< Memory pool objects size. */ -#if CH_USE_MEMCORE - bool_t mp_usecore; /**< Feed from the memory code - allocator if empty. */ -#endif + struct pool_header *mp_next; /**< @brief Pointer to the header. */ + size_t mp_object_size; /**< @brief Memory pool objects + size. */ + memgetfunc_t mp_provider; /**< @brief Memory blocks provider for + this pool. */ } MemoryPool; /** @@ -53,42 +52,30 @@ typedef struct { * @details This macro should be used when statically initializing a * memory pool that is part of a bigger structure. * - * @param name the name of the memory pool variable - * @param size size of the memory pool contained objects + * @param[in] name the name of the memory pool variable + * @param[in] size size of the memory pool contained objects + * @param[in] provider memory provider function for the memory pool */ -#if CH_USE_MEMCORE || defined(__DOXYGEN__) -#define _MEMORYPOOL_DATA(name, size) {NULL, MEM_ALIGN_SIZE(size), FALSE} -#else -#define _MEMORYPOOL_DATA(name, size) {NULL, MEM_ALIGN_SIZE(size)} -#endif +#define _MEMORYPOOL_DATA(name, size, provider) \ + {NULL, MEM_ALIGN_SIZE(size), provider} /** - * @brief Static memory pool initializer. + * @brief Static memory pool initializer in hungry mode. * @details Statically initialized memory pools require no explicit * initialization using @p chPoolInit(). * - * @param name the name of the memory pool variable - * @param size size of the memory pool contained objects - */ -#define MEMORYPOOL_DECL(name, size) \ - MemoryPool name = _MEMORYPOOL_DATA(name, size) - -#if CH_USE_MEMCORE || defined(__DOXYGEN__) -/** - * @brief Enables or disables the hungry mode. - * @details If enabled, the hungry mode, makes an empty memory pool feed - * new objects from the core memory manager. - * - * @param[in] mp pointer to a @p MemoryPool structure - * @param[in] mode hungry mode flag + * @param[in] name the name of the memory pool variable + * @param[in] size size of the memory pool contained objects + * @param[in] provider memory provider function for the memory pool or @p NULL + * if the pool is not allowed to grow automatically */ -#define chPoolSetHungryMode(mp, mode) ((mp)->mp_usecore = (mode)) -#endif +#define MEMORYPOOL_DECL(name, size, provider) \ + MemoryPool name = _MEMORYPOOL_DATA(name, size, provider) #ifdef __cplusplus extern "C" { #endif - void chPoolInit(MemoryPool *mp, size_t size); + void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider); void *chPoolAllocI(MemoryPool *mp); void *chPoolAlloc(MemoryPool *mp); void chPoolFreeI(MemoryPool *mp, void *objp); -- cgit v1.2.3