Main Page | Modules | File List | File Members

multiboot.c

00001 /* kernel.c - the C part of the kernel */
00002 /* Copyright (C) 1999  Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2 of the License, or
00007    (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
00017 
00018 #include "multiboot.h"
00019 
00020 /* Macros. */
00021 /* Check if the bit BIT in FLAGS is set. */
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   /* Am I booted by a Multiboot-compliant boot loader? */
00029   if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
00030     consoleOut ("Invalid magic number: 0x%x\n", (unsigned) magic);
00031     return;
00032   }
00033 
00034   /* Set MBI to the address of the Multiboot information structure. */
00035   multibootInfo = (multiboot_info_t *) addr;
00036   consoleOut("stuff2\n");
00037   return;
00038 }
00039 
00040 /* Check if MAGIC is valid and print the Multiboot information structure
00041    pointed by ADDR. */
00042 void
00043 mb_main (unsigned long magic, unsigned long addr)
00044 {
00045   multiboot_info_t *mbi;
00046 
00047   /* Clear the screen. */
00048   consoleClear ();
00049 
00050   /* Am I booted by a Multiboot-compliant boot loader? */
00051   if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
00052     {
00053       consoleOut ("Invalid magic number: 0x%x\n", (unsigned) magic);
00054       return;
00055     }
00056 
00057   /* Set MBI to the address of the Multiboot information structure. */
00058   mbi = (multiboot_info_t *) addr;
00059 
00060   /* Print out the flags. */
00061   consoleOut ("flags = 0x%x\n", (unsigned) mbi->flags);
00062 
00063   /* Are mem_* valid? */
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   /* Is boot_device valid? */
00069   if (CHECK_FLAG (mbi->flags, 1))
00070     consoleOut ("boot_device = 0x%x\n", (unsigned) mbi->boot_device);
00071 
00072   /* Is the command line passed? */
00073   if (CHECK_FLAG (mbi->flags, 2))
00074     consoleOut ("cmdline = %s\n", (char *) mbi->cmdline);
00075 
00076   /* Are mods_* valid? */
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   /* Bits 4 and 5 are mutually exclusive! */
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   /* Is the symbol table of a.out valid? */
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   /* Is the section header table of ELF valid? */
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   /* Are mmap_* valid? */
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 }

Generated on Sun Nov 21 18:26:11 2004 for ndk by doxygen 1.3.2