Mercurial > lcfOS
diff cos/kernel/kernel.c @ 34:8012221dd740
Fixes for uninitialized data. This causes problems on real machines
author | windel |
---|---|
date | Mon, 16 Jan 2012 13:46:06 +0100 |
parents | d8185ddb6c7b |
children | bcb3b68c8147 |
line wrap: on
line diff
--- a/cos/kernel/kernel.c Sun Jan 15 13:39:49 2012 +0100 +++ b/cos/kernel/kernel.c Mon Jan 16 13:46:06 2012 +0100 @@ -21,31 +21,25 @@ * */ void kmain() { + // No kmalloc required here yet: init_screen(); setupIDT(); - - uint64_t available_memory = 0; - - printf("Running with %d MB ram\n", available_memory / 1000000); - - printf("Detecting amount of memory\n"); + keyboard_init(); + timer_init(); - printf("Grub multiboot header location: %x\n", multiboot_info); - // On real hardware, the retrieval of the flags fails into general protection fault?? - - printf("Grub lower mem: %d\n", multiboot_info->mem_lower); - printf("Grub multiboot header flags: %x\n", multiboot_info->flags); - - /* Display memory information from multiboot header */ + /* Retrieve memory information from multiboot header */ + uint64_t available_memory = 0; if ((multiboot_info->flags & (1<<6)) == (1<<6)) { - printf("Found GRUB memory map\n"); multiboot_memory_map_t *mmap; for (mmap = (multiboot_memory_map_t*)(uint64_t)multiboot_info->mmap_addr; (uint64_t)mmap < multiboot_info->mmap_addr + multiboot_info->mmap_length; mmap = (multiboot_memory_map_t*) ( (uint64_t)mmap + mmap->size + sizeof(mmap->size)) ) { - printf("size: %d, start: 0x%x, length=0x%x, type=%d\n", mmap->size, mmap->base, mmap->length, mmap->type); + /* + printf("size: %d, start: 0x%x, length=0x%x, type=%d\n", mmap->size, + mmap->base, mmap->length, mmap->type); + */ if ( (mmap->type == 1) && (mmap->base == 0x100000) ) { @@ -55,13 +49,13 @@ } else { - printf("Found no GRUB map\n"); + panic("Found no GRUB memory map\n"); } printf("Running with %d MB ram\n", available_memory / 1000000); + /* fs_node_t *fs_root = 0; - if ( (multiboot_info->flags & (1<<3)) == (1<<3)) { printf("Mod count: %d\n", multiboot_info->mods_count); @@ -75,6 +69,8 @@ uint64_t ramdisk_location = ((uint32_t*)((uint64_t)multiboot_info->mods_addr))[0]; fs_root = initialize_initrd(ramdisk_location); } + // TODO: Make sure that placement malloc does not overwrite the ramdisk. + printf("Mod size: %d", mod->mod_end - mod->mod_start); } } @@ -87,9 +83,7 @@ } } - - // TODO: Make sure that placement malloc does not overwrite the ramdisk. - printf("Mod size: "); + */ // Assume first 16MB: // TODO: get size from grub @@ -98,8 +92,7 @@ // TODO: make below a user space program! printf("Welcome!\n"); - - while (1==1) + while (1) { char buffer[70]; printf(">");