ptos: ex: Add pool allocator header groundwork
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: Pool allocator
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#ifndef _EX_POOL_H_
|
||||
#define _EX_POOL_H_ 1
|
||||
|
||||
#include <ptdef.h>
|
||||
|
||||
/* Maximum levels per region */
|
||||
#define POOL_LEVEL_MAX 8
|
||||
|
||||
/* Minimum log2 granularity */
|
||||
#define POOL_MIN_LOG2 3
|
||||
|
||||
/* Compute the granularity at a specific level */
|
||||
#define POOL_LEVEL_GRAN(X) \
|
||||
(1 << ((X) + POOL_MIN_LOG2))
|
||||
|
||||
/*
|
||||
* A pool page represents a single allocatable
|
||||
* unit within a pool segment.
|
||||
*
|
||||
* @Bitmap: Bitmap within pool page
|
||||
* @Next: Next page within list
|
||||
*/
|
||||
typedef struct _POOL_PAGE {
|
||||
UQUAD Bitmap;
|
||||
struct _POOL_PAGE *Next;
|
||||
} POOL_PAGE;
|
||||
|
||||
/*
|
||||
* A pool segment represents a list of pages at a specific
|
||||
* granularity.
|
||||
*
|
||||
* @LastPage: Last page in segment
|
||||
* @PageCount: Number of pages in this segment
|
||||
*/
|
||||
typedef struct {
|
||||
POOL_PAGE *LastPage;
|
||||
USIZE PageCount;
|
||||
} POOL_SEGMENT;
|
||||
|
||||
/*
|
||||
* A pool region represents a whole area in which several
|
||||
* pool levels can reside.
|
||||
*
|
||||
* @Level: Segment levels
|
||||
*/
|
||||
typedef struct {
|
||||
POOL_SEGMENT Level[POOL_LEVEL_MAX];
|
||||
} POOL_REGION;
|
||||
|
||||
#endif /* !_EX_POOL_H_ */
|
||||
Reference in New Issue
Block a user