11.18Stsutsui/* $NetBSD: uboot.c,v 1.18 2022/12/11 06:20:08 tsutsui Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 1982, 1986, 1990, 1993 51.1Sthorpej * The Regents of the University of California. All rights reserved. 61.1Sthorpej * 71.1Sthorpej * Redistribution and use in source and binary forms, with or without 81.1Sthorpej * modification, are permitted provided that the following conditions 91.1Sthorpej * are met: 101.1Sthorpej * 1. Redistributions of source code must retain the above copyright 111.1Sthorpej * notice, this list of conditions and the following disclaimer. 121.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 131.1Sthorpej * notice, this list of conditions and the following disclaimer in the 141.1Sthorpej * documentation and/or other materials provided with the distribution. 151.10Sagc * 3. Neither the name of the University nor the names of its contributors 161.1Sthorpej * may be used to endorse or promote products derived from this software 171.1Sthorpej * without specific prior written permission. 181.1Sthorpej * 191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221.1Sthorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291.1Sthorpej * SUCH DAMAGE. 301.1Sthorpej * 311.1Sthorpej * @(#)boot.c 8.1 (Berkeley) 6/10/93 321.1Sthorpej */ 331.1Sthorpej 341.1Sthorpej#include <sys/param.h> 351.4Sjdolecek#include <sys/boot_flag.h> 361.1Sthorpej 371.1Sthorpej#include <lib/libsa/stand.h> 381.11Stsutsui#include <lib/libkern/libkern.h> 391.1Sthorpej 401.1Sthorpej#include <hp300/stand/common/samachdep.h> 411.1Sthorpej 421.1Sthorpej/* 431.1Sthorpej * Boot program... bits in `howto' determine whether boot stops to 441.1Sthorpej * ask for system name. Boot device is derived from ROM provided 451.1Sthorpej * information. 461.1Sthorpej */ 471.1Sthorpej 481.1Sthorpejchar line[100]; 491.1Sthorpej 501.1Sthorpej/* 511.1Sthorpej * XXX UFS accepts a /, NFS doesn't. 521.1Sthorpej */ 531.1Sthorpejchar *name; 541.1Sthorpejchar *names[] = { 551.2Sthorpej "netbsd", "netbsd.gz", 561.2Sthorpej "netbsd.bak", "netbsd.bak.gz", 571.2Sthorpej "netbsd.old", "netbsd.old.gz", 581.2Sthorpej "onetbsd", "onetbsd.gz", 591.1Sthorpej NULL 601.1Sthorpej}; 611.1Sthorpej#define NUMNAMES (sizeof(names) / sizeof(char *)) 621.1Sthorpej 631.1Sthorpejstatic int bdev, badapt, bctlr, bunit, bpart; 641.1Sthorpej 651.12Stsutsuivoid main(void); 661.12Stsutsuivoid getbootdev(int *); 671.5Ssimonb 681.5Ssimonbvoid 691.12Stsutsuimain(void) 701.1Sthorpej{ 711.1Sthorpej int currname = 0; 721.1Sthorpej 731.1Sthorpej printf("\n"); 741.15Stsutsui printf(">> %s, Revision %s (from NetBSD %s)\n", 751.15Stsutsui bootprog_name, bootprog_rev, bootprog_kernrev); 761.3Sthorpej printf(">> HP 9000/%s SPU\n", getmachineid()); 771.1Sthorpej printf(">> Enter \"reset\" to reset system.\n"); 781.1Sthorpej 791.1Sthorpej bdev = B_TYPE(bootdev); 801.1Sthorpej badapt = B_ADAPTOR(bootdev); 811.1Sthorpej bctlr = B_CONTROLLER(bootdev); 821.1Sthorpej bunit = B_UNIT(bootdev); 831.1Sthorpej bpart = B_PARTITION(bootdev); 841.1Sthorpej 851.1Sthorpej for (;;) { 861.1Sthorpej name = names[currname++]; 871.1Sthorpej if (currname == NUMNAMES) 881.1Sthorpej currname = 0; 891.1Sthorpej 901.1Sthorpej if (!noconsole) { 911.1Sthorpej howto = 0; 921.1Sthorpej getbootdev(&howto); 931.1Sthorpej } else 941.1Sthorpej printf(": %s\n", name); 951.5Ssimonb exec_hp300(name, (u_long)lowram, howto); 961.1Sthorpej printf("boot: %s\n", strerror(errno)); 971.1Sthorpej } 981.1Sthorpej} 991.1Sthorpej 1001.5Ssimonbvoid 1011.12Stsutsuigetbootdev(int *howto) 1021.1Sthorpej{ 1031.1Sthorpej char c, *ptr = line; 1041.1Sthorpej 1051.7Sgmcgarry printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ", 1061.1Sthorpej devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name); 1071.1Sthorpej 1081.17Sdholland if (tgets(line, sizeof(line))) { 1091.1Sthorpej if (strcmp(line, "reset") == 0) { 1101.1Sthorpej call_req_reboot(); /* reset machine */ 1111.1Sthorpej printf("panic: can't reboot, halting\n"); 1121.14Sperry __asm("stop #0x2700"); 1131.1Sthorpej } 1141.5Ssimonb while ((c = *ptr) != '\0') { 1151.1Sthorpej while (c == ' ') 1161.1Sthorpej c = *++ptr; 1171.1Sthorpej if (!c) 1181.1Sthorpej return; 1191.1Sthorpej if (c == '-') 1201.1Sthorpej while ((c = *++ptr) && c != ' ') 1211.4Sjdolecek BOOT_FLAG(c, *howto); 1221.1Sthorpej else { 1231.1Sthorpej name = ptr; 1241.1Sthorpej while ((c = *++ptr) && c != ' '); 1251.1Sthorpej if (c) 1261.1Sthorpej *ptr++ = 0; 1271.1Sthorpej } 1281.1Sthorpej } 1291.1Sthorpej } else 1301.1Sthorpej printf("\n"); 1311.1Sthorpej} 132