2021-10-23 11:26:15 +00:00
|
|
|
#pragma once
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "prekernel/multiboot.h"
|
2021-10-23 11:26:15 +00:00
|
|
|
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
|
|
|
|
|
2023-02-03 20:47:05 +00:00
|
|
|
#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;
|
|
|
|
|
2021-12-29 15:15:18 +00:00
|
|
|
#ifdef __VERBOSE__
|
2021-10-23 11:26:15 +00:00
|
|
|
/* Print out the flags */
|
|
|
|
printf("flags = 0x%x\n", (unsigned) mbi->flags);
|
2021-12-29 15:15:18 +00:00
|
|
|
#endif
|
2021-10-23 11:26:15 +00:00
|
|
|
/* Are mem_* valid? */
|
|
|
|
if ( CHECK_FLAG(mbi->flags,0)){
|
2021-12-29 15:15:18 +00:00
|
|
|
// Do nothing
|
2021-10-23 11:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* is boot device valid ? */
|
2021-12-29 15:15:18 +00:00
|
|
|
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);
|
2021-12-29 15:15:18 +00:00
|
|
|
#endif
|
2021-10-23 11:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* is the command line passed? */
|
2021-12-29 15:15:18 +00:00
|
|
|
if (CHECK_FLAG ( mbi->flags,2))
|
|
|
|
{
|
|
|
|
#ifdef __VERBOSE__
|
2021-10-23 11:26:15 +00:00
|
|
|
printf("cmdline = %s\n", (char *) mbi->cmdline);
|
2021-12-29 15:15:18 +00:00
|
|
|
#endif
|
2021-10-23 11:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Are mods_* valid? */
|
|
|
|
if(CHECK_FLAG ( mbi->flags, 3)){
|
|
|
|
multiboot_module_t *mod;
|
2021-11-02 20:03:11 +00:00
|
|
|
uint32_t i;
|
2021-12-29 15:15:18 +00:00
|
|
|
#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);
|
|
|
|
}
|
2021-12-29 15:15:18 +00:00
|
|
|
#endif
|
2021-10-23 11:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Bits 4 and 5 are mutually exclusive! */
|
2021-12-29 15:15:18 +00:00
|
|
|
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");
|
2021-12-29 15:15:18 +00:00
|
|
|
#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);
|
2021-12-29 15:15:18 +00:00
|
|
|
#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);
|
2021-12-29 15:15:18 +00:00
|
|
|
#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);
|
2021-12-29 15:15:18 +00:00
|
|
|
#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-12-29 15:15:18 +00:00
|
|
|
|
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);
|
2021-12-29 15:15:18 +00:00
|
|
|
#endif
|
2021-10-23 11:26:15 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-06 15:27:13 +00:00
|
|
|
/* Draw diagonal blue line */
|
|
|
|
if (CHECK_FLAG (mbt->flags, 12)){
|
2021-12-29 15:15:18 +00:00
|
|
|
#ifdef __VERBOSE__
|
|
|
|
printf("Can draw!\n");
|
|
|
|
#endif
|
2021-11-06 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 11:26:15 +00:00
|
|
|
|
|
|
|
}
|