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 ++++++++++++++ src/stem/mem/paging.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src/stem/mem') 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; diff --git a/src/stem/mem/paging.h b/src/stem/mem/paging.h index 9ee6c4c..cb76cd6 100644 --- a/src/stem/mem/paging.h +++ b/src/stem/mem/paging.h @@ -35,6 +35,7 @@ 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); -- cgit v1.2.3