aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/memory
diff options
context:
space:
mode:
authorMarvin Borner2020-04-29 19:21:29 +0200
committerMarvin Borner2020-04-29 19:21:29 +0200
commit4546c75d685475d8b9f215b588364e1d1bbd0b79 (patch)
tree2077f72ad46dfe877f7febdd0692edc139fd7937 /src/kernel/memory
parent396d7d303d3bf0e796d0c817883ec1dec928352a (diff)
MUCH work in libc
Also cleaned up some syscalls etc
Diffstat (limited to 'src/kernel/memory')
-rw-r--r--src/kernel/memory/alloc.c13
-rw-r--r--src/kernel/memory/paging.c11
-rw-r--r--src/kernel/memory/paging.h2
3 files changed, 16 insertions, 10 deletions
diff --git a/src/kernel/memory/alloc.c b/src/kernel/memory/alloc.c
index fd00cc7..f03c0f5 100644
--- a/src/kernel/memory/alloc.c
+++ b/src/kernel/memory/alloc.c
@@ -100,7 +100,7 @@ void free_internal(struct heap_header *heap, void *address)
}
if ((head->magic != KHEAP_MAGIC) || (head->magic2 != KHEAP_MAGIC2)) {
- //warn("Invalid header in heap");
+ warn("Invalid header in heap");
return;
}
@@ -110,7 +110,7 @@ void free_internal(struct heap_header *heap, void *address)
foot = (struct heap_footer *)((uint32_t)head - sizeof(struct heap_footer));
if ((foot->magic != KHEAP_MAGIC) || (foot->magic2 != KHEAP_MAGIC2)) {
- //warn("Invalid footer in heap");
+ warn("Invalid footer in heap");
return;
}
@@ -126,14 +126,7 @@ void free_internal(struct heap_header *heap, void *address)
foot = (struct heap_footer *)((uint32_t)heap + (heap->size + head->size + HEAP_TOTAL) +
HEAP_S);
if ((foot->magic != KHEAP_MAGIC) || (foot->magic2 != KHEAP_MAGIC2)) {
- /*vga_puts("Footer with size of ");
- vga_puts_hex(foot->size);
- vga_puts(" / head size of ");
- vga_puts_hex(heap->size);
- vga_puts("\n");
- dump_struct(foot, sizeof(struct heap_footer));
- warn("fatal arithmetic error in free() call");
- */
+ panic("Fatal arithmetic error in free() call");
return;
}
diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c
index 9075d1d..ed06004 100644
--- a/src/kernel/memory/paging.c
+++ b/src/kernel/memory/paging.c
@@ -43,6 +43,17 @@ void set_cr0(uint32_t cr0)
asm volatile("movl %%eax, %%cr0" ::"a"(cr0));
}
+void paging_disable()
+{
+ set_cr0(get_cr0() | 0x7fffffff);
+}
+
+void paging_enable()
+{
+ set_cr3(paging_current_directory);
+ set_cr0(get_cr0() | 0x80000000);
+}
+
void paging_switch_directory(struct page_directory *dir)
{
set_cr3(dir);
diff --git a/src/kernel/memory/paging.h b/src/kernel/memory/paging.h
index b4881a9..1941cb9 100644
--- a/src/kernel/memory/paging.h
+++ b/src/kernel/memory/paging.h
@@ -29,6 +29,8 @@ uint32_t get_cr0();
void set_cr3(struct page_directory *dir);
void set_cr0(uint32_t new_cr0);
+void paging_disable();
+void paging_enable();
void paging_switch_directory(struct page_directory *dir);
struct page_directory *paging_make_directory();