/*
* Copyright (c) 2001 Minoura Makoto
* 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
* documentation and/or other materials provided with the distribution.
*
* 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.
*/
static void
doboot(const char *file, int flags)
{
u_long marks[MARK_MAX];
int fd;
int ha; /* host adaptor */
int dev; /* device number in devspec[] */
int unit;
int part;
int bootdev;
int maj;
char *name;
short *p;
int loadflag;
struct fs_ops *fs;
printf("Starting %s, flags 0x%x\n", file, flags);
if (devparse(file, &ha, &dev, &unit, &part, &name) != 0) {
printf("XXX: unknown corruption in /boot.\n");
}
#ifdef DEBUG
if (file[0] == 'n') {
printf("dev = %x, unit = %d, name = %s\n",
dev, unit, name);
} else {
printf("ha = 0x%x, dev = %x, unit = %d, part = %c, name = %s\n",
ha, dev, unit, part + 'a', name);
}
#endif
if (dev == 3) { /* netboot */
bootdev = X68K_MAKEBOOTDEV(X68K_MAJOR_NE, unit, 0);
} else if (dev == 2) { /* FD */
bootdev = X68K_MAKEBOOTDEV(X68K_MAJOR_FD, unit & 3, 0);
} else { /* SCSI */
if (ha != 0) {
hostadaptor = ha;
}
if (hostadaptor == 0) {
printf("host adaptor must be specified.\n");
return;
}
maj = (dev == 0) ? X68K_MAJOR_SD : X68K_MAJOR_CD;
bootdev = X68K_MAKESCSIBOOTDEV(maj,
hostadaptor >> 4,
hostadaptor & 15,
unit & 7, 0, 0);
}
#ifdef DEBUG
printf("boot device = %x\n", bootdev);
if (file[0] == 'n') {
printf("type = %x, if = %d, unit = %d\n",
B_TYPE(bootdev),
B_X68K_SCSI_IF(bootdev),
B_X68K_SCSI_IF_UN(bootdev));
} else {
printf("type = %x, if = %d, unit = %d, id = %d, lun = %d, part = %c\n",
B_TYPE(bootdev),
B_X68K_SCSI_IF(bootdev),
B_X68K_SCSI_IF_UN(bootdev),
B_X68K_SCSI_ID(bootdev),
B_X68K_SCSI_LUN(bootdev),
B_X68K_SCSI_PART(bootdev) + 'a');
}
#endif
/*
* Choose the last entry of file_system[] at runtime.
*
* file_system[] is checked in turn from the beginning at all cases.
* Trying FS_OPS(ustarfs) for non-ustarfs displays "@" (as the
* mark which read a cylinder?). OTOH, trying FS_OPS(nfs) for
* non-nfs displays "must mount first" error message.
* It is better that neither is displayed and in other words you
* should not put these two into file_system[] at the same time.
* Therefore I choose one of these here.
*/
if (file[0] == 'n') {
fs = &file_system_nfs[0];
} else {
fs = &file_system_ustarfs[0];
}
memcpy(&file_system[nfsys - 1], fs, sizeof(*fs));
loadflag = LOAD_KERNEL;
if (file[0] == 'f')
loadflag &= ~LOAD_BACKWARDS;
p = ((short*) marks[MARK_ENTRY]) - 1;
#ifdef DEBUG
printf("Kernel Version: 0x%x\n", *p);
#endif
if (*p != 0x4e73 && *p != 0) {
/*
* XXX temporary solution; compatibility loader
* must be written.
*/
printf("This kernel is too new to be loaded by "
"this version of /boot.\n");
return;
}
/*
* Arguments from the boot block:
* bootdev - specifies the device from which /boot was read, in
* bootdev format.
*/
void
bootmain(int bootdev)
{
u_int sram_memsize;
u_int probed_memsize;