Improve print information from mbi

This commit is contained in:
Mathieu Maret 2021-10-18 20:39:08 +02:00
parent d2accf3da6
commit 8ff10c938c
1 changed files with 31 additions and 16 deletions

View File

@ -53,6 +53,7 @@ void kmain(unsigned long magic, unsigned long addr)
irqSetup();
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
multiboot_info_t *mbi = (multiboot_info_t *)addr;
/* Are mem_* valid? */
@ -63,7 +64,34 @@ void kmain(unsigned long magic, unsigned long addr)
/* Is boot_device valid? */
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;
int part3 = mbi->boot_device & 0xff;
printf("boot_device = 0x%x (0x0 for floppy 0x80 for disk) part %d %d %d\n", disk, part1, part2, part3);
}
if (CHECK_FLAG(mbi->flags, 3)) {
if (mbi->mods_count > 0) {
multiboot_module_t *mod;
uint32_t i;
printf("mods_count = %d, mods_addr = 0x%x\n", (int)mbi->mods_count,
(int)mbi->mods_addr);
for (i = 0, mod = (multiboot_module_t *)mbi->mods_addr; i < mbi->mods_count;
i++, mod++)
printf(" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
(unsigned)mod->mod_start, (unsigned)mod->mod_end,
(char *)mod->cmdline);
}
}
if (CHECK_FLAG(mbi->flags, 6)) {
memMapAvailable = 1;
}
if (CHECK_FLAG(mbi->flags, 9)) {
printf("Loaded by %s. ", mbi->boot_loader_name);
}
/* Is the command line passed? */
@ -71,22 +99,9 @@ void kmain(unsigned long magic, unsigned long addr)
printf("cmdline = %s\n", (char *)mbi->cmdline);
}
if (CHECK_FLAG(mbi->flags, 3)) {
multiboot_module_t *mod;
uint32_t i;
printf("mods_count = %d, mods_addr = 0x%x\n", (int)mbi->mods_count,
(int)mbi->mods_addr);
for (i = 0, mod = (multiboot_module_t *)mbi->mods_addr; i < mbi->mods_count;
i++, mod++)
printf(" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
(unsigned)mod->mod_start, (unsigned)mod->mod_end, (char *)mod->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);
}
if (CHECK_FLAG(mbi->flags, 6)) {
memMapAvailable = 1;
}
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) {