1 /* $NetBSD: smallnet.c,v 1.6 2009/03/14 14:46:04 dsl Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <lib/libsa/stand.h>
33 #include <lib/libkern/libkern.h>
34 #include <lib/libz/zlib.h>
36 #include <sys/param.h>
37 #include <sys/exec_elf.h>
39 #include <machine/dec_prom.h>
41 #include "../common/common.h"
42 #include "../common/bootinfo.h"
45 typedef void (*entrypt
)(int, char **, int, const void *);
47 int main(int, char **);
50 * These variables and array will be patched to contain a kernel image
51 * and some information about the kernel.
54 int maxkernel_size
= KERNELSIZE
;
55 entrypt kernel_entry
= 0 /* (entrypt)0x80030000 */ /* XXX XXX XXX */;
56 u_long kernel_loadaddr
= 0 /* 0x80030000 */ /* XXX XXX XXX */;
57 int kernel_size
= 0 /* 387321 */ /* XXX XXX XXX */;
58 char kernel_image
[KERNELSIZE
] = "|This is the kernel image!\n";
62 * This gets arguments from the PROM, calls other routines to open
63 * and load the secondary boot loader called boot, and then transfers
64 * execution to that program.
66 * Argv[0] should be something like "rz(0,0,0)netbsd" on a DECstation 3100.
67 * Argv[0,1] should be something like "boot 5/rz0/netbsd" on a DECstation 5000.
68 * The argument "-a" means netbsd should do an automatic reboot.
71 main(int argc
, char **argv
)
76 struct btinfo_bootpath bi_bpath
;
78 printf("NetBSD/pmax " NETBSD_VERS
" " BOOT_TYPE_NAME
79 " Bootstrap, Revision %s\n", bootprog_rev
);
80 printf("(%s, %s)\n", bootprog_maker
, bootprog_date
);
82 /* initialise bootinfo structure early */
83 bi_init(BOOTINFO_ADDR
);
85 /* check for DS5000 boot */
86 if (strcmp(argv
[0], "boot") == 0) {
92 strncpy(bi_bpath
.bootpath
, name
, BTINFO_BOOTPATH_LEN
);
93 bi_add(&bi_bpath
, BTINFO_BOOTPATH
, sizeof(bi_bpath
));
95 destlen
= RELOC
- kernel_loadaddr
;
97 printf("Decompressing %d bytes to 0x%lx\n", kernel_size
,
99 ret
= uncompress((Bytef
*)kernel_loadaddr
, &destlen
, kernel_image
,
102 printf("Error decompressing kernel\n");
103 printf("libz error %d\n", ret
);
107 if (callv
== &callvec
)
108 kernel_entry(argc
, argv
, 0, 0);
110 kernel_entry(argc
, argv
, DEC_PROM_MAGIC
, callv
);