1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-27 11:24:34 -05:00

Add function "paging_load"

This commit is contained in:
Braiden Vasco 2017-11-04 14:43:07 +00:00
parent bcae0f03b6
commit 3bbe7a934d
4 changed files with 17 additions and 1 deletions

View file

@ -5,7 +5,7 @@ CC = $(CCPREFIX)gcc
OBJS = start.s.o OBJS = start.s.o
OBJS += init.c.o OBJS += init.c.o
OBJS += multiboot.c.o OBJS += multiboot.c.o
OBJS += paging.c.o OBJS += paging.c.o paging.asm.cpp.o
# Architecture-independent # Architecture-independent
OBJS += info.c.o OBJS += info.c.o

6
arch/paging.asm Normal file
View file

@ -0,0 +1,6 @@
[GLOBAL write_cr3]
write_cr3:
mov eax, [esp+4]
mov cr3, eax
ret

View file

@ -26,6 +26,8 @@
#define assert(n) if (n) {} #define assert(n) if (n) {}
#define panic() if (1) {} #define panic() if (1) {}
void write_cr3(volatile unsigned long);
static unsigned long pagedir[I386_VM_PT_ENTRIES] __attribute__((aligned(4096))); static unsigned long pagedir[I386_VM_PT_ENTRIES] __attribute__((aligned(4096)));
void paging_clear() void paging_clear()
@ -78,3 +80,10 @@ int paging_mapkernel(const struct KernelMQ_Info *const kinfo)
return pde; return pde;
} }
unsigned long paging_load()
{
unsigned long pagedir_phys = (unsigned long)pagedir;
write_cr3(pagedir_phys);
return pagedir_phys;
}

View file

@ -6,5 +6,6 @@
void paging_clear(); void paging_clear();
void paging_identity(const struct KernelMQ_Info *kinfo); void paging_identity(const struct KernelMQ_Info *kinfo);
int paging_mapkernel(const struct KernelMQ_Info *kinfo); int paging_mapkernel(const struct KernelMQ_Info *kinfo);
unsigned long paging_load();
#endif #endif