uboot.c revision 1.4
1/* $NetBSD: uboot.c,v 1.4 2000/09/24 12:32:34 jdolecek Exp $ */ 2 3/*- 4 * Copyright (c) 1982, 1986, 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)boot.c 8.1 (Berkeley) 6/10/93 36 */ 37 38#include <sys/param.h> 39#include <sys/reboot.h> 40#include <sys/boot_flag.h> 41#include <a.out.h> 42 43#include <lib/libsa/stand.h> 44 45#include <hp300/stand/common/samachdep.h> 46 47/* 48 * Boot program... bits in `howto' determine whether boot stops to 49 * ask for system name. Boot device is derived from ROM provided 50 * information. 51 */ 52 53char line[100]; 54 55extern u_int opendev; 56extern char *lowram; 57extern int noconsole; 58 59/* 60 * XXX UFS accepts a /, NFS doesn't. 61 */ 62char *name; 63char *names[] = { 64 "netbsd", "netbsd.gz", 65 "netbsd.bak", "netbsd.bak.gz", 66 "netbsd.old", "netbsd.old.gz", 67 "onetbsd", "onetbsd.gz", 68 NULL 69}; 70#define NUMNAMES (sizeof(names) / sizeof(char *)) 71 72static int bdev, badapt, bctlr, bunit, bpart; 73 74main() 75{ 76 int currname = 0; 77 78 printf("\n"); 79 printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); 80 printf(">> (%s, %s)\n", bootprog_maker, bootprog_date); 81 printf(">> HP 9000/%s SPU\n", getmachineid()); 82 printf(">> Enter \"reset\" to reset system.\n"); 83 84 bdev = B_TYPE(bootdev); 85 badapt = B_ADAPTOR(bootdev); 86 bctlr = B_CONTROLLER(bootdev); 87 bunit = B_UNIT(bootdev); 88 bpart = B_PARTITION(bootdev); 89 90 for (;;) { 91 name = names[currname++]; 92 if (currname == NUMNAMES) 93 currname = 0; 94 95 if (!noconsole) { 96 howto = 0; 97 getbootdev(&howto); 98 } else 99 printf(": %s\n", name); 100 101 exec(name, lowram, howto); 102 printf("boot: %s\n", strerror(errno)); 103 } 104} 105 106getbootdev(howto) 107 int *howto; 108{ 109 char c, *ptr = line; 110 111 printf("Boot: [[[%s%d%c:]%s][-s][-a][-d][-v][-q]] :- ", 112 devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name); 113 114 if (tgets(line)) { 115 if (strcmp(line, "reset") == 0) { 116 call_req_reboot(); /* reset machine */ 117 printf("panic: can't reboot, halting\n"); 118 asm("stop #0x2700"); 119 } 120 while (c = *ptr) { 121 while (c == ' ') 122 c = *++ptr; 123 if (!c) 124 return; 125 if (c == '-') 126 while ((c = *++ptr) && c != ' ') 127 BOOT_FLAG(c, *howto); 128 else { 129 name = ptr; 130 while ((c = *++ptr) && c != ' '); 131 if (c) 132 *ptr++ = 0; 133 } 134 } 135 } else 136 printf("\n"); 137} 138