BarinkOS/kernel/bootcheck.h

91 lines
2.8 KiB
C
Raw Normal View History

2021-10-23 11:26:15 +00:00
#pragma once
#include "prekernel/multiboot.h"
2021-10-23 11:26:15 +00:00
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
#include "terminal/kterm.h"
2021-10-23 11:26:15 +00:00
void CheckMBT ( multiboot_info_t* mbt ){
/* Set MBI to the addresss of the multiboot information structure*/
multiboot_info_t * mbi = (multiboot_info_t *) mbt;
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
/* Print out the flags */
printf("flags = 0x%x\n", (unsigned) mbi->flags);
#endif
2021-10-23 11:26:15 +00:00
/* Are mem_* valid? */
if ( CHECK_FLAG(mbi->flags,0)){
// Do nothing
2021-10-23 11:26:15 +00:00
}
/* is boot device valid ? */
if (CHECK_FLAG (mbi->flags, 1))
{
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
printf("boot_device = 0x0%x\n", (unsigned) mbi->boot_device);
#endif
2021-10-23 11:26:15 +00:00
}
/* is the command line passed? */
if (CHECK_FLAG ( mbi->flags,2))
{
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
printf("cmdline = %s\n", (char *) mbi->cmdline);
#endif
2021-10-23 11:26:15 +00:00
}
/* Are mods_* valid? */
if(CHECK_FLAG ( mbi->flags, 3)){
multiboot_module_t *mod;
uint32_t i;
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
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);
}
#endif
2021-10-23 11:26:15 +00:00
}
/* Bits 4 and 5 are mutually exclusive! */
if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG(mbi->flags, 5))
{
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
printf("Both bits 4 and 5 are set.\n");
#endif
2021-10-23 11:26:15 +00:00
return;
}
/* Is the symbol table of a.out valid? */
if (CHECK_FLAG(mbi->flags, 4)){
multiboot_aout_symbol_table_t *multiboot_aout_sym = &(mbi->u.aout_sym);
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
printf( "multiboot_aout_symbol_table: tabsize = 0x%0x, strsize = 0x%x, addr = 0x%x\n",
(unsigned) multiboot_aout_sym->tabsize,
(unsigned) multiboot_aout_sym->strsize,
(unsigned) multiboot_aout_sym->addr);
#endif
2021-10-23 11:26:15 +00:00
}
/* Is the section header table of ELF valid? */
if (CHECK_FLAG(mbi->flags, 5)){
multiboot_elf_section_header_table_t *multiboot_elf_sec = &(mbi->u.elf_sec);
#ifdef __VERBOSE__
2021-10-23 11:26:15 +00:00
printf("multiboot_elf_sec: num = %u, size = 0x%x, addr = 0x%x, shnd = 0x%x\n",
2021-10-23 11:26:15 +00:00
(unsigned) multiboot_elf_sec->num, (unsigned) multiboot_elf_sec->size,
(unsigned) multiboot_elf_sec->addr, (unsigned) multiboot_elf_sec->shndx);
#endif
2021-10-23 11:26:15 +00:00
}
/* Draw diagonal blue line */
if (CHECK_FLAG (mbt->flags, 12)){
#ifdef __VERBOSE__
printf("Can draw!\n");
#endif
}
2021-10-23 11:26:15 +00:00
}