stos: pool: Add actual allocation groundwork
Still lots to do Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
+30
-1
@@ -13,9 +13,12 @@
|
||||
#include <stapi/status.h>
|
||||
#include <stdef.h>
|
||||
|
||||
/* Minimum log2 allocation size */
|
||||
#define POOL_MIN_LOG2 3
|
||||
|
||||
/* Compute the granularity of a specific level */
|
||||
#define LEVEL_GRAN(LEVEL) \
|
||||
(1 << (3 + (LEVEL)))
|
||||
(1 << (POOL_MIN_LOG2 + (LEVEL)))
|
||||
|
||||
/* Maximum levels per pool */
|
||||
#define LEVEL_COUNT 8
|
||||
@@ -28,6 +31,15 @@
|
||||
#define POOL_REAL_PAGESZ \
|
||||
(PAGESIZE - sizeof(MEMORY_PAGE))
|
||||
|
||||
/*
|
||||
* Valid pool types
|
||||
*
|
||||
* @POOL_NON_PAGED: Not pagable to disk
|
||||
*/
|
||||
typedef enum {
|
||||
POOL_NON_PAGED
|
||||
} POOL_TYPE;
|
||||
|
||||
/*
|
||||
* Page data structure used internally to link together page
|
||||
* lists
|
||||
@@ -58,9 +70,11 @@ typedef struct {
|
||||
* A memory pool holds blocks of varying granularities
|
||||
*
|
||||
* @BlockLevels: Block levels [granularity : GRAN(level)]
|
||||
* @Id: Pool ID
|
||||
*/
|
||||
typedef struct {
|
||||
MEMORY_BLOCK BlockLevels[LEVEL_COUNT];
|
||||
USIZE Id;
|
||||
} MEMORY_POOL;
|
||||
|
||||
/*
|
||||
@@ -70,4 +84,19 @@ typedef struct {
|
||||
*/
|
||||
ST_STATUS ExPoolInit(MEMORY_POOL *Pool);
|
||||
|
||||
/*
|
||||
* Allocate a tagged pool
|
||||
*
|
||||
* @Type: Pool type
|
||||
* @ByteCount: Number of bytes to allocate
|
||||
* @Tag: Tag to assign to pool
|
||||
*
|
||||
* Returns the memory base on success, otherwise
|
||||
* NULL on failure.
|
||||
*/
|
||||
VOID *ExAllocatePoolWithTag(
|
||||
POOL_TYPE Type, USIZE ByteCount,
|
||||
ULONG Tag
|
||||
);
|
||||
|
||||
#endif /* !_EX_POOL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user