smallnet.c revision 1.7.6.1 1 1.7.6.1 jruoho /* $NetBSD: smallnet.c,v 1.7.6.1 2011/06/06 09:06:25 jruoho 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 *
19 1.1 simonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 simonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 simonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 simonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 simonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 simonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 simonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 simonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 simonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 simonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 simonb * POSSIBILITY OF SUCH DAMAGE.
30 1.1 simonb */
31 1.1 simonb
32 1.4 simonb #include <lib/libsa/stand.h>
33 1.4 simonb #include <lib/libkern/libkern.h>
34 1.4 simonb #include <lib/libz/zlib.h>
35 1.4 simonb
36 1.1 simonb #include <sys/param.h>
37 1.1 simonb #include <sys/exec_elf.h>
38 1.4 simonb
39 1.1 simonb #include <machine/dec_prom.h>
40 1.1 simonb
41 1.4 simonb #include "../common/common.h"
42 1.4 simonb #include "../common/bootinfo.h"
43 1.1 simonb
44 1.1 simonb
45 1.6 dsl typedef void (*entrypt)(int, char **, int, const void *);
46 1.1 simonb
47 1.6 dsl int main(int, char **);
48 1.1 simonb
49 1.1 simonb /*
50 1.1 simonb * These variables and array will be patched to contain a kernel image
51 1.1 simonb * and some information about the kernel.
52 1.1 simonb */
53 1.1 simonb
54 1.1 simonb int maxkernel_size = KERNELSIZE;
55 1.1 simonb entrypt kernel_entry = 0 /* (entrypt)0x80030000 */ /* XXX XXX XXX */;
56 1.1 simonb u_long kernel_loadaddr = 0 /* 0x80030000 */ /* XXX XXX XXX */;
57 1.1 simonb int kernel_size = 0 /* 387321 */ /* XXX XXX XXX */;
58 1.1 simonb char kernel_image[KERNELSIZE] = "|This is the kernel image!\n";
59 1.1 simonb
60 1.1 simonb
61 1.1 simonb /*
62 1.1 simonb * This gets arguments from the PROM, calls other routines to open
63 1.1 simonb * and load the secondary boot loader called boot, and then transfers
64 1.1 simonb * execution to that program.
65 1.1 simonb *
66 1.1 simonb * Argv[0] should be something like "rz(0,0,0)netbsd" on a DECstation 3100.
67 1.1 simonb * Argv[0,1] should be something like "boot 5/rz0/netbsd" on a DECstation 5000.
68 1.1 simonb * The argument "-a" means netbsd should do an automatic reboot.
69 1.1 simonb */
70 1.1 simonb int
71 1.7 dsl main(int argc, char **argv)
72 1.1 simonb {
73 1.1 simonb int ret;
74 1.1 simonb char *name;
75 1.1 simonb uLongf destlen;
76 1.1 simonb struct btinfo_bootpath bi_bpath;
77 1.1 simonb
78 1.1 simonb printf("NetBSD/pmax " NETBSD_VERS " " BOOT_TYPE_NAME
79 1.1 simonb " Bootstrap, Revision %s\n", bootprog_rev);
80 1.1 simonb
81 1.1 simonb /* initialise bootinfo structure early */
82 1.1 simonb bi_init(BOOTINFO_ADDR);
83 1.1 simonb
84 1.1 simonb /* check for DS5000 boot */
85 1.1 simonb if (strcmp(argv[0], "boot") == 0) {
86 1.1 simonb argc--;
87 1.1 simonb argv++;
88 1.1 simonb }
89 1.1 simonb name = *argv;
90 1.1 simonb
91 1.1 simonb strncpy(bi_bpath.bootpath, name, BTINFO_BOOTPATH_LEN);
92 1.1 simonb bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath));
93 1.1 simonb
94 1.1 simonb destlen = RELOC - kernel_loadaddr;
95 1.1 simonb printf("\n");
96 1.1 simonb printf("Decompressing %d bytes to 0x%lx\n", kernel_size,
97 1.1 simonb kernel_loadaddr);
98 1.1 simonb ret = uncompress((Bytef *)kernel_loadaddr, &destlen, kernel_image,
99 1.1 simonb kernel_size);
100 1.1 simonb if (ret != Z_OK) {
101 1.1 simonb printf("Error decompressing kernel\n");
102 1.1 simonb printf("libz error %d\n", ret);
103 1.1 simonb return (1);
104 1.1 simonb }
105 1.1 simonb
106 1.1 simonb if (callv == &callvec)
107 1.1 simonb kernel_entry(argc, argv, 0, 0);
108 1.1 simonb else
109 1.1 simonb kernel_entry(argc, argv, DEC_PROM_MAGIC, callv);
110 1.1 simonb return (1);
111 1.1 simonb }
112