smallnet.c revision 1.2 1 /* $NetBSD: smallnet.c,v 1.2 1999/11/12 01:37:43 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 <stand.h>
40 #include <sys/param.h>
41 #include <sys/exec_elf.h>
42 #include <machine/dec_prom.h>
43 #include <lib/libz/zlib.h>
44
45 #include "common.h"
46 #include "bootinfo.h"
47
48
49 typedef void (*entrypt) __P((int, char **, int, const void *));
50
51 int main __P((int, char **));
52
53 /*
54 * These variables and array will be patched to contain a kernel image
55 * and some information about the kernel.
56 */
57
58 int maxkernel_size = KERNELSIZE;
59 entrypt kernel_entry = 0 /* (entrypt)0x80030000 */ /* XXX XXX XXX */;
60 u_long kernel_loadaddr = 0 /* 0x80030000 */ /* XXX XXX XXX */;
61 int kernel_size = 0 /* 387321 */ /* XXX XXX XXX */;
62 char kernel_image[KERNELSIZE] = "|This is the kernel image!\n";
63
64
65 /*
66 * This gets arguments from the PROM, calls other routines to open
67 * and load the secondary boot loader called boot, and then transfers
68 * execution to that program.
69 *
70 * Argv[0] should be something like "rz(0,0,0)netbsd" on a DECstation 3100.
71 * Argv[0,1] should be something like "boot 5/rz0/netbsd" on a DECstation 5000.
72 * The argument "-a" means netbsd should do an automatic reboot.
73 */
74 int
75 main(argc, argv)
76 int argc;
77 char **argv;
78 {
79 int ret;
80 char *name;
81 uLongf destlen;
82 struct btinfo_bootpath bi_bpath;
83
84 printf("NetBSD/pmax " NETBSD_VERS " " BOOT_TYPE_NAME
85 " Bootstrap, Revision %s\n", bootprog_rev);
86 printf("(%s, %s)\n", bootprog_maker, bootprog_date);
87
88 /* initialise bootinfo structure early */
89 bi_init(BOOTINFO_ADDR);
90
91 /* check for DS5000 boot */
92 if (strcmp(argv[0], "boot") == 0) {
93 argc--;
94 argv++;
95 }
96 name = *argv;
97
98 strncpy(bi_bpath.bootpath, name, BTINFO_BOOTPATH_LEN);
99 bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath));
100
101 destlen = RELOC - kernel_loadaddr;
102 printf("\n");
103 printf("Decompressing %d bytes to 0x%lx\n", kernel_size,
104 kernel_loadaddr);
105 ret = uncompress((Bytef *)kernel_loadaddr, &destlen, kernel_image,
106 kernel_size);
107 if (ret != Z_OK) {
108 printf("Error decompressing kernel\n");
109 printf("libz error %d\n", ret);
110 return (1);
111 }
112
113 if (callv == &callvec)
114 kernel_entry(argc, argv, 0, 0);
115 else
116 kernel_entry(argc, argv, DEC_PROM_MAGIC, callv);
117 return (1);
118 }
119