Files
PluralTechnology/service/ptos/head/ex/pool.h
T
2026-07-13 18:35:39 -04:00

66 lines
1.2 KiB
C

/*
* 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;
/*
* Initialize a pool region
*
* @Region: Pool region to initialize
*/
VOID ExPoolRegionInit(POOL_REGION *Region);
#endif /* !_EX_POOL_H_ */