some stuff enhancement
This commit is contained in:
parent
1213055aff
commit
a389517877
|
@ -175,7 +175,7 @@ void KeSetupIDT(void)
|
|||
|
||||
// Load IDT
|
||||
KeLoadIDT();
|
||||
DebugLog("\tInterrupt table initialized\n");
|
||||
DebugLog("\tInterrupt table initialized at %p\n", _KeIdtPtr.base);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <ex/malloc.h>
|
||||
#include <mm/mm.h>
|
||||
|
||||
#define PAGESIZE (4 * KB)
|
||||
#define KPAGESIZE (4 * KB)
|
||||
#define UPAGESIZE (2 * MB)
|
||||
|
||||
|
||||
// Page directory pointer offset
|
||||
|
@ -39,13 +40,13 @@ enum
|
|||
|
||||
//-----------
|
||||
|
||||
volatile pdpe_t MmPML4[512] __attribute__((__aligned__(4096)));
|
||||
volatile pdpe_t MmPML4[512] __attribute__((__aligned__(KPAGESIZE)));
|
||||
|
||||
volatile pde_t MmPDP[512] __attribute__((__aligned__(4096)));
|
||||
volatile pde_t MmPDP[512] __attribute__((__aligned__(KPAGESIZE)));
|
||||
|
||||
volatile pde_t MmPD[512 * RAM_MAX] __attribute__((__aligned__(4096)));;
|
||||
volatile pde_t MmPD[512 * RAM_MAX] __attribute__((__aligned__(KPAGESIZE)));;
|
||||
|
||||
volatile pte_t MmPT[512 * NB_4K] __attribute__((__aligned__(4096)));;
|
||||
volatile pte_t MmPT[512 * NB_4K] __attribute__((__aligned__(KPAGESIZE)));;
|
||||
|
||||
volatile ulong MmStackGuards[2] = { 0 };
|
||||
|
||||
|
@ -63,25 +64,25 @@ void MmInitPaging(void)
|
|||
|
||||
for (volatile ulong i = 0; i < 512 * NB_4K; i++) {
|
||||
// STACK GUARD PAGE
|
||||
if ((ulong)(i*4096) == (ulong)BtLoaderInfo.stackEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*4096));
|
||||
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.stackEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE));
|
||||
MmStackGuards[0] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ENOMEM like
|
||||
if ((ulong)(i*4096) > (ulong)phRamSize) {
|
||||
if ((ulong)(i*KPAGESIZE) > (ulong)phRamSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
// STACK GARD PAGE
|
||||
if ((ulong)(i*4096) == (ulong)BtLoaderInfo.kernelEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*4096));
|
||||
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.kernelEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE));
|
||||
MmStackGuards[1] = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
MmPT[i] = ((ulong)(i*4096)) | MF_PRESENT | MF_READWRITE;
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
||||
for (volatile ulong i = 0; i < NB_4K; i++) {
|
||||
|
@ -90,12 +91,12 @@ void MmInitPaging(void)
|
|||
|
||||
for (volatile ulong i = NB_4K; i < 512 * RAM_MAX; i++) {
|
||||
// ENOMEM like
|
||||
if ((ulong)(i* 2048 * 1024) > (ulong)phRamSize) {
|
||||
if ((ulong)(i* UPAGESIZE) > (ulong)phRamSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
MmPD[i] = 0;
|
||||
MmPD[i] = ((ulong)(i* 2048 * 1024)) | MF_PRESENT | MF_READWRITE | MF_HUGE;
|
||||
MmPD[i] = ((ulong)(i* UPAGESIZE)) | MF_PRESENT | MF_READWRITE | MF_HUGE;
|
||||
}
|
||||
|
||||
for (volatile int i = 0; i < RAM_MAX; i++) {
|
||||
|
@ -105,4 +106,5 @@ void MmInitPaging(void)
|
|||
MmPML4[0] = (ulong)(&MmPDP[0])| MF_PRESENT | MF_READWRITE;
|
||||
|
||||
MmLoadPML4((void *)MmPML4);
|
||||
DebugLog("\tPaging table initialized at %p, %p, %p, %p\n", &MmPML4, &MmPDP, &MmPD, &MmPT);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue