boot.c revision 1.1
11.1Sfredette/* $NetBSD: boot.c,v 1.1 2001/06/14 12:57:16 fredette Exp $ */ 21.1Sfredette 31.1Sfredette/*- 41.1Sfredette * Copyright (c) 1982, 1986, 1990, 1993 51.1Sfredette * The Regents of the University of California. All rights reserved. 61.1Sfredette * 71.1Sfredette * Redistribution and use in source and binary forms, with or without 81.1Sfredette * modification, are permitted provided that the following conditions 91.1Sfredette * are met: 101.1Sfredette * 1. Redistributions of source code must retain the above copyright 111.1Sfredette * notice, this list of conditions and the following disclaimer. 121.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright 131.1Sfredette * notice, this list of conditions and the following disclaimer in the 141.1Sfredette * documentation and/or other materials provided with the distribution. 151.1Sfredette * 3. All advertising materials mentioning features or use of this software 161.1Sfredette * must display the following acknowledgement: 171.1Sfredette * This product includes software developed by the University of 181.1Sfredette * California, Berkeley and its contributors. 191.1Sfredette * 4. Neither the name of the University nor the names of its contributors 201.1Sfredette * may be used to endorse or promote products derived from this software 211.1Sfredette * without specific prior written permission. 221.1Sfredette * 231.1Sfredette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 241.1Sfredette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251.1Sfredette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261.1Sfredette * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271.1Sfredette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281.1Sfredette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 291.1Sfredette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 301.1Sfredette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311.1Sfredette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321.1Sfredette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331.1Sfredette * SUCH DAMAGE. 341.1Sfredette * 351.1Sfredette * @(#)boot.c 8.1 (Berkeley) 6/10/93 361.1Sfredette */ 371.1Sfredette 381.1Sfredette#include <sys/param.h> 391.1Sfredette#include <sys/reboot.h> 401.1Sfredette#include <machine/mon.h> 411.1Sfredette 421.1Sfredette#include <stand.h> 431.1Sfredette#include <loadfile.h> 441.1Sfredette#include "libsa.h" 451.1Sfredette 461.1Sfredette/* 471.1Sfredette * Default the name (really tape segment number). 481.1Sfredette * The defaults assume the following tape layout: 491.1Sfredette * segment 0: tapeboot 501.1Sfredette * segment 1: netbsd.sun3 (RAMDISK3) 511.1Sfredette * segment 2: netbsd.sun3x (RAMDISK3X) 521.1Sfredette * segment 3: miniroot image 531.1Sfredette * Therefore, the default name is "1" or "2" 541.1Sfredette * for sun3 and sun3x respectively. 551.1Sfredette */ 561.1Sfredette 571.1Sfredettechar defname[32] = "1"; 581.1Sfredettechar line[80]; 591.1Sfredette 601.1Sfredetteint 611.1Sfredettemain() 621.1Sfredette{ 631.1Sfredette char *cp, *file; 641.1Sfredette void *entry; 651.1Sfredette u_long marks[MARK_MAX]; 661.1Sfredette int fd; 671.1Sfredette 681.1Sfredette printf(">> %s tapeboot [%s]\n", bootprog_name, bootprog_rev); 691.1Sfredette prom_get_boot_info(); 701.1Sfredette 711.1Sfredette /* 721.1Sfredette * Can not hold open the tape device as is done 731.1Sfredette * in the other boot programs because it does 741.1Sfredette * its position-to-segment on open. 751.1Sfredette */ 761.1Sfredette 771.1Sfredette /* If running on a Sun3X, use segment 2. */ 781.1Sfredette if (_is3x) 791.1Sfredette defname[0] = '2'; 801.1Sfredette file = defname; 811.1Sfredette 821.1Sfredette cp = prom_bootfile; 831.1Sfredette if (cp && *cp) 841.1Sfredette file = cp; 851.1Sfredette 861.1Sfredette for (;;) { 871.1Sfredette if (prom_boothow & RB_ASKNAME) { 881.1Sfredette printf("tapeboot: segment? [%s]: ", defname); 891.1Sfredette gets(line); 901.1Sfredette if (line[0]) 911.1Sfredette file = line; 921.1Sfredette else 931.1Sfredette file = defname; 941.1Sfredette } else 951.1Sfredette printf("tapeboot: loading segment %s\n", file); 961.1Sfredette 971.1Sfredette marks[MARK_START] = KERN_LOADADDR; 981.1Sfredette if ((fd = loadfile(file, marks, LOAD_KERNEL)) != -1) { 991.1Sfredette break; 1001.1Sfredette } 1011.1Sfredette printf("tapeboot: segment %s: %s\n", file, strerror(errno)); 1021.1Sfredette prom_boothow |= RB_ASKNAME; 1031.1Sfredette } 1041.1Sfredette close(fd); 1051.1Sfredette 1061.1Sfredette entry = (void *)marks[MARK_ENTRY]; 1071.1Sfredette printf("Starting program at 0x%x\n", entry); 1081.1Sfredette chain_to(entry); 1091.1Sfredette} 110