ptos: Initialize per-processor pool regions
Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: Pool allocator
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#include <ex/pool.h>
|
||||
#include <ke/bugcheck.h>
|
||||
#include <mm/vm.h>
|
||||
#include <ptapi/status.h>
|
||||
|
||||
/*
|
||||
* Initialize a pool segment
|
||||
*
|
||||
* @Segment: Pool segment to initialize
|
||||
*/
|
||||
static PT_STATUS
|
||||
PoolSegmentInit(POOL_SEGMENT *Segment)
|
||||
{
|
||||
PT_STATUS Status;
|
||||
MM_RANGE Range;
|
||||
|
||||
if (Segment == NULL) {
|
||||
return STATUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
Status = MmAllocatePages(1, &Range);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Segment->PageCount = 1;
|
||||
Segment->LastPage = RANGE_PTR(&Range);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
ExPoolRegionInit(POOL_REGION *Region)
|
||||
{
|
||||
UCHAR Level;
|
||||
POOL_SEGMENT *Segment;
|
||||
PT_STATUS Status;
|
||||
|
||||
if (Region == NULL) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_UNBOUND_RESRC,
|
||||
"unbound region in ExPoolRegionInit()\n"
|
||||
);
|
||||
}
|
||||
|
||||
/* Initialize each segment level */
|
||||
for (Level = 0; Level < POOL_LEVEL_MAX; ++Level) {
|
||||
Segment = &Region->Level[Level];
|
||||
Status = PoolSegmentInit(Segment);
|
||||
|
||||
if (PT_ERROR(Status)) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_MISC,
|
||||
"failed to initialize segment level %d\n",
|
||||
Level
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user