Files
Chloe M. 7ce1cf27d1 stos: mm: Add locking to VAD lists
Signed-off-by: Chloe M. <chloe@mensia.org>
2026-06-23 22:27:05 +00:00

61 lines
1.1 KiB
C

/*
* 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>
#include <ke/spinlock.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
* @Lock: Lock protecting this VAD list
*/
typedef struct {
MM_VAD *First;
MM_VAD *Last;
SPINLOCK Lock;
} 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_ */