summaryrefslogtreecommitdiff
path: root/src/stem/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/stem/mem')
-rw-r--r--src/stem/mem/mem.c2
-rw-r--r--src/stem/mem/paging.c14
-rw-r--r--src/stem/mem/seg.c2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/stem/mem/mem.c b/src/stem/mem/mem.c
index c96a29d..2f7e1c8 100644
--- a/src/stem/mem/mem.c
+++ b/src/stem/mem/mem.c
@@ -34,7 +34,7 @@ static void get_free_pages() {
}
freepages[freepagecount].virt = i;
freepages[freepagecount].phys = frame_alloc() * 0x1000;
- page_map(pagedir_getPage(kernel_pagedir, i, 0), i, 0, 0);
+ page_map(pagedir_getPage(kernel_pagedir, i, 0), freepages[freepagecount].phys / 0x1000, 0, 0);
freepagecount++;
} else {
if (mem_placementAddr & 0xFFFFF000) {
diff --git a/src/stem/mem/paging.c b/src/stem/mem/paging.c
index 9b9c989..27ce043 100644
--- a/src/stem/mem/paging.c
+++ b/src/stem/mem/paging.c
@@ -54,7 +54,7 @@ void paging_init(size_t totalRam) {
void paging_cleanup() {
uint32_t i;
for (i = 0; i < (mem_placementAddr - 0xE0000000) / 0x100000; i++) {
- kernel_pagedir->tablesPhysical[i] = 9;
+ kernel_pagedir->tablesPhysical[i] = 0;
kernel_pagedir->tables[i] = 0;
}
monitor_write("Pages cleaned up\n");
@@ -80,7 +80,7 @@ struct page_directory *pagedir_new() {
pd->tables[i] = 0; pd->tablesPhysical[i] = 0;
}
- for (i = 768; i < 1024; i++) {
+ for (i = 896; i < 1024; i++) {
pd->tables[i] = kernel_pagedir->tables[i];
pd->tablesPhysical[i] = kernel_pagedir->tablesPhysical[i];
}
@@ -93,7 +93,7 @@ void pagedir_delete(struct page_directory *pd) {
//Unmap segments
while (pd->mappedSegs != 0) seg_unmap(pd->mappedSegs);
//Cleanup page tables
- for (i = 0; i < 768; i++) {
+ for (i = 0; i < 896; i++) {
kfree_page(pd->tables[i]);
}
kfree_page(pd->tablesPhysical);
@@ -107,16 +107,16 @@ uint32_t paging_fault(struct registers *regs) {
seg = current_pagedir->mappedSegs;
while (seg) {
- if (seg->start >= addr && seg->start + seg->len < addr) break;
+ if (seg->start <= addr && seg->start + seg->len > addr) break;
seg = seg->next;
}
if (seg != 0) {
- if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2)) != 0) seg = 0;
+ if (seg->seg->handle_fault(seg, addr, (regs->err_code & 0x2) && (regs->eip < 0xE0000000)) != 0) seg = 0;
}
if (seg == 0) {
- monitor_write("PageFault ");
+ monitor_write("(paging.c:119) Unhandled Page Fault ");
if (regs->err_code & 0x1) monitor_write("present ");
if (regs->err_code & 0x2) monitor_write("write ");
if (regs->err_code & 0x4) monitor_write("user ");
@@ -136,7 +136,7 @@ struct page *pagedir_getPage(struct page_directory *pd, uint32_t address, int ma
return &pd->tables[table_idx]->pages[address % 1024];
} else if (make) {
pd->tables[table_idx] = kmalloc_page(pd->tablesPhysical + table_idx);
- if (table_idx >= 768)
+ if (table_idx >= 896)
tasking_updateKernelPagetable(table_idx, pd->tables[table_idx], pd->tablesPhysical[table_idx]);
memset((uint8_t*)pd->tables[table_idx], 0, 0x1000);
pd->tablesPhysical[table_idx] |= 0x07;
diff --git a/src/stem/mem/seg.c b/src/stem/mem/seg.c
index f340c63..1452d61 100644
--- a/src/stem/mem/seg.c
+++ b/src/stem/mem/seg.c
@@ -8,7 +8,7 @@ struct segment_map *seg_map(struct segment* seg, struct page_directory *pagedir)
sm->seg = seg;
sm->pagedir = pagedir;
sm->next = pagedir->mappedSegs;
- pagedir->mappedSegs = sm->next;
+ pagedir->mappedSegs = sm;
return sm;
}