Comp errors

paging
E. Almqvist 3 years ago
parent 7baf28a82d
commit 5a239f5760
  1. 2
      Makefile
  2. 4
      drivers/vga.c
  3. 14
      kernel/enable_paging.asm
  4. 15
      kernel/kernel.c
  5. 10
      kernel/paging.c
  6. 2
      kernel/paging.h

@ -22,7 +22,7 @@ eos_grub.iso : kernel.bin grub/grub.cfg
eos.iso: bootloader/bootloader.bin kernel.bin
cat $^ > eos.iso
kernel.bin: kernel/kernel_entry.o $(OBJ)
kernel.bin: kernel/kernel_entry.o kernel/enable_paging.o $(OBJ)
gcc -o $@ $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32

@ -13,9 +13,9 @@ void vga_init() {
// Clear screen
// clear_row(0);
// clear_screen();
clear_screen();
set_cursor_pos(0, 11);
set_cursor_pos(0, 0);
}
/*

@ -0,0 +1,14 @@
[bits 32] ; 32-bit mode
PAGING_ENABLE equ 0x80000001
PAGE_DIRECTORY equ 0x8000 ; TODO: change me to something good
enable_paging_registers:
mov eax, PAGE_DIRECTORY ; Move the address of the page register (page directory) into eax
; (Using eax as a middle-man register)
mov cr3, eax ; Put the address into the cr3 register (required by the MMU)
mov eax, cr0 ; eax as a middle-man register (again)
or eax, PAGING_ENABLE ; perform the OR operation on eax (ex: 0b01 or 0b10 = 0b11)
; This is needed to enable paging (set the flag as "enabled")
mov cr0, eax ; Move it into cr0 to finally enable paging

@ -4,19 +4,16 @@
#include "../lib/str.h"
#include "../lib/strf.h"
void display_status(char* status_text, unsigned int bg_color) {
clear_row(0);
set_cursor_pos(0, 0);
print(status_text, bg_color | STATUS_TEXT_COLOR);
}
void init() {
display_status("Kernel loaded", 0x70);
vga_init(); // Initialize the screen first
// i.e. clear the screen et cetera.
println("Kernel loaded", DEFAULT_COLOR);
enable_paging();
println("");
char* title = "eOS Version 0.2 2021";
println(title, DEFAULT_COLOR);

@ -1,4 +1,14 @@
#include "paging.h"
#include "../drivers/vga.h"
void enable_paging() {
println("Enabling paging...", DEFAULT_COLOR);
extern int enable_paging_registers(); // Call the assembly SR
enable_paging_registers();
return;
}
// Page Entry struct
struct page_entry {

@ -1,6 +1,8 @@
#define PAGE_SIZE 100
#define PAGE_TABLE_SIZE 128
void enable_paging();
struct page_entry;
char** heap_alloc(unsigned int size); // Process heap allocation

Loading…
Cancel
Save