summaryrefslogtreecommitdiff
path: root/src/stem/paging.h
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-01-25 18:38:43 +0100
committerAlexis211 <alexis211@gmail.com>2010-01-25 18:38:43 +0100
commit4ae83c83f34759172e9c575c8ac875011bfaff2d (patch)
tree26ec6c665cbada6e413bd31e34c60d7c2bbb41c3 /src/stem/paging.h
downloadTCE-4ae83c83f34759172e9c575c8ac875011bfaff2d.tar.gz
TCE-4ae83c83f34759172e9c575c8ac875011bfaff2d.zip
First commit
Diffstat (limited to 'src/stem/paging.h')
-rw-r--r--src/stem/paging.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/stem/paging.h b/src/stem/paging.h
new file mode 100644
index 0000000..87ba183
--- /dev/null
+++ b/src/stem/paging.h
@@ -0,0 +1,42 @@
+#ifndef DEF_PAGING_H
+#define DEF_PAGING_H
+
+#include "types.h"
+#include "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 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
+};
+
+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 *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
+
+#endif