/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
/*
* MD bootstrap main() and assorted miscellaneous
* commands.
*/
#include <stand.h>
#include <stddef.h>
#include <string.h>
#include <machine/bootinfo.h>
#include "bootstrap.h"
#include "common/bootargs.h"
#include "btxv86.h"
#ifdef LOADER_ZFS_SUPPORT
#endif
static void extract_currdev(void);
#ifdef LOADER_ZFS_SUPPORT
static void i386_zfs_probe(void);
#endif
/* from vers.c */
/* XXX debugging */
extern char end[];
static void *heap_top;
static void *heap_bottom;
int
main(void)
{
int i;
/* Pick up arguments */
/* Initialize the v86 register set to a known-good state. */
/*
* Initialise the heap as early as possible. Once this is done, malloc() is usable.
*/
bios_getmem();
#if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || \
defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT)
if (high_heap_size > 0) {
if (high_heap_base < memtop_copyin)
} else
#endif
{
heap_bottom = (void *)end;
}
/*
* XXX Chicken-and-egg problem; we want to have console output early, but some
* console attributes may depend on reading from eg. the boot device, which we
* can't do yet.
*
* We can use printf() etc. once this is done.
* If the previous boot stage has requested a serial console, prefer that.
*/
if (initial_howto & RB_MULTIPLE) {
if (initial_howto & RB_SERIAL)
else
} else if (initial_howto & RB_SERIAL)
else if (initial_howto & RB_MUTE)
cons_probe();
/*
* Initialise the block cache. Set the upper limit.
*/
/*
* Special handling for PXE and CD booting.
*/
/*
* We only want the PXE disk to try to init itself in the below
* walk through devsw if we actually booted off of PXE.
*/
}
#ifdef LOADER_ZFS_SUPPORT
#endif
/*
* March through the device switch probing for things.
*/
if (initial_bootinfo != NULL) {
}
/* detect ACPI for future reference */
/* detect SMBIOS for future reference */
/* detect PCI BIOS for future reference */
printf("\n");
extract_currdev(); /* set $currdev and $loaddev */
if (bi_checkcpu())
else
bios_getsmap();
/* if we ever get here, it is an error */
return (1);
}
/*
* Set the 'current device' by (if possible) recovering the boot device as
* supplied by the initial bootstrap.
*
* XXX should be extended for netbooting.
*/
static void
extract_currdev(void)
{
#ifdef LOADER_ZFS_SUPPORT
#endif
/* Assume we are booting from a BIOS disk by default */
/* new-style boot loaders such as pxeldr and cdldr */
/* we are booting from a CD with cdboot */
/* we are booting from pxeldr */
new_currdev.d_unit = 0;
} else {
/* we don't know what our boot device is */
biosdev = -1;
}
#ifdef LOADER_ZFS_SUPPORT
/* check for new style extended argument */
/* sufficient data is provided */
}
} else {
/* old style zfsboot block */
}
#endif
/* The passed-in boot device is bad */
biosdev = -1;
} else {
/*
* If we are booted by an old bootstrap, we have to guess at the BIOS
* unit number. We will lose if there is more than one disk type
* and we are not booting from the lowest-numbered disk type
* (ie. SCSI when IDE also exists).
*/
}
/*
* If we are booting off of a BIOS disk and we didn't succeed in determining
* which one we booted off of, just use disk0: as a reasonable default.
*/
printf("Can't work out which disk we are booting from.\n"
"Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev);
new_currdev.d_unit = 0;
}
#ifdef LOADER_ZFS_SUPPORT
#ifdef __FreeBSD__
#endif
#endif
}
static int
{
int i;
(devsw[i]->dv_cleanup)();
printf("Rebooting...\n");
delay(1000000);
__exit(0);
}
/* provide this for panic, as it's not in the startup code */
void
{
}
static int
{
mallocstats();
return(CMD_OK);
}
#ifdef LOADER_ZFS_SUPPORT
static int
{
int err;
if (argc != 2) {
command_errmsg = "wrong number of arguments";
return (CMD_ERROR);
}
if (err != 0) {
return (CMD_ERROR);
}
return (CMD_OK);
}
#ifdef __FreeBSD__
static int
{
int err;
char *root;
if (argc > 2) {
command_errmsg = "wrong number of arguments";
return (CMD_ERROR);
}
if (argc == 2) {
} else {
/* There does not appear to be a ZFS pool here, exit without error */
return (CMD_OK);
}
}
if (err != 0) {
return (CMD_ERROR);
}
return (CMD_OK);
}
#endif /* __FreeBSD__ */
#endif
/* ISA bus access functions for PnP. */
static int
{
}
static void
{
}
#ifdef LOADER_ZFS_SUPPORT
static void
i386_zfs_probe(void)
{
int unit;
/*
* Open all the disks we can find and see if we can reconstruct
* ZFS pools from them.
*/
break;
}
}
#endif