Improve print information from mbi

This commit is contained in:
Mathieu Maret 2021-10-18 20:39:08 +02:00
parent d2accf3da6
commit 8ff10c938c

View File

@ -53,6 +53,7 @@ void kmain(unsigned long magic, unsigned long addr)
irqSetup(); irqSetup();
pitSetup(HZ); pitSetup(HZ);
// https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
if (magic == MULTIBOOT_BOOTLOADER_MAGIC) { // Get loaded by Grub with mutliboot version 1 if (magic == MULTIBOOT_BOOTLOADER_MAGIC) { // Get loaded by Grub with mutliboot version 1
multiboot_info_t *mbi = (multiboot_info_t *)addr; multiboot_info_t *mbi = (multiboot_info_t *)addr;
/* Are mem_* valid? */ /* Are mem_* valid? */
@ -63,15 +64,15 @@ void kmain(unsigned long magic, unsigned long addr)
/* Is boot_device valid? */ /* Is boot_device valid? */
if (CHECK_FLAG(mbi->flags, 1)) { if (CHECK_FLAG(mbi->flags, 1)) {
printf("boot_device = %d\n", mbi->boot_device); int disk = mbi->boot_device >> 24 & 0xff;
} int part1 = mbi->boot_device >> 16 & 0xff;
int part2 = mbi->boot_device >> 8 & 0xff;
/* Is the command line passed? */ int part3 = mbi->boot_device & 0xff;
if (CHECK_FLAG(mbi->flags, 2)) { printf("boot_device = 0x%x (0x0 for floppy 0x80 for disk) part %d %d %d\n", disk, part1, part2, part3);
printf("cmdline = %s\n", (char *)mbi->cmdline);
} }
if (CHECK_FLAG(mbi->flags, 3)) { if (CHECK_FLAG(mbi->flags, 3)) {
if (mbi->mods_count > 0) {
multiboot_module_t *mod; multiboot_module_t *mod;
uint32_t i; uint32_t i;
@ -80,14 +81,28 @@ void kmain(unsigned long magic, unsigned long addr)
for (i = 0, mod = (multiboot_module_t *)mbi->mods_addr; i < mbi->mods_count; for (i = 0, mod = (multiboot_module_t *)mbi->mods_addr; i < mbi->mods_count;
i++, mod++) i++, mod++)
printf(" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n", printf(" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
(unsigned)mod->mod_start, (unsigned)mod->mod_end, (char *)mod->cmdline); (unsigned)mod->mod_start, (unsigned)mod->mod_end,
(char *)mod->cmdline);
}
} }
if (CHECK_FLAG(mbi->flags, 6)) { if (CHECK_FLAG(mbi->flags, 6)) {
memMapAvailable = 1; memMapAvailable = 1;
} }
if (CHECK_FLAG(mbi->flags, 9)) {
printf("Loaded by %s. ", mbi->boot_loader_name);
}
/* Is the command line passed? */
if (CHECK_FLAG(mbi->flags, 2)) {
printf("cmdline = %s\n", (char *)mbi->cmdline);
}
if (CHECK_FLAG(mbi->flags, 12)) {
printf("Framebuffer from 0x%llx size (%dx%d) pitch %d bpp %d\n", mbi->framebuffer_addr, mbi->framebuffer_width, mbi->framebuffer_height, mbi->framebuffer_pitch, mbi->framebuffer_bpp); printf("Framebuffer from 0x%llx size (%dx%d) pitch %d bpp %d\n", mbi->framebuffer_addr, mbi->framebuffer_width, mbi->framebuffer_height, mbi->framebuffer_pitch, mbi->framebuffer_bpp);
} }
}
if (upperMemKB == 0) { if (upperMemKB == 0) {
printf("Cannot get upper phy mem bound. Using default value 32MB\n"); printf("Cannot get upper phy mem bound. Using default value 32MB\n");