From c0018a3607947922a51597df12fd2a6528af2fa2 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 5 Feb 2010 19:37:47 +0100 Subject: More work on tasking, paging, syscalls, stuff. --- src/stem/mem/paging.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/stem/mem/paging.c') 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; -- cgit v1.2.3