1 /* $OpenBSD: netboot.c,v 1.3 1996/11/27 19:54:56 niklas Exp $ */ 2 /* $NetBSD: netboot.c,v 1.1 1996/09/18 20:03:12 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Ralph Campbell. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)boot.c 8.1 (Berkeley) 6/10/93 40 */ 41 42 #include <lib/libkern/libkern.h> 43 #include <lib/libsa/stand.h> 44 45 #include <sys/param.h> 46 #include <sys/exec.h> 47 #include <sys/exec_ecoff.h> 48 49 #include <machine/rpb.h> 50 #include <machine/prom.h> 51 52 #define _KERNEL 53 #include "include/pte.h" 54 55 int loadfile __P((char *, u_int64_t *)); 56 57 char boot_file[128]; 58 char boot_flags[128]; 59 60 extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; 61 62 vm_offset_t ffp_save, ptbr_save; 63 64 int debug; 65 66 void 67 main() 68 { 69 u_int64_t entry; 70 71 /* Init prom callback vector. */ 72 init_prom_calls(); 73 74 /* print a banner */ 75 printf("\n"); 76 printf("%s, Revision %s\n", bootprog_name, bootprog_rev); 77 printf("(%s, %s)\n", bootprog_maker, bootprog_date); 78 printf("\n"); 79 80 /* switch to OSF pal code. */ 81 OSFpal(); 82 83 printf("\n"); 84 85 prom_getenv(PROM_E_BOOTED_FILE, boot_file, sizeof(boot_file)); 86 prom_getenv(PROM_E_BOOTED_OSFLAGS, boot_flags, sizeof(boot_flags)); 87 88 if (boot_file[0] == '\0') 89 bcopy("bsd", boot_file, sizeof "bsd"); 90 91 (void)printf("Boot: %s %s\n", boot_file, boot_flags); 92 93 if (!loadfile(boot_file, &entry)) { 94 (void)printf("Entering kernel at 0x%lx...\n", entry); 95 (*(void (*)())entry)(ffp_save, ptbr_save, 0); 96 } 97 98 (void)printf("Boot failed! Halting...\n"); 99 halt(); 100 } 101