Finally Fix Paging!
This commit is contained in:
parent
082eb0554d
commit
7adc6757e8
@ -11,7 +11,6 @@ Reboot:
|
||||
in al, 0x64
|
||||
test al, 0x02
|
||||
jnz Reboot
|
||||
|
||||
mov al, 0xFC
|
||||
out 0x64, al
|
||||
|
||||
@ -42,11 +41,6 @@ Write_CR3:
|
||||
mov ebp, esp
|
||||
mov eax, [ebp+8]
|
||||
mov cr3, eax
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
retn
|
||||
|
||||
global Enable_Paging
|
||||
Enable_Paging:
|
||||
mov eax, cr4
|
||||
or eax, 0x00000010
|
||||
mov cr4, eax
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
void __attribute__((cdecl)) Reboot();
|
||||
unsigned long __attribute__((cdecl)) Read_CR0();
|
||||
void __attribute__((cdecl)) Write_CR0(unsigned long value);
|
||||
unsigned long* __attribute__((cdecl)) Read_CR3();
|
||||
void __attribute__((cdecl)) Write_CR3(unsigned long* value);
|
||||
void __attribute__((cdecl)) Enable_Paging();
|
||||
uint32_t __attribute__((cdecl)) Read_CR0();
|
||||
void __attribute__((cdecl)) Write_CR0(uint32_t value);
|
||||
uint32_t* __attribute__((cdecl)) Read_CR3();
|
||||
void __attribute__((cdecl)) Write_CR3(uint32_t* value);
|
||||
|
||||
@ -12,29 +12,28 @@
|
||||
|
||||
extern uint16_t DEBUG_COM_PORT;
|
||||
|
||||
unsigned long* Page_Directory = (unsigned long*) 0x9C000;
|
||||
unsigned long* Page_Table = (unsigned long*) 0x9D000;
|
||||
uint32_t Page_Directory[1024] __attribute__((aligned(4096)));
|
||||
uint32_t Page_Table[1024] __attribute__((aligned(4096)));
|
||||
|
||||
void Memory_Page_Init()
|
||||
{
|
||||
unsigned long address = 0;
|
||||
unsigned int i;
|
||||
unsigned int PDi;
|
||||
|
||||
Serial_Printf(DEBUG_COM_PORT, "MEMORY:> Mapping First 4MB of Memory.\n");
|
||||
for(i=0; i<1024; i++) {
|
||||
Page_Table[i] = address | 3;
|
||||
address = address + 4096; // 4096 = 4kb
|
||||
Serial_Printf(DEBUG_COM_PORT, "MEMORY:> Inititalizing Memory Paging\n");
|
||||
// Set entries to not Present
|
||||
for(PDi=0; PDi<1024; PDi++) {
|
||||
Page_Directory[PDi] = 0x00000002;
|
||||
}
|
||||
Serial_Printf(DEBUG_COM_PORT, "MEMORY:> Inititalizing Page Directory and Table.\n");
|
||||
// Set R/W + Supervisor Flags For Table
|
||||
unsigned int PTi;
|
||||
for(PTi=0; PTi<1024; PTi++) {
|
||||
Page_Table[PTi] = (PTi * 0x1000) | 3;
|
||||
}
|
||||
// Add Table to Directory & Set R/W Supervisor
|
||||
Page_Directory[0] = ((unsigned int)Page_Table) | 3;
|
||||
|
||||
// fill the first entry of the page directory
|
||||
Page_Directory[0] = *Page_Table;
|
||||
Page_Directory[0] = Page_Directory[0] | 3; // attribute set to: supervisor level, read/write
|
||||
for(i=1; i<1024; i++) {
|
||||
Page_Directory[i] = 0 | 2; // attribute set to: supervisor level, read/write
|
||||
}
|
||||
// Enable_Paging();
|
||||
// Enable Paging
|
||||
Write_CR3(Page_Directory);
|
||||
Write_CR0(Read_CR0() | 0x60000001); // set the paging bit in CR0 to 1
|
||||
/* Holy Shit i Fixed Paging */
|
||||
Write_CR0(Read_CR0() | 0x80000000);
|
||||
}
|
||||
@ -6,4 +6,4 @@
|
||||
#pragma once
|
||||
|
||||
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
|
||||
#define VERSION "RD-00051"
|
||||
#define VERSION "RD-00052"
|
||||
Loading…
x
Reference in New Issue
Block a user