stos: mm: Add virtual page allocation

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-23 09:52:44 +00:00
parent 333331171d
commit d337a3d55b
4 changed files with 224 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: VAD management
* Author: Chloe M.
*/
#ifndef _MM_VAD_H_
#define _MM_VAD_H_ 1
#include <stdef.h>
#define VAD_FROM_VMA(VMA) \
((MM_VAD *)(VMA))
/*
* A virtual address descriptor represents a specific
* page of memory.
*
* @Next: Next free page
* @Prev: Previous free page
*/
typedef struct _MM_VAD {
struct _MM_VAD *Next;
struct _MM_VAD *Prev;
} MM_VAD;
/*
* Represents a virtual address descriptor list
*
* @First: First entry in VAD list
* @Last: Last entry in VAD list
*/
typedef struct {
MM_VAD *First;
MM_VAD *Last;
} MM_VAD_LIST;
/*
* Append a VAD to VAD list
*
* @List: VAD list to append to
* @Vad: VAD list to append
*/
VOID MmVadListAppend(MM_VAD_LIST *List, MM_VAD *Vad);
/*
* Pop a VAD from a VAD list
*
* @List: VAD list to pop from
*
* Returns NULL if no more entries
*/
MM_VAD *MmVadListPop(MM_VAD_LIST *List);
#endif /* !_MM_VAD_H_ */
+9
View File
@@ -24,4 +24,13 @@
*/
VOID MmInitVmm(VOID);
/*
* Allocate a number of contiguous pages
*
* @Count: Number of pages to allocate
*
* Returns NULL on failure
*/
VOID *MmAllocPages(USIZE Count);
#endif /* !_MM_VMM_H_ */