1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Add module "pagedir"

This commit is contained in:
Braiden Vasco 2017-11-09 06:20:45 +00:00
parent 9b6a586f65
commit a24686c345
4 changed files with 29 additions and 17 deletions

View file

@ -6,6 +6,7 @@ OBJS += multiboot.c.o
OBJS += panic.c.o panic.asm.cpp.o OBJS += panic.c.o panic.asm.cpp.o
OBJS += pfa.c.o OBJS += pfa.c.o
OBJS += paging.c.o paging.asm.cpp.o OBJS += paging.c.o paging.asm.cpp.o
OBJS += pagedir.c.o
# Built-in drivers # Built-in drivers
OBJS += console.c.o OBJS += console.c.o

1
arch/x86/pagedir.c Normal file
View file

@ -0,0 +1 @@
#include "pagedir.h"

25
arch/x86/pagedir.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef KERNELMQ_INCLUDED_PAGEDIR
#define KERNELMQ_INCLUDED_PAGEDIR 1
#include "config.h"
#define PAGE_DIR_ALIGN 4096
struct PageDir_Entry {
unsigned int present : 1;
unsigned int writable : 1;
unsigned int user : 1;
unsigned int write_through : 1;
unsigned int cache_disabled : 1;
unsigned int accessed : 1;
unsigned int always_0 : 1;
unsigned int page_size : 1;
unsigned int ignored : 1;
unsigned int unused : 3;
unsigned int addr : 20;
}
__attribute__((packed));
typedef struct PageDir_Entry PageDir[PAGE_DIR_LENGTH] __attribute__((aligned((PAGE_DIR_ALIGN))));
#endif

View file

@ -1,6 +1,6 @@
#include "paging.h" #include "paging.h"
#include "config.h" #include "pagedir.h"
#include "panic.h" #include "panic.h"
#include <kernelmq/stdlib.h> #include <kernelmq/stdlib.h>
@ -26,21 +26,6 @@
#define BIG_PAGE_BASE_TO_ADDR(base) ((base) >> 12) #define BIG_PAGE_BASE_TO_ADDR(base) ((base) >> 12)
struct entry {
unsigned int present : 1;
unsigned int writable : 1;
unsigned int user : 1;
unsigned int write_through : 1;
unsigned int cache_disabled : 1;
unsigned int accessed : 1;
unsigned int always_0 : 1;
unsigned int page_size : 1;
unsigned int ignored : 1;
unsigned int unused : 3;
unsigned int addr : 20;
}
__attribute__((packed));
unsigned long read_cr0(); unsigned long read_cr0();
unsigned long read_cr4(); unsigned long read_cr4();
@ -48,7 +33,7 @@ void write_cr0(volatile unsigned long);
void write_cr3(volatile unsigned long); void write_cr3(volatile unsigned long);
void write_cr4(volatile unsigned long); void write_cr4(volatile unsigned long);
static struct entry pagedir[PAGE_DIR_LENGTH] __attribute__((aligned(4096))); static PageDir pagedir;
void paging_enable() void paging_enable()
{ {