From ef1012f3b7e7bf974a5d24408d719ed8769c8425 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sat, 4 Nov 2017 04:19:32 +0000 Subject: [PATCH] Add file "arch/paging.c" --- arch/Makefile | 1 + arch/paging.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 arch/paging.c diff --git a/arch/Makefile b/arch/Makefile index 8c2e73e..d624d62 100644 --- a/arch/Makefile +++ b/arch/Makefile @@ -10,6 +10,7 @@ OBJS += main.c.o OBJS += logger.c.o console.c.o kprintf.c.o OBJS += multiboot.c.o OBJS += memory.c.o +OBJS += paging.c.o OBJS += protected.c.o protected.asm.cpp.o OBJS += exception.c.o exception.asm.cpp.o diff --git a/arch/paging.c b/arch/paging.c new file mode 100644 index 0000000..074502d --- /dev/null +++ b/arch/paging.c @@ -0,0 +1,22 @@ +#define PAGES_PER_TABLE 1024 +#define TABLES_PER_DIR 1024 + +struct page { + unsigned int present : 1; + unsigned int rw : 1; + unsigned int user : 1; + unsigned int accessed : 1; + unsigned int dirty : 1; + unsigned int unused : 7; + unsigned int frame : 20; +}; + +struct page_table { + struct page pages[PAGES_PER_TABLE]; +}; + +struct page_dir { + struct page_table *tables[TABLES_PER_DIR]; + unsigned int tables_phys[TABLES_PER_DIR]; + unsigned int phys; +};