diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index ca479f1..aab43d1 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -33,11 +33,14 @@ #include #include #include +#include + +static uInt32 freePages = 0; +static spinLock_t vmmSpinLock = SPIN_LOCK_INITIALIZER; -mMap *vmmMemoryMap = (mMap *) 0x101000; int numPages = 0x0; -uInt32 freePages = 0; +mMap *vmmMemoryMap = (mMap *) 0x101000; /************************************************************************ @@ -185,6 +188,8 @@ if (pid < sysID) { kpanic("Error: invalid PID\n"); } + + spinLock(&vmmSpinLock); for (i = 0; i <= numPages; i++) { @@ -197,6 +202,7 @@ vmmMemoryMap[i].pid = pid; freePages--; systemVitals->freePages = freePages; + spinUnlock(&vmmSpinLock); return (vmmMemoryMap[i].pageAddr); } } @@ -218,6 +224,8 @@ ************************************************************************/ int freePage(uInt32 pageAddr) { int pageIndex = 0x0; + + spinLock(&vmmSpinLock); /* Find The Page Index To The Memory Map */ pageIndex = (pageAddr / 4096); @@ -234,7 +242,7 @@ /* Adjust The COW Counter */ adjustCowCounter(((uInt32) vmmMemoryMap[pageIndex].pageAddr), -1); } - + spinUnlock(&vmmSpinLock); /* Return */ return (0); } @@ -253,7 +261,7 @@ ************************************************************************/ int adjustCowCounter(uInt32 baseAddr, int adjustment) { int vmmMemoryMapIndex = (baseAddr / 4096); - + //spinLock(&vmmSpinLock); /* Adjust COW Counter */ vmmMemoryMap[vmmMemoryMapIndex].cowCounter += adjustment; @@ -267,7 +275,7 @@ vmmMemoryMap[vmmMemoryMapIndex].pid = vmmID; freePages++; } - + //spinUnlock(&vmmSpinLock); /* Return */ return (0); } @@ -287,7 +295,7 @@ int i=0,x=0; uInt32 *tmpPageTable = 0x0; uInt32 *tmpPageDir = (uInt32 *)parentPageDirAddr; - + //spinLock(&vmmSpinLock); /* Check Page Directory For An Avail Page Table */ for (i=0;i<=0x300;i++) { if (tmpPageDir[i] != 0) { @@ -314,13 +322,21 @@ freePages++; systemVitals->freePages = freePages; } + else { + kprintf("."); + } } } /* Return */ + //spinUnlock(&vmmSpinLock); + return; } /*** $Log$ + Revision 1.6 2004/06/14 12:20:54 reddawg + notes: many bugs repaired and ld works 100% now. + Revision 1.5 2004/05/21 15:34:23 reddawg Fixed a couple of typo