Working on Paging API #67
This commit is contained in:
parent
40cd623b97
commit
3bce4c6208
|
@ -173,7 +173,7 @@ void MmInitPaging(void)
|
||||||
else if ((ulong)curAddrPT >= USERSPACE) {
|
else if ((ulong)curAddrPT >= USERSPACE) {
|
||||||
MmPT[index] = ((ulong)curAddrPT - diffKernUsr) | PRESENT; // Not present for instance
|
MmPT[index] = ((ulong)curAddrPT - diffKernUsr) | PRESENT; // Not present for instance
|
||||||
xedni = (((ulong)curAddrPT - diffKernUsr) / ((ulong)KPAGESIZE));
|
xedni = (((ulong)curAddrPT - diffKernUsr) / ((ulong)KPAGESIZE));
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
//MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
|
|
||||||
if ((ulong)curAddrPT == USERSPACE) {
|
if ((ulong)curAddrPT == USERSPACE) {
|
||||||
DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr);
|
DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr);
|
||||||
|
@ -295,44 +295,48 @@ void MmUnmapPage(void* virtualAddr)
|
||||||
//
|
//
|
||||||
// Find a free block of pages
|
// Find a free block of pages
|
||||||
//
|
//
|
||||||
void *MmGetPhyPageBlock(size_t size, bool usermode) {
|
/* void *MmGetPhyPageBlock(size_t size, bool usermode) { */
|
||||||
void *startPhyPage = 0;
|
/* void *startPhyPage = 0; */
|
||||||
void *endPhyPage = 0;
|
/* void *endPhyPage = 0; */
|
||||||
size_t curSize = 0;
|
/* ulong offset = 0; */
|
||||||
|
/* size_t curSize = 0; */
|
||||||
|
|
||||||
// Maximum PHYSICAL address in memory
|
/* // Maximum PHYSICAL address in memory */
|
||||||
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
/* ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; */
|
||||||
|
|
||||||
ulong curVirtAddr = 0;
|
/* ulong curVirtAddr = 0; */
|
||||||
|
|
||||||
if (!usermode) {
|
/* if (!usermode) { */
|
||||||
startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE + 1);
|
/* startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE); */
|
||||||
endPhyPage = (void*)MmPhysLastKernAddress;
|
/* endPhyPage = (void*)MmPhysLastKernAddress; */
|
||||||
} else {
|
/* offset = 0; */
|
||||||
startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE);
|
/* } else { */
|
||||||
endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1));
|
/* startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); */
|
||||||
}
|
/* endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); */
|
||||||
|
/* offset = (ulong)USERSPACE - MmPhysLastKernAddress - KPAGESIZE; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
DebugLog("Start phy at %p\n", startPhyPage);
|
/* DebugLog("Start phy at %p\n", startPhyPage); */
|
||||||
DebugLog("End phy at %p\n", endPhyPage);
|
/* DebugLog("End phy at %p\n", endPhyPage); */
|
||||||
|
|
||||||
for (ulong curPhyAddr = (ulong)startPhyPage;
|
/* for (ulong curPhyAddr = (ulong)startPhyPage; */
|
||||||
curPhyAddr <= (ulong)endPhyPage;
|
/* curPhyAddr <= (ulong)endPhyPage; */
|
||||||
curPhyAddr += KPAGESIZE) {
|
/* curPhyAddr += KPAGESIZE) { */
|
||||||
curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr);
|
/* curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr); */
|
||||||
|
|
||||||
if (curVirtAddr == 0) {
|
|
||||||
DebugLog("CurrentAddr %p\n", curVirtAddr);
|
|
||||||
DebugLog("\t Free !\n");
|
|
||||||
curSize += KPAGESIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curSize >= size)
|
/* if (curVirtAddr == 0) { */
|
||||||
break;
|
/* DebugLog("CurrentAddr %p\n", curPhyAddr); */
|
||||||
}
|
/* DebugLog("\t Free !\n"); */
|
||||||
|
/* curSize += KPAGESIZE; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
return NULL;
|
/* if (curSize >= size) */
|
||||||
}
|
/* break; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* return NULL; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue