summaryrefslogtreecommitdiff
path: root/src/stem/mem/paging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stem/mem/paging.c')
-rw-r--r--src/stem/mem/paging.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stem/mem/paging.c b/src/stem/mem/paging.c
index 4cc861c..4d98e75 100644
--- a/src/stem/mem/paging.c
+++ b/src/stem/mem/paging.c
@@ -30,6 +30,7 @@ void paging_init(size_t totalRam) {
frames.bits = kmalloc(INDEX_FROM_BIT(frames.size));
kernel_pagedir = kmalloc(sizeof(struct page_directory));
+ kernel_pagedir->mappedSegs = 0;
kernel_pagedir->tablesPhysical = kmalloc_page(&kernel_pagedir->physicalAddr);
for (i = 0; i < 1024; i++) {
kernel_pagedir->tables[i] = 0;
@@ -73,6 +74,7 @@ struct page_directory *pagedir_new() {
struct page_directory *pd = kmalloc(sizeof(struct page_directory));
pd->tablesPhysical = kmalloc_page(&pd->physicalAddr);
+ pd->mappedSegs = 0;
for (i = 768; i < 1024; i++) {
pd->tables[i] = kernel_pagedir->tables[i];
@@ -82,6 +84,18 @@ struct page_directory *pagedir_new() {
return pd;
}
+void pagedir_delete(struct page_directory *pd) {
+ uint32_t i;
+ //Unmap segments
+ while (pd->mappedSegs != 0) seg_unmap(pd->mappedSegs);
+ //Cleanup page tables
+ for (i = 0; i < 768; i++) {
+ kfree_page(pd->tables[i]);
+ }
+ kfree_page(pd->tablesPhysical);
+ kfree(pd);
+}
+
uint32_t paging_fault(struct registers *regs) {
size_t addr;
struct segment_map *seg = 0;