uboot.c revision 1.4
11.4Sjdolecek/* $NetBSD: uboot.c,v 1.4 2000/09/24 12:32:34 jdolecek 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.1Sthorpej * 3. All advertising materials mentioning features or use of this software 161.1Sthorpej * must display the following acknowledgement: 171.1Sthorpej * This product includes software developed by the University of 181.1Sthorpej * California, Berkeley and its contributors. 191.1Sthorpej * 4. Neither the name of the University nor the names of its contributors 201.1Sthorpej * may be used to endorse or promote products derived from this software 211.1Sthorpej * without specific prior written permission. 221.1Sthorpej * 231.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.1Sthorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.1Sthorpej * SUCH DAMAGE. 341.1Sthorpej * 351.1Sthorpej * @(#)boot.c 8.1 (Berkeley) 6/10/93 361.1Sthorpej */ 371.1Sthorpej 381.1Sthorpej#include <sys/param.h> 391.1Sthorpej#include <sys/reboot.h> 401.4Sjdolecek#include <sys/boot_flag.h> 411.1Sthorpej#include <a.out.h> 421.1Sthorpej 431.1Sthorpej#include <lib/libsa/stand.h> 441.1Sthorpej 451.1Sthorpej#include <hp300/stand/common/samachdep.h> 461.1Sthorpej 471.1Sthorpej/* 481.1Sthorpej * Boot program... bits in `howto' determine whether boot stops to 491.1Sthorpej * ask for system name. Boot device is derived from ROM provided 501.1Sthorpej * information. 511.1Sthorpej */ 521.1Sthorpej 531.1Sthorpejchar line[100]; 541.1Sthorpej 551.1Sthorpejextern u_int opendev; 561.1Sthorpejextern char *lowram; 571.1Sthorpejextern int noconsole; 581.1Sthorpej 591.1Sthorpej/* 601.1Sthorpej * XXX UFS accepts a /, NFS doesn't. 611.1Sthorpej */ 621.1Sthorpejchar *name; 631.1Sthorpejchar *names[] = { 641.2Sthorpej "netbsd", "netbsd.gz", 651.2Sthorpej "netbsd.bak", "netbsd.bak.gz", 661.2Sthorpej "netbsd.old", "netbsd.old.gz", 671.2Sthorpej "onetbsd", "onetbsd.gz", 681.1Sthorpej NULL 691.1Sthorpej}; 701.1Sthorpej#define NUMNAMES (sizeof(names) / sizeof(char *)) 711.1Sthorpej 721.1Sthorpejstatic int bdev, badapt, bctlr, bunit, bpart; 731.1Sthorpej 741.1Sthorpejmain() 751.1Sthorpej{ 761.1Sthorpej int currname = 0; 771.1Sthorpej 781.1Sthorpej printf("\n"); 791.1Sthorpej printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); 801.1Sthorpej printf(">> (%s, %s)\n", bootprog_maker, bootprog_date); 811.3Sthorpej printf(">> HP 9000/%s SPU\n", getmachineid()); 821.1Sthorpej printf(">> Enter \"reset\" to reset system.\n"); 831.1Sthorpej 841.1Sthorpej bdev = B_TYPE(bootdev); 851.1Sthorpej badapt = B_ADAPTOR(bootdev); 861.1Sthorpej bctlr = B_CONTROLLER(bootdev); 871.1Sthorpej bunit = B_UNIT(bootdev); 881.1Sthorpej bpart = B_PARTITION(bootdev); 891.1Sthorpej 901.1Sthorpej for (;;) { 911.1Sthorpej name = names[currname++]; 921.1Sthorpej if (currname == NUMNAMES) 931.1Sthorpej currname = 0; 941.1Sthorpej 951.1Sthorpej if (!noconsole) { 961.1Sthorpej howto = 0; 971.1Sthorpej getbootdev(&howto); 981.1Sthorpej } else 991.1Sthorpej printf(": %s\n", name); 1001.1Sthorpej 1011.1Sthorpej exec(name, lowram, howto); 1021.1Sthorpej printf("boot: %s\n", strerror(errno)); 1031.1Sthorpej } 1041.1Sthorpej} 1051.1Sthorpej 1061.1Sthorpejgetbootdev(howto) 1071.1Sthorpej int *howto; 1081.1Sthorpej{ 1091.1Sthorpej char c, *ptr = line; 1101.1Sthorpej 1111.4Sjdolecek printf("Boot: [[[%s%d%c:]%s][-s][-a][-d][-v][-q]] :- ", 1121.1Sthorpej devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name); 1131.1Sthorpej 1141.1Sthorpej if (tgets(line)) { 1151.1Sthorpej if (strcmp(line, "reset") == 0) { 1161.1Sthorpej call_req_reboot(); /* reset machine */ 1171.1Sthorpej printf("panic: can't reboot, halting\n"); 1181.1Sthorpej asm("stop #0x2700"); 1191.1Sthorpej } 1201.1Sthorpej while (c = *ptr) { 1211.1Sthorpej while (c == ' ') 1221.1Sthorpej c = *++ptr; 1231.1Sthorpej if (!c) 1241.1Sthorpej return; 1251.1Sthorpej if (c == '-') 1261.1Sthorpej while ((c = *++ptr) && c != ' ') 1271.4Sjdolecek BOOT_FLAG(c, *howto); 1281.1Sthorpej else { 1291.1Sthorpej name = ptr; 1301.1Sthorpej while ((c = *++ptr) && c != ' '); 1311.1Sthorpej if (c) 1321.1Sthorpej *ptr++ = 0; 1331.1Sthorpej } 1341.1Sthorpej } 1351.1Sthorpej } else 1361.1Sthorpej printf("\n"); 1371.1Sthorpej} 138