Memory Paging Stuff
This commit is contained in:
parent
cbefa0c30c
commit
2838108c6e
@ -8,7 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
void __attribute__((cdecl)) Reboot();
|
||||
void __attribute__((cdecl)) Read_CR0();
|
||||
void __attribute__((cdecl)) Write_CR0(uint8_t value);
|
||||
void __attribute__((cdecl)) Read_CR3();
|
||||
void __attribute__((cdecl)) Write_CR3(uint8_t value);
|
||||
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);
|
||||
|
||||
@ -5,5 +5,34 @@
|
||||
\*----------------*/
|
||||
#include "page.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <dri/serial.h>
|
||||
#include <arch/i686/util.h>
|
||||
|
||||
extern uint16_t DEBUG_COM_PORT;
|
||||
|
||||
unsigned long* Page_Directory = (unsigned long*) 0x9c000;
|
||||
unsigned long* Page_Table = (unsigned long*) 0x9d000
|
||||
unsigned long* Page_Table = (unsigned long*) 0x9d000;
|
||||
|
||||
void Memory_Page_Init()
|
||||
{
|
||||
unsigned long address = 0;
|
||||
unsigned int i;
|
||||
|
||||
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 Page Directory and Table.\n");
|
||||
|
||||
// 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
|
||||
}
|
||||
Write_CR3(Page_Directory);
|
||||
Write_CR0(Read_CR0() | 0x80000000); // set the paging bit in CR0 to 1
|
||||
}
|
||||
@ -3,4 +3,6 @@
|
||||
|Copyright (C) 2024|
|
||||
|Tyler McGurrin |
|
||||
\*----------------*/
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
void Memory_Page_Init();
|
||||
@ -73,4 +73,10 @@ int Slave_FDD_Detect()
|
||||
i++;
|
||||
}
|
||||
return FDDType;
|
||||
}
|
||||
|
||||
int uptime;
|
||||
void CPU_Timer()
|
||||
{
|
||||
uptime++;
|
||||
}
|
||||
@ -8,6 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
void CMOS_RTC_Handler();
|
||||
void CPU_Timer();
|
||||
int Master_FDD_Detect();
|
||||
int Slave_FDD_Detect();
|
||||
uint8_t Read_CMOS(uint8_t Register);
|
||||
|
||||
@ -16,27 +16,17 @@
|
||||
#include <dri/disk/floppy.h>
|
||||
#include <dri/disk/ata.h>
|
||||
#include <core/hal/hal.h>
|
||||
#include <core/memory/page.h>
|
||||
#include <util/param.h>
|
||||
#include <util/util.h>
|
||||
#include "../libs/version.h"
|
||||
#include "../libs/boot/bootparams.h"
|
||||
|
||||
#define PS2_KEYBOARD_PORT 0x60
|
||||
|
||||
extern uint8_t __bss_start;
|
||||
extern uint8_t __end;
|
||||
|
||||
uint16_t DEBUG_COM_PORT = COM1_PORT;
|
||||
|
||||
int uptime;
|
||||
void timer(Registers* regs)
|
||||
{
|
||||
uptime++;
|
||||
// printf("%d", uptime);
|
||||
// movecursorpos(8,14);
|
||||
}
|
||||
|
||||
|
||||
void __attribute__((section(".entry"))) start(BootParams* bootParams) {
|
||||
|
||||
// print logo
|
||||
@ -53,7 +43,7 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) {
|
||||
|
||||
// Register IRQs
|
||||
printf("Registering IRQs...");
|
||||
IRQ_RegisterHandler(0, timer);
|
||||
IRQ_RegisterHandler(0, CPU_Timer);
|
||||
IRQ_RegisterHandler(1, Keyboard_Handler);
|
||||
IRQ_RegisterHandler(4, COM1_Serial_Handler);
|
||||
IRQ_RegisterHandler(6, Floppy_Handler);
|
||||
@ -67,6 +57,10 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) {
|
||||
// Floppy_Init(); // This should always be last; its slow as fuck
|
||||
printf("Done!\n");
|
||||
|
||||
// unsure why this is not working, will look into it later...
|
||||
printf("Initializing Memory Paging...");
|
||||
// Memory_Page_Init();
|
||||
printf("Done!\n");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,5 +6,5 @@
|
||||
#pragma once
|
||||
|
||||
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
|
||||
#define VERSION "RD-00035"
|
||||
#define VERSION "RD-00036"
|
||||
#define BOOTLOGO " _ ______ ____ ____ ______\n / | / / __ )/ __ \\/ __ /_ __/\n / |/ / __ / / / / / / // / \n / /| / /_/ / /_/ / /_/ // / \n/_/ |_/_____/\\____/\\____//_/ \n"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user