ptos: mm: Protect PFDs with lock
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
+11
-2
@@ -9,6 +9,7 @@
|
||||
#include <mm/pm.h>
|
||||
#include <mm/vm.h>
|
||||
#include <ke/bpal.h>
|
||||
#include <ke/spinlock.h>
|
||||
#include <ex/trace.h>
|
||||
#include <string.h>
|
||||
#include <units.h>
|
||||
@@ -54,14 +55,16 @@ typedef struct _MM_PFD {
|
||||
* descriptors and marks the start and end of a physical
|
||||
* memory freelist.
|
||||
*
|
||||
* @First: First entry in freelist
|
||||
* @Last: Last entry in freelist
|
||||
* @First: First entry in freelist
|
||||
* @Last: Last entry in freelist
|
||||
* @Lock: Protects this list
|
||||
*
|
||||
* TODO: Add a lock to this structure
|
||||
*/
|
||||
typedef struct {
|
||||
MM_PFD *First;
|
||||
MM_PFD *Last;
|
||||
SPINLOCK Lock;
|
||||
} MM_PFD_LIST;
|
||||
|
||||
/* Standard usable memory list */
|
||||
@@ -222,7 +225,10 @@ MmRequestFrame(VOID)
|
||||
MM_PFD *Pfd;
|
||||
UPTR PhysicalBase;
|
||||
|
||||
KeSpinLockAcquire(&AvlList.Lock, true);
|
||||
Pfd = PmPfdListPop(&AvlList);
|
||||
KeSpinLockRelease(&AvlList.Lock);
|
||||
|
||||
if (Pfd == NULL) {
|
||||
return PFN_ERROR;
|
||||
}
|
||||
@@ -242,14 +248,17 @@ MmReclaimFrame(MM_PFN Pfn)
|
||||
return;
|
||||
}
|
||||
|
||||
KeSpinLockAcquire(&AvlList.Lock, true);
|
||||
PhysicalBase = PFN_TO_ADDRESS(Pfn);
|
||||
Pfd = (VOID *)PMA_TO_VMA(PhysicalBase);
|
||||
PmPfdListAppend(&AvlList, Pfd);
|
||||
KeSpinLockRelease(&AvlList.Lock);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmPmInit(VOID)
|
||||
{
|
||||
KeSpinLockInit(&AvlList.Lock, "pmm.avllock");
|
||||
DTRACE("probing physical memory...\n");
|
||||
PmProbe();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user