stos: pmm: Add physical frame allocation
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -11,9 +11,20 @@
|
||||
|
||||
#include <stdef.h>
|
||||
|
||||
/* Page frame number */
|
||||
typedef UQUAD MM_PFN;
|
||||
|
||||
/*
|
||||
* Initialize the physical memory management
|
||||
*/
|
||||
VOID MmInitPmm(VOID);
|
||||
|
||||
/*
|
||||
* Request a single frame of memory
|
||||
*
|
||||
* Returns the page frame number on success, otherwise
|
||||
* zero on failure e.g., out of memory
|
||||
*/
|
||||
MM_PFN MmRequestFrame(VOID);
|
||||
|
||||
#endif /* !_MM_PMM_H_ */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <hal/page.h>
|
||||
#include <units.h>
|
||||
#include <stdef.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LOAD_DELAY 128
|
||||
|
||||
@@ -159,6 +160,22 @@ MmLoadUpdate(VOID)
|
||||
LoadIdx %= LoadMax;
|
||||
}
|
||||
|
||||
MM_PFN
|
||||
MmRequestFrame(VOID)
|
||||
{
|
||||
MM_PFD *Pfd;
|
||||
UPTR Pma;
|
||||
|
||||
Pfd = MmPfdPop(&PfdList);
|
||||
if (Pfd == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
RtlMemSet(Pfd, 0, PAGESIZE);
|
||||
Pma = VMA_TO_PMA(Pfd);
|
||||
return Pma >> LOG2_PAGESIZE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
MmProbeMemory(VOID)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user