1 /* $NetBSD: smallnet.c,v 1.4 1999/11/27 07:07:04 simonb Exp $ */ 2 3 /*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Simon Burge. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <lib/libsa/stand.h> 40 #include <lib/libkern/libkern.h> 41 #include <lib/libz/zlib.h> 42 43 #include <sys/param.h> 44 #include <sys/exec_elf.h> 45 46 #include <machine/dec_prom.h> 47 48 #include "../common/common.h" 49 #include "../common/bootinfo.h" 50 51 52 typedef void (*entrypt) __P((int, char **, int, const void *)); 53 54 int main __P((int, char **)); 55 56 /* 57 * These variables and array will be patched to contain a kernel image 58 * and some information about the kernel. 59 */ 60 61 int maxkernel_size = KERNELSIZE; 62 entrypt kernel_entry = 0 /* (entrypt)0x80030000 */ /* XXX XXX XXX */; 63 u_long kernel_loadaddr = 0 /* 0x80030000 */ /* XXX XXX XXX */; 64 int kernel_size = 0 /* 387321 */ /* XXX XXX XXX */; 65 char kernel_image[KERNELSIZE] = "|This is the kernel image!\n"; 66 67 68 /* 69 * This gets arguments from the PROM, calls other routines to open 70 * and load the secondary boot loader called boot, and then transfers 71 * execution to that program. 72 * 73 * Argv[0] should be something like "rz(0,0,0)netbsd" on a DECstation 3100. 74 * Argv[0,1] should be something like "boot 5/rz0/netbsd" on a DECstation 5000. 75 * The argument "-a" means netbsd should do an automatic reboot. 76 */ 77 int 78 main(argc, argv) 79 int argc; 80 char **argv; 81 { 82 int ret; 83 char *name; 84 uLongf destlen; 85 struct btinfo_bootpath bi_bpath; 86 87 printf("NetBSD/pmax " NETBSD_VERS " " BOOT_TYPE_NAME 88 " Bootstrap, Revision %s\n", bootprog_rev); 89 printf("(%s, %s)\n", bootprog_maker, bootprog_date); 90 91 /* initialise bootinfo structure early */ 92 bi_init(BOOTINFO_ADDR); 93 94 /* check for DS5000 boot */ 95 if (strcmp(argv[0], "boot") == 0) { 96 argc--; 97 argv++; 98 } 99 name = *argv; 100 101 strncpy(bi_bpath.bootpath, name, BTINFO_BOOTPATH_LEN); 102 bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath)); 103 104 destlen = RELOC - kernel_loadaddr; 105 printf("\n"); 106 printf("Decompressing %d bytes to 0x%lx\n", kernel_size, 107 kernel_loadaddr); 108 ret = uncompress((Bytef *)kernel_loadaddr, &destlen, kernel_image, 109 kernel_size); 110 if (ret != Z_OK) { 111 printf("Error decompressing kernel\n"); 112 printf("libz error %d\n", ret); 113 return (1); 114 } 115 116 if (callv == &callvec) 117 kernel_entry(argc, argv, 0, 0); 118 else 119 kernel_entry(argc, argv, DEC_PROM_MAGIC, callv); 120 return (1); 121 } 122