paging
E. Almqvist 3 years ago
parent 3c891cad57
commit 9ffbcc8ad0
  1. 10
      kernel/enable_paging.asm
  2. 4
      kernel/paging.c
  3. 2
      kernel/paging.h

@ -1,8 +1,9 @@
[bits 32] ; 32-bit mode
PAGING_ENABLE equ 0x80000001
PAGE_DIRECTORY_ADDR equ 0xf000000f ; TODO: change me to something good
PAGING_ENABLE_FLAG equ 0x80000001
PAGE_DIRECTORY_ADDR equ 0xffffffff ; TODO: change me to something good
global enable_paging_registers ; make the SR "global" so that we can access it in the kernel etc
enable_paging_registers:
mov eax, PAGE_DIRECTORY_ADDR ; Move the address of the
; page register (page directory) into eax
@ -10,9 +11,10 @@ enable_paging_registers:
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)
or eax, PAGING_ENABLE_FLAG ; 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
ret ; return to last location
global enable_paging_registers ; make the SR "global" so that we can access it in the kernel etc

@ -4,8 +4,8 @@
void enable_paging() {
println("Enabling paging...", DEFAULT_COLOR);
extern void enable_paging_registers(); // Call the assembly SR
enable_paging_registers();
extern int enable_paging_registers(); // Call the assembly SR
enable_paging_registers(); // and enable paging
return;
}

@ -5,5 +5,5 @@ void enable_paging();
struct page_entry;
//char** heap_alloc(unsigned int size); // Process heap allocation
// char** heap_alloc(unsigned int size); // Process heap allocation
int get_phys_addr(int virt_addr);

Loading…
Cancel
Save