multiboot.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This program is loaded and executed by GRUB on x86 platforms.
* It is responsible for interpreting the miniroot archive
* loaded by GRUB, read unix and krtld, and jump to the kernel.
*
* Currently the kernel (_kobj_boot) expects a syscall vector,
* bootops, and elfbootvec. So we oblige by providing the
* same services for now.
*/
#include "multiboot.h"
#include "debug.h"
#include "standalloc.h"
#include "bootprop.h"
#include "util.h"
#include "console.h"
typedef int (*func_t)();
extern void setup_bootops();
extern void setup_memlists();
extern void init_paging(void);
extern int mountroot(char *);
extern int openfile(char *, char *);
extern int close(int);
extern void console_init(char *);
extern void kmem_init(void);
extern void init_biosprog();
static void print_mbinfo(void);
int debug;
void *elfbootvec; /* XXX dummy for 32-bit exitto */
char *bootfile_prop = NULL;
char *inputdevice_prop = NULL;
char *outputdevice_prop = NULL;
char *console_prop = NULL;
extern char *bootfile;
extern char *module_path;
extern int boot_verbose;
int is_amd64;
#ifdef BOOTAMD64
extern void amd64_handoff(uint64_t);
extern int amd64_config_cpu();
int amd64_elf64;
#endif /* BOOTAMD64 */
extern int get_bootenv_props(void);
extern void vga_probe(void);
void
{
int fd;
char *grub_bootstr;
int (*entry)();
if (magic != MB_BOOTLOADER_MAGIC) {
/* printf isn't working, so we return to loader */
return;
}
/* Set MBI to the address of the Multiboot information structure. */
kmem_init(); /* initialize memory allocator */
setup_memlists(); /* memory core for the allocator */
print_mbinfo();
setup_bootops(); /* 32-bit memory ops and lists */
init_paging(); /* turn on paging to before loading kernel */
panic("cannot mount boot archive\n");
} else if (verbosemode) {
printf("mountroot succeeded\n");
}
init_biosprog(); /* install bios service program */
get_bootenv_props(); /* read bootenv.rc properties */
vga_probe(); /* probe bios for vga */
/*
* Set console as per eeprom(1M) if not yet specified.
* May set graphics mode, for which bios support is required.
*/
#ifdef BOOTAMD64
/* Test to see if this CPU is an AMD64 */
is_amd64 = amd64_config_cpu();
if (verbosemode && is_amd64)
printf("cpu is amd64 capable\n");
if (is_amd64 == 0)
#endif /* BOOTAMD64 */
/*
* Determine the boot file
* precedence given to what's specified via grub,
* fall back to boot-file property set by eeprom(1M).
* If boot-file not set, fall back to defaults
*/
}
}
setup_bootprop(); /* set up boot properties for the kernel */
printf("\n");
if (fd == -1) {
} else {
extern char filename[];
if (verbosemode)
}
if (module_path) {
if (verbosemode)
}
if (entry == (int (*)())-1) {
}
#ifdef BOOTAMD64
if (amd64_elf64) {
if (verbosemode)
printf("Boot about to exit to AMD64 image at 0x%llx.\n",
}
#endif
if (verbosemode)
printf("Boot about to exit to 32-bit kernel image at 0x%x.\n",
entry);
}
static void
print_mbinfo(void)
{
int tmp;
/* multiboot header */
printf("load_addr = 0x%x, end = 0x%x, bss_end = 0x%x\n",
/* multiboot info location */
/* flags */
/* memory range */
printf("mem_lower = %uKB, mem_upper = %uKB\n",
/* Is boot_device valid? */
}
/* Is the command line passed? */
/* Are mods_* valid? */
int i;
printf("mods_count = %d, mods_addr = 0x%x\n",
" mod_start = 0x%x, mod_end = 0x%x, string = %s\n",
}
}
/* make sure we are not a.out */
printf("Bit 4 is set, we shouldn't be using a.out format.\n");
return;
}
/* Is the section header table of ELF valid? */
printf("elf_sec: num = %u, size = 0x%x,"
" addr = 0x%x, shndx = 0x%x\n",
}
/* print drives info */
printf("drives length %d, driver addr 0x%x\n",
}
}
/*ARGSUSED*/
void
{
panic("unexpected trap in boot loader\n");
}