summaryrefslogtreecommitdiff
path: root/src/kernel/mem/paging.h
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-02-06 20:51:56 +0100
committerAlexis211 <alexis211@gmail.com>2010-02-06 20:51:56 +0100
commit6a52d123672b7a00af6e22b4c138205be2042a94 (patch)
treecd9b0a13490159369a66c850850596fd4b418139 /src/kernel/mem/paging.h
parent3558f18daf50281ee1cd68cca96cd967dbac04ba (diff)
downloadTCE-6a52d123672b7a00af6e22b4c138205be2042a94.tar.gz
TCE-6a52d123672b7a00af6e22b4c138205be2042a94.zip
Reorganisation
Diffstat (limited to 'src/kernel/mem/paging.h')
-rw-r--r--src/kernel/mem/paging.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/kernel/mem/paging.h b/src/kernel/mem/paging.h
new file mode 100644
index 0000000..cb76cd6
--- /dev/null
+++ b/src/kernel/mem/paging.h
@@ -0,0 +1,46 @@
+#ifndef DEF_PAGING_H
+#define DEF_PAGING_H
+
+#include <types.h>
+#include <task/idt.h>
+
+struct page {
+ uint32_t present : 1; //Page mapped to a frame ?
+ uint32_t rw : 1; //Page read/write ?
+ uint32_t user : 1; //Page user readable ?
+ uint32_t accessed : 1; //Was page accessed ?
+ uint32_t dirty : 1; //Was page modified ?
+ uint32_t unused : 7;
+ uint32_t frame : 20; //Frame address (physical address)
+};
+
+struct page_table {
+ struct page pages[1024];
+};
+
+struct segment_map;
+struct page_directory {
+ struct page_table *tables[1024]; //Virtual addresses of page tables
+ uint32_t *tablesPhysical; //Pointer to the virtual address of the page directory (contain phys addr of pt)
+ uint32_t physicalAddr; //Physical address of info above
+ struct segment_map *mappedSegs;
+};
+
+extern struct page_directory *kernel_pagedir;
+
+uint32_t frame_alloc();
+void frame_free(uint32_t id);
+
+void paging_init(size_t totalRam);
+void paging_cleanup();
+void pagedir_switch(struct page_directory *pd);
+struct page_directory *pagedir_new(); //Creates a brand new empty page directory for a process, with kernel pages
+void pagedir_delete(struct page_directory *pagedir);
+struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int make);
+void page_map(struct page *page, uint32_t frame, uint32_t user, uint32_t rw);
+void page_unmap(struct page *page);
+void page_unmapFree(struct page *page);
+
+uint32_t paging_fault(struct registers *regs); //returns a boolean : 1 if unhandled, 0 if ok
+
+#endif