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