mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Working static paging
This commit is contained in:
parent
bee9793a8b
commit
96dd593b88
@ -48,15 +48,13 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
||||
|
||||
// Memory
|
||||
MmInitMemoryMap();
|
||||
MmInitHeap();
|
||||
MmInitPaging();
|
||||
|
||||
// Interrupts launching
|
||||
KeSetupIDT();
|
||||
KeEnableIRQs();
|
||||
|
||||
// Several inits
|
||||
MmInitHeap();
|
||||
|
||||
// Start drivers
|
||||
KeEnableRTC();
|
||||
IoEnableKeyb();
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <kernel.h>
|
||||
#include <init/boot.h>
|
||||
#include <ex/malloc.h>
|
||||
#include <mm/mm.h>
|
||||
|
||||
#define PAGESIZE (4 * KB)
|
||||
|
||||
@ -32,7 +34,8 @@ enum
|
||||
};
|
||||
|
||||
#define RAM_MAX 16
|
||||
#define NB_4K 2
|
||||
#define NB_4K 150
|
||||
// * 2 MB
|
||||
|
||||
//-----------
|
||||
|
||||
@ -40,9 +43,9 @@ volatile pdpe_t MmPML4[512] __attribute__((__aligned__(4096)));
|
||||
|
||||
volatile pde_t MmPDP[512] __attribute__((__aligned__(4096)));
|
||||
|
||||
volatile pde_t MmPD[512 * RAM_MAX] __attribute__((__aligned__(4096)));
|
||||
volatile pde_t MmPD[512 * RAM_MAX] __attribute__((__aligned__(4096)));;
|
||||
|
||||
volatile pte_t MmPT[512 * NB_4K] __attribute__((__aligned__(4096)));
|
||||
volatile pte_t MmPT[512 * NB_4K] __attribute__((__aligned__(4096)));;
|
||||
|
||||
volatile ulong MmStackGuards[2] = { 0 };
|
||||
|
||||
@ -51,6 +54,8 @@ volatile ulong MmStackGuards[2] = { 0 };
|
||||
// Creates our new page table structure and loads it
|
||||
void MmInitPaging(void)
|
||||
{
|
||||
extern MemoryMap_t memoryMap;
|
||||
uint phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
||||
memzero((void *)&MmPML4[0], sizeof(MmPML4));
|
||||
memzero((void *)&MmPDP[0], sizeof(MmPDP));
|
||||
memzero((void *)&MmPD[0], sizeof(MmPD));
|
||||
@ -65,12 +70,9 @@ void MmInitPaging(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
// STACK PAGES
|
||||
if (
|
||||
(ulong)i*4096 < (ulong)BtLoaderInfo.stackEndAddr &&
|
||||
(ulong)i*4096 > (ulong)BtLoaderInfo.kernelEndAddr
|
||||
) {
|
||||
MmPT[i] = ((ulong)i * 4096) | MF_PRESENT | MF_READWRITE;// | MF_NX;
|
||||
// ENOMEM like
|
||||
if ((ulong)i*4096 > (ulong)phRamSize) {
|
||||
MmPT[i] = ((ulong)i * 4096) | MF_READWRITE;// | MF_NX;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -89,6 +91,12 @@ void MmInitPaging(void)
|
||||
}
|
||||
|
||||
for (int i = NB_4K; i < 512 * RAM_MAX; i++) {
|
||||
// ENOMEM like
|
||||
if ((ulong)i* 2048 * 1024 > (ulong)phRamSize) {
|
||||
MmPT[i] = ((ulong)i * 4096) | MF_READWRITE;// | MF_NX;
|
||||
continue;
|
||||
}
|
||||
|
||||
MmPD[i] = ((ulong)i * 2048 * 1024) | MF_PRESENT | MF_READWRITE | MF_HUGE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user