1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

some stuff enhancement

This commit is contained in:
Adrien Bourmault 2019-05-18 12:58:54 +02:00
parent 1213055aff
commit a389517877
2 changed files with 16 additions and 14 deletions

View File

@ -175,7 +175,7 @@ void KeSetupIDT(void)
// Load IDT
KeLoadIDT();
DebugLog("\tInterrupt table initialized\n");
DebugLog("\tInterrupt table initialized at %p\n", _KeIdtPtr.base);
}
//

View File

@ -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);
}