A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/kernel/paging.c

25 lines
609 B

#include "paging.h"
3 years ago
#include "../drivers/vga.h"
void enable_paging() {
println("Enabling paging...", DEFAULT_COLOR);
3 years ago
// extern int enable_paging_registers(); // Call the assembly SR
// enable_paging_registers(); // and enable paging
3 years ago
return;
}
3 years ago
// Page Entry struct
struct page_entry {
unsigned int index;
unsigned int start_addr;
3 years ago
} page_table[PAGE_TABLE_SIZE];
3 years ago
int get_phys_addr(int virt_addr) {
int index = virt_addr / PAGE_SIZE; // page index for the virtual address
int offset = virt_addr % PAGE_SIZE; // actual physical offset for the address
return page_table[index].start_addr + offset;
}