New Page Map broken
Closed this issue · 43 comments
I finish 8th episode (https://www.youtube.com/watch?v=e47SApmmx44&list=PLxN4E629pPnJxCQCLy7E0SQY_zuumOVyZ&index=8) and Page Map don't work for me:
Please fix this problem in near future
What doesn't work with the page map?
Be more precise
Does your OS crash or does it do something special?
Nothing crash
I clone PonchoOS and works
Priting text don't work
so it crashes
this is a hint
I have this
I already told you where you should look in your code
I copying Poncho code
no
let me tell you what's the problem
I will keep my modifications
you're causing a page fault
do you know what is a page fault?
Problem is I cannot print text using new PageMap
let me explain to you what's happening ok?
you're causing a page fault that's crashing everything
do you know what's a page fault?
I watch Poncho episode, create new PageMap like Poncho. Poncho print's text using new PageMa, I cannot print text
I asked you something. If you don't listen to me, I won't help you
do you know what's a page fault?
I don't know where is fault
here
A Page Fault occurs when:
A page directory or table entry is not present in physical memory.
Attempting to load the instruction TLB with a translation for a non-executable page.
A protection check (privileges, read/write) failed. <- that's happening now
A reserved bit in the page directory or table entries is set to 1.
you're writing to privileged or inexistent memory
if you don't understand what I'm saying let me know
wanna tell you the fix?
Whatever you say, I can print now
you removed that chunk of code, right?
#include <stdint.h>
#include "BasicRenderer.h"
#include "cstr.h"
#include "efiMemory.h"
#include "memory.h"
#include "Bitmap.h"
#include "paging/PageFrameAllocator.h"
#include "paging/PageMapIndexer.h"
#include "paging/paging.h"
#include "paging/PageTableManager.h"
struct BootInfo {
Framebuffer* framebuffer;
PSF1_FONT* psf1_Font;
EFI_MEMORY_DESCRIPTOR* mMap;
uint64_t mMapSize;
uint64_t mMapDescSize;
} ;
extern uint64_t _KernelStart;
extern uint64_t _KernelEnd;
extern "C" void _start(BootInfo* bootInfo){
BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font);
//Welcome
newRenderer.Colour = 0xff00ffff;
newRenderer.CursorPosition = {0, 0};
newRenderer.Print("Welcome to ringOS!!");
newRenderer.Print(" ");
//Basic system info
newRenderer.Colour = 0xffffff00;
newRenderer.CursorPosition = {0, 16};
newRenderer.Print("Basic System Info:");
newRenderer.Print(" ");
newRenderer.Print("Width: ");
newRenderer.Print(to_string((uint64_t)bootInfo->framebuffer->Width));
newRenderer.Print(" | ");
newRenderer.Print("Height: ");
newRenderer.Print(to_string((uint64_t)bootInfo->framebuffer->Height));
newRenderer.Print(" | ");
newRenderer.Print("PixelsPerScanLine: ");
newRenderer.Print(to_string((uint64_t)bootInfo->framebuffer->PixelsPerScanLine));
newRenderer.Print(" | ");
uint64_t mMapEntries = bootInfo->mMapSize / bootInfo->mMapDescSize;
GlobalAllocator = PageFrameAllocator();
GlobalAllocator.ReadEFIMemoryMap(bootInfo->mMap, bootInfo->mMapSize, bootInfo->mMapDescSize);
uint64_t kernelSize = (uint64_t)&_KernelEnd - (uint64_t)&_KernelStart;
uint64_t kernelPages = (uint64_t)kernelSize / 4096 + 1;
GlobalAllocator.LockPages(&_KernelStart, kernelPages);
PageTable* PML4 = (PageTable*)GlobalAllocator.RequestPage();
memset(PML4, 0, 0x1000);
PageTableManager pageTableManager = PageTableManager(PML4);
for (uint64_t t = 0; t < GetMemorySize(bootInfo->mMap, mMapEntries, bootInfo->mMapDescSize); t+= 0x1000){
pageTableManager.MapMemory((void*)t, (void*)t);
}
uint64_t fbBase = (uint64_t)bootInfo->framebuffer->BaseAddress;
uint64_t fbSize = (uint64_t)bootInfo->framebuffer->BufferSize + 0x1000;
for (uint64_t t = fbBase; t < fbBase + fbSize; t += 4096){
pageTableManager.MapMemory((void*)t, (void*)t);
}
asm ("mov %0, %%cr3" : : "r" (PML4));
pageTableManager.MapMemory((void*)0x600000000, (void*)0x80000);
uint64_t* test = (uint64_t*)0x600000000;
*test = 26;
newRenderer.Print(to_string(*test));
return ;
}
My code
does it work?
Yes
ok
Thanks for help
ur welcome