mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Bug with heap ?
This commit is contained in:
parent
0fa7d46511
commit
36ce243b8c
@ -63,13 +63,15 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
|||||||
// Memory
|
// Memory
|
||||||
MmInitMemoryMap();
|
MmInitMemoryMap();
|
||||||
MmInitGdt();
|
MmInitGdt();
|
||||||
MmInitHeap();
|
|
||||||
MmInitPaging();
|
|
||||||
|
|
||||||
// IDT
|
// Interrupts
|
||||||
KeSetupIDT();
|
KeSetupIDT();
|
||||||
KeEnableIRQs();
|
KeEnableIRQs();
|
||||||
|
|
||||||
|
// Memory (2)
|
||||||
|
MmInitHeap();
|
||||||
|
MmInitPaging();
|
||||||
|
|
||||||
// Interrupt handlers
|
// Interrupt handlers
|
||||||
MmActivatePageHandler();
|
MmActivatePageHandler();
|
||||||
KeEnableRTC();
|
KeEnableRTC();
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <init/boot.h>
|
#include <init/boot.h>
|
||||||
#include <ke/idt.h>
|
#include <ke/idt.h>
|
||||||
#include <io/vga.h>
|
#include <io/vga.h>
|
||||||
#include <mm/mm.h>
|
|
||||||
#include <io/spkr.h>
|
#include <io/spkr.h>
|
||||||
|
|
||||||
IdtEntry_t idt[256] = { 0 };
|
IdtEntry_t idt[256] = { 0 };
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
|
|
||||||
volatile pml4_t MmPageMapLevel4[512] __attribute__((__aligned__(KPAGESIZE)));
|
static pml4_t MmPageMapLevel4[512] __attribute__((__aligned__(KPAGESIZE)));
|
||||||
|
static ulong *MmPhysicalPageTable;
|
||||||
|
|
||||||
extern ulong _text;
|
extern ulong _text;
|
||||||
extern ulong _text_end;
|
extern ulong _text_end;
|
||||||
@ -51,6 +52,7 @@ void MmInitPaging(void)
|
|||||||
ulong lastKernelAddr = (ulong)(_heap_start + _heap_max);
|
ulong lastKernelAddr = (ulong)(_heap_start + _heap_max);
|
||||||
ulong firstDirectoryAddr = 0;
|
ulong firstDirectoryAddr = 0;
|
||||||
ulong lastDirectoryAddr = 0;
|
ulong lastDirectoryAddr = 0;
|
||||||
|
ulong phDirSize = 0;
|
||||||
|
|
||||||
// Maximum PHYSICAL address in memory
|
// Maximum PHYSICAL address in memory
|
||||||
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
||||||
@ -64,6 +66,10 @@ void MmInitPaging(void)
|
|||||||
//DebugLog("\tPaging gap : %u MB (%p)\n\tLast virtual address %p\n", diffKernUsr / MB, diffKernUsr, MmVirtLastAddress);
|
//DebugLog("\tPaging gap : %u MB (%p)\n\tLast virtual address %p\n", diffKernUsr / MB, diffKernUsr, MmVirtLastAddress);
|
||||||
|
|
||||||
memzero((void *)&MmPageMapLevel4[0], sizeof(MmPageMapLevel4));
|
memzero((void *)&MmPageMapLevel4[0], sizeof(MmPageMapLevel4));
|
||||||
|
phDirSize = (phRamSize / KPAGESIZE)*sizeof(ulong);
|
||||||
|
|
||||||
|
//MmPhysicalPageTable = (ulong*)malloc((phRamSize / KPAGESIZE)*sizeof(ulong));
|
||||||
|
DebugLog("\t\tRam %u MB, pagesize %u KB, size %u MB\n", phRamSize / MB, KPAGESIZE / KB, phDirSize / MB);
|
||||||
|
|
||||||
for (ulong curAddrPML4 = 0;
|
for (ulong curAddrPML4 = 0;
|
||||||
curAddrPML4 < MmVirtLastAddress;
|
curAddrPML4 < MmVirtLastAddress;
|
||||||
@ -157,6 +163,7 @@ void MmInitPaging(void)
|
|||||||
// While we're inside the userspace pages
|
// While we're inside the userspace pages
|
||||||
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
|
||||||
|
//MmPhysicalPageTable[(ulong)curAddrPT - diffKernUsr] = 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);
|
||||||
@ -174,9 +181,9 @@ 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)/MB);
|
|
||||||
|
DebugLog("\tPage table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -221,7 +228,7 @@ void *MmTransVirtToPhyAddr(void* virtualAddr)
|
|||||||
|
|
||||||
void *MmTransPhyToVirtAddr(void* physicalAddr)
|
void *MmTransPhyToVirtAddr(void* physicalAddr)
|
||||||
{
|
{
|
||||||
return (void*)0;
|
return (void*)MmPhysicalPageTable[(ulong)physicalAddr];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -272,6 +279,28 @@ void MmUnmapPage(void* virtualAddr)
|
|||||||
KeFlushTlbSingle(*page);
|
KeFlushTlbSingle(*page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Kernel Page allocator
|
||||||
|
//
|
||||||
|
void *MmKAllocPageBlock(void *start) {
|
||||||
|
pte_t *startPage = MmGetPageDescriptorFromVirtual(start);
|
||||||
|
|
||||||
|
//for (ulong curPage = 0; curPage < )
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// User page allocator
|
||||||
|
//
|
||||||
|
void *MmUAllocPageBlock(void *start) {
|
||||||
|
pte_t *startPage = MmGetPageDescriptorFromVirtual(start);
|
||||||
|
|
||||||
|
//for (ulong curPage = 0; curPage < )
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user