cc4391d783
There's a lot here, so let's through it: - Lots of work to include a symbol table in the kernel. We can't rely on our bootloader to give us our own ELF information, so we do this separately. This probably should be changed to output a C source rather than assembly, but that's a TODO. - Makefile can now generate modules. It works basically the same way any other kernel object works, expect with a slightly different linking scheme. - Commands have been added to the debug shell to load modules, but they don't work yet - still need to get through relocation and linking. - Commands have been added to the debug shell to print the symbol list, as well as print symbol values (but note that printing symbol values is kinda dangerous if you don't know what they are, so don't just go printing things willy-nilly).
74 lines
2.6 KiB
C
74 lines
2.6 KiB
C
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
*
|
|
* Multiboot (GRUB) handler
|
|
*/
|
|
#include <system.h>
|
|
#include <multiboot.h>
|
|
|
|
char * ramdisk = NULL;
|
|
struct multiboot * mboot_ptr = NULL;
|
|
|
|
struct multiboot *
|
|
copy_multiboot(
|
|
struct multiboot *mboot_ptr
|
|
) {
|
|
struct multiboot *new_header = (struct multiboot *)kmalloc(sizeof(struct multiboot));
|
|
memcpy(new_header, mboot_ptr, sizeof(struct multiboot));
|
|
return new_header;
|
|
}
|
|
|
|
void
|
|
dump_multiboot(
|
|
struct multiboot *mboot_ptr
|
|
) {
|
|
kprintf("MULTIBOOT header at 0x%x:\n", (uintptr_t)mboot_ptr);
|
|
kprintf("Flags : 0x%x ", mboot_ptr->flags);
|
|
kprintf("Mem Lo: 0x%x ", mboot_ptr->mem_lower);
|
|
kprintf("Mem Hi: 0x%x ", mboot_ptr->mem_upper);
|
|
kprintf("Boot d: 0x%x\n", mboot_ptr->boot_device);
|
|
kprintf("cmdlin: 0x%x ", mboot_ptr->cmdline);
|
|
kprintf("Mods : 0x%x ", mboot_ptr->mods_count);
|
|
kprintf("Addr : 0x%x ", mboot_ptr->mods_addr);
|
|
kprintf("ELF n : 0x%x\n", mboot_ptr->num);
|
|
kprintf("ELF s : 0x%x ", mboot_ptr->size);
|
|
kprintf("ELF a : 0x%x ", mboot_ptr->addr);
|
|
kprintf("ELF h : 0x%x ", mboot_ptr->shndx);
|
|
kprintf("MMap : 0x%x\n", mboot_ptr->mmap_length);
|
|
kprintf("Addr : 0x%x ", mboot_ptr->mmap_addr);
|
|
kprintf("Drives: 0x%x ", mboot_ptr->drives_length);
|
|
kprintf("Addr : 0x%x ", mboot_ptr->drives_addr);
|
|
kprintf("Config: 0x%x\n", mboot_ptr->config_table);
|
|
kprintf("Loader: 0x%x ", mboot_ptr->boot_loader_name);
|
|
kprintf("APM : 0x%x ", mboot_ptr->apm_table);
|
|
kprintf("VBE Co: 0x%x ", mboot_ptr->vbe_control_info);
|
|
kprintf("VBE Mo: 0x%x\n", mboot_ptr->vbe_mode_info);
|
|
kprintf("VBE In: 0x%x ", mboot_ptr->vbe_mode);
|
|
kprintf("VBE se: 0x%x ", mboot_ptr->vbe_interface_seg);
|
|
kprintf("VBE of: 0x%x ", mboot_ptr->vbe_interface_off);
|
|
kprintf("VBE le: 0x%x\n", mboot_ptr->vbe_interface_len);
|
|
if (mboot_ptr->flags & (1 << 2)) {
|
|
kprintf("Started with: %s\n", (char *)mboot_ptr->cmdline);
|
|
}
|
|
if (mboot_ptr->flags & (1 << 9)) {
|
|
kprintf("Booted from: %s\n", (char *)mboot_ptr->boot_loader_name);
|
|
}
|
|
if (mboot_ptr->flags & (1 << 0)) {
|
|
kprintf("%dkB lower memory\n", mboot_ptr->mem_lower);
|
|
kprintf("%dkB higher memory ", mboot_ptr->mem_upper);
|
|
int mem_mb = mboot_ptr->mem_upper / 1024;
|
|
kprintf("(%dMB)\n", mem_mb);
|
|
}
|
|
if (mboot_ptr->flags & (1 << 3)) {
|
|
kprintf("Found %d module(s).\n", mboot_ptr->mods_count);
|
|
if (mboot_ptr->mods_count > 0) {
|
|
uint32_t i;
|
|
for (i = 0; i < mboot_ptr->mods_count; ++i ) {
|
|
uint32_t module_start = *((uint32_t*)mboot_ptr->mods_addr + 8 * i);
|
|
uint32_t module_end = *(uint32_t*)(mboot_ptr->mods_addr + 8 * i + 4);
|
|
kprintf("Module %d is at 0x%x:0x%x\n", i+1, module_start, module_end);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|