From 9d7e9002ec99b7c96d76981ba425bf8e4ddc0d13 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Mon, 13 Jul 2026 21:53:14 +0000 Subject: [PATCH] ptos: ex: Add pool allocator header groundwork Signed-off-by: Chloe M. --- service/ptos/head/ex/pool.h | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 service/ptos/head/ex/pool.h diff --git a/service/ptos/head/ex/pool.h b/service/ptos/head/ex/pool.h new file mode 100644 index 0000000..61ca137 --- /dev/null +++ b/service/ptos/head/ex/pool.h @@ -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 + +/* 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_ */