ptos: vad: Add VAD insertions and create VALLOC VADs
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: Virtual address descriptor management
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#include <mm/vad.h>
|
||||
|
||||
/* Prototypes */
|
||||
static LONG VadCmp(MM_VAD *V0, MM_VAD *V1);
|
||||
|
||||
/* RBT generation */
|
||||
RB_PROTOTYPE(VadTree, _MM_VAD, TreeLink, VadCmp);
|
||||
RB_GENERATE(VadTree, _MM_VAD, TreeLink, VadCmp);
|
||||
|
||||
static LONG
|
||||
VadCmp(MM_VAD *V0, MM_VAD *V1)
|
||||
{
|
||||
MM_RANGE *Range0, *Range1;
|
||||
|
||||
Range0 = &V0->Range;
|
||||
Range1 = &V1->Range;
|
||||
|
||||
return (Range0->VirtualBase < Range1->VirtualBase)
|
||||
? -1
|
||||
: Range0->VirtualBase > Range1->VirtualBase;
|
||||
}
|
||||
|
||||
VOID
|
||||
MmVadTreeInit(MM_VAD_TREE *Tree)
|
||||
{
|
||||
if (Tree == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tree->Elements = 0;
|
||||
RB_INIT(&Tree->Head);
|
||||
}
|
||||
|
||||
PT_STATUS
|
||||
MmVadTreeInsert(MM_VAD_TREE *Tree, MM_VAD *Vad)
|
||||
{
|
||||
if (Tree == NULL || Vad == NULL) {
|
||||
return STATUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
RB_INSERT(VadTree, &Tree->Head, Vad);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user