00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "multiboot.h"
00019
00020
00021
00022 #define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))
00023
00024 multiboot_info_t *multibootInfo;
00025
00026 void multibootInit(unsigned long magic, unsigned long addr) {
00027 consoleOut("stuff\n");
00028
00029 if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
00030 consoleOut ("Invalid magic number: 0x%x\n", (unsigned) magic);
00031 return;
00032 }
00033
00034
00035 multibootInfo = (multiboot_info_t *) addr;
00036 consoleOut("stuff2\n");
00037 return;
00038 }
00039
00040
00041
00042 void
00043 mb_main (unsigned long magic, unsigned long addr)
00044 {
00045 multiboot_info_t *mbi;
00046
00047
00048 consoleClear ();
00049
00050
00051 if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
00052 {
00053 consoleOut ("Invalid magic number: 0x%x\n", (unsigned) magic);
00054 return;
00055 }
00056
00057
00058 mbi = (multiboot_info_t *) addr;
00059
00060
00061 consoleOut ("flags = 0x%x\n", (unsigned) mbi->flags);
00062
00063
00064 if (CHECK_FLAG (mbi->flags, 0))
00065 consoleOut ("mem_lower = %uKB, mem_upper = %uKB\n",
00066 (unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper);
00067
00068
00069 if (CHECK_FLAG (mbi->flags, 1))
00070 consoleOut ("boot_device = 0x%x\n", (unsigned) mbi->boot_device);
00071
00072
00073 if (CHECK_FLAG (mbi->flags, 2))
00074 consoleOut ("cmdline = %s\n", (char *) mbi->cmdline);
00075
00076
00077 if (CHECK_FLAG (mbi->flags, 3))
00078 {
00079 module_t *mod;
00080 int i;
00081
00082 consoleOut ("mods_count = %d, mods_addr = 0x%x\n",
00083 (int) mbi->mods_count, (int) mbi->mods_addr);
00084 for (i = 0, mod = (module_t *) mbi->mods_addr;
00085 i < mbi->mods_count;
00086 i++, mod += sizeof (module_t))
00087 consoleOut (" mod_start = 0x%x, mod_end = 0x%x, string = %s\n",
00088 (unsigned) mod->mod_start,
00089 (unsigned) mod->mod_end,
00090 (char *) mod->string);
00091 }
00092
00093
00094 if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5))
00095 {
00096 consoleOut ("Both bits 4 and 5 are set.\n");
00097 return;
00098 }
00099
00100
00101 if (CHECK_FLAG (mbi->flags, 4))
00102 {
00103 aout_symbol_table_t *aout_sym = &(mbi->u.aout_sym);
00104
00105 consoleOut ("aout_symbol_table: tabsize = 0x%0x, "
00106 "strsize = 0x%x, addr = 0x%x\n",
00107 (unsigned) aout_sym->tabsize,
00108 (unsigned) aout_sym->strsize,
00109 (unsigned) aout_sym->addr);
00110 }
00111
00112
00113 if (CHECK_FLAG (mbi->flags, 5))
00114 {
00115 elf_section_header_table_t *elf_sec = &(mbi->u.elf_sec);
00116
00117 consoleOut ("elf_sec: num = %u, size = 0x%x,"
00118 " addr = 0x%x, shndx = 0x%x\n",
00119 (unsigned) elf_sec->num, (unsigned) elf_sec->size,
00120 (unsigned) elf_sec->addr, (unsigned) elf_sec->shndx);
00121 }
00122
00123
00124 if (CHECK_FLAG (mbi->flags, 6))
00125 {
00126 memory_map_t *mmap;
00127
00128 consoleOut ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
00129 (unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
00130 for (mmap = (memory_map_t *) mbi->mmap_addr;
00131 (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
00132 mmap = (memory_map_t *) ((unsigned long) mmap
00133 + mmap->size + sizeof (mmap->size)))
00134 consoleOut (" size = 0x%x, base_addr = 0x%x%x,"
00135 " length = 0x%x%x, type = 0x%x\n",
00136 (unsigned) mmap->size,
00137 (unsigned) mmap->base_addr_high,
00138 (unsigned) mmap->base_addr_low,
00139 (unsigned) mmap->length_high,
00140 (unsigned) mmap->length_low,
00141 (unsigned) mmap->type);
00142 }
00143 }