diff options
author | Marvin Borner | 2021-05-19 00:43:40 +0200 |
---|---|---|
committer | Marvin Borner | 2021-05-19 00:43:40 +0200 |
commit | 98df498e8e8a07e33cc77a059876b940cb9b3c6a (patch) | |
tree | 57a2ff0fab411c91fba5512827c18124b092aa5d /kernel/features | |
parent | 45bfdffcb2e00fda595b3f9318469f6b0d29cbe4 (diff) |
Smashed some bugs
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/mm.c | 16 | ||||
-rw-r--r-- | kernel/features/proc.c | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 7a39b33..eca1aae 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -137,6 +137,7 @@ static void physical_page_set_free(u32 address) CLEAR void physical_set_total(u32 total) { assert(total > 0); + memory_used = 0; memory_total = total; } @@ -670,7 +671,7 @@ struct memory_range memory_range_from(u32 base, u32 size) base += align; size -= align; - size -= size % PAGE_SIZE; + size = ALIGN_DOWN(size, PAGE_SIZE); return memory_range(base, size); } @@ -682,7 +683,7 @@ struct memory_range memory_range_around(u32 base, u32 size) base -= align; size += align; - size += PAGE_SIZE - size % PAGE_SIZE; + size = ALIGN_UP(size, PAGE_SIZE); return memory_range(base, size); } @@ -728,8 +729,15 @@ void memory_user_hook(void) CLEAR void memory_install(void) { + // Set all memory 'used' + for (u32 i = 0; i < 1024 * 1024 / 8; i++) { + memory[i] = 0xff; + } + + // Free memory using mmap multiboot_mmap(); + // Initialize kernel page directory for (u32 i = 0; i < PAGE_KERNEL_COUNT; i++) { union page_dir_entry *dir_entry = &kernel_dir.entries[i]; dir_entry->bits.present = 1; @@ -738,16 +746,12 @@ CLEAR void memory_install(void) dir_entry->bits.address = (u32)&kernel_tables[i] / PAGE_SIZE; } - memory_used = 0; printf("Detected memory: %dKiB (%dMiB)\n", memory_total >> 10, memory_total >> 20); // Map kernel memory_map_identity(&kernel_dir, kernel_ro_memory_range(), MEMORY_READONLY); memory_map_identity(&kernel_dir, kernel_rw_memory_range(), MEMORY_NONE); - // Map framebuffer - memory_map_identity(&kernel_dir, memory_range_around(multiboot_vbe(), 0x1000), MEMORY_NONE); - // Unmap NULL byte/page struct memory_range zero = memory_range(0, PAGE_SIZE); virtual_free(&kernel_dir, zero); diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 574df68..4dd90c8 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -279,7 +279,7 @@ struct procfs_message { static res procfs_read(const char *path, void *buf, u32 offset, u32 count, struct vfs_dev *dev) { - (void)dev; + UNUSED(dev); u32 pid = 0; procfs_parse_path(&path, &pid); @@ -314,8 +314,8 @@ static res procfs_read(const char *path, void *buf, u32 offset, u32 count, struc static res procfs_perm(const char *path, enum vfs_perm perm, struct vfs_dev *dev) { - (void)path; - (void)dev; + UNUSED(path); + UNUSED(dev); if (perm == VFS_EXEC) return -EACCES; |