Working on page allocator (3) #67
This commit is contained in:
parent
6a054a4b67
commit
459ed7c5b5
|
@ -31,7 +31,15 @@
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
typedef struct AllocatedPage_t{
|
||||||
|
void *phyAddress;
|
||||||
|
ulong id;
|
||||||
|
struct AllocatedPage_t *next;
|
||||||
|
} AllocatedPage_t;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
error_t MmGetFreePageFrame(void **framePtr, size_t *pageNumber, size_t size);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ void MmInitPaging(void)
|
||||||
ulong lastDirectoryAddr = 0;
|
ulong lastDirectoryAddr = 0;
|
||||||
ulong phDirSize = 0;
|
ulong phDirSize = 0;
|
||||||
|
|
||||||
|
KernLog("\tActivating paging...\n");
|
||||||
|
|
||||||
// Maximum PHYSICAL address in memory
|
// Maximum PHYSICAL address in memory
|
||||||
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ void MmInitPaging(void)
|
||||||
lastDirectoryAddr = (ulong)MmPT;
|
lastDirectoryAddr = (ulong)MmPT;
|
||||||
|
|
||||||
MmLoadPML4((void *)MmPageMapLevel4);
|
MmLoadPML4((void *)MmPageMapLevel4);
|
||||||
//MmEnableWriteProtect();
|
MmEnableWriteProtect();
|
||||||
|
|
||||||
DebugLog("\tPage table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
DebugLog("\tPage table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
||||||
}
|
}
|
||||||
|
@ -415,5 +417,5 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||||
void MmActivatePageHandler(void)
|
void MmActivatePageHandler(void)
|
||||||
{
|
{
|
||||||
KeRegisterISR(PagingHandler, 0xe);
|
KeRegisterISR(PagingHandler, 0xe);
|
||||||
DebugLog("\tPaging activated\n");
|
//DebugLog("\tPage handler activated\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,22 +37,35 @@ enum
|
||||||
Whatever2 = 1UL << 62
|
Whatever2 = 1UL << 62
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
static AllocatedPage_t busyPagesList = { (void*)0, 0, (AllocatedPage_t*)0 };
|
||||||
void **FramePtr;
|
|
||||||
int pageNumber;
|
|
||||||
} FramePtr_t;
|
|
||||||
|
|
||||||
//---------
|
//---------
|
||||||
|
|
||||||
|
static bool MmIsPageBusy(void *phyAddr) {
|
||||||
|
AllocatedPage_t *busyPage = &busyPagesList;
|
||||||
|
bool isBusy = false;
|
||||||
|
|
||||||
|
while(busyPage->next) {
|
||||||
|
busyPages = busyPage->next;
|
||||||
|
DebugLog("Busy page at %p\n", busyPage->phyAddress);
|
||||||
|
|
||||||
|
if (phyPageAddr == busyPage->phyAddress) {
|
||||||
|
isBusy = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isBusy;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Returns a structure that describes a pageframe
|
// Returns a structure that describes a pageframe
|
||||||
//
|
//
|
||||||
/* FramePtr_t MmAllocPageBlock(size_t size) { */
|
error_t MmGetFreePageFrame(void **framePtr, size_t *pageNumber, size_t size) {
|
||||||
/* ulong pageNumber = (ulong)size / KPAGESIZE; */
|
*pageNumber = (ulong)size / KPAGESIZE;
|
||||||
|
|
||||||
|
return EOK;
|
||||||
/* return (FramePtr_t)0; */
|
}
|
||||||
/* } */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <vers.h>
|
#include <vers.h>
|
||||||
#include <mm/paging.h>
|
#include <mm/paging.h>
|
||||||
|
#include <mm/palloc.h>
|
||||||
#include <mm/map.h>
|
#include <mm/map.h>
|
||||||
#include <io/ata.h>
|
#include <io/ata.h>
|
||||||
#include <io/vga.h>
|
#include <io/vga.h>
|
||||||
|
@ -256,9 +257,10 @@ error_t CmdPageBlock(int argc, char **argv, char *cmdline)
|
||||||
size_t size = (size_t)atoi(argv[1]);
|
size_t size = (size_t)atoi(argv[1]);
|
||||||
bool usermode = (bool)atoi(argv[2]);
|
bool usermode = (bool)atoi(argv[2]);
|
||||||
|
|
||||||
//MmGetPhyPageBlock(size, usermode);
|
size_t pageNum = 0;
|
||||||
|
|
||||||
return EOK;
|
error_t err = MmGetFreePageFrame((void**)0x12345678, &pageNum, (size_t)4096);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_t CmdPF(int argc, char **argv, char *cmdline)
|
error_t CmdPF(int argc, char **argv, char *cmdline)
|
||||||
|
|
Loading…
Reference in New Issue