1 /* $NetBSD: loadbsd.c,v 1.20 2009/03/18 10:22:26 cegger Exp $ */
4 * Copyright (c) 1995 L. Weppelman
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * NetBSD loader for the Atari-TT.
43 char *Progname
; /* How are we called */
44 int d_flag
= 0; /* Output debugging output? */
45 int h_flag
= 0; /* show help */
46 int N_flag
= 0; /* No symbols? */
47 int s_flag
= 0; /* St-ram only */
48 int t_flag
= 0; /* Just test, do not execute */
49 int v_flag
= 0; /* show version */
51 const char version
[] = "$Revision: 1.21 $";
54 * Default name of kernel to boot, large enough to patch
56 char kname
[80] = "n:/netbsd";
58 static osdsc_t kernelparms
;
60 void help
PROTO((void));
61 void usage
PROTO((void));
62 void get_sys_info
PROTO((osdsc_t
*));
63 void start_kernel
PROTO((osdsc_t
*));
66 main(int argc
, char **argv
)
82 od
->boothowto
= RB_SINGLE
;
84 while ((ch
= getopt(argc
, argv
, "abdDhNstVwo:S:T:")) != -1) {
87 od
->boothowto
&= ~(RB_SINGLE
);
88 od
->boothowto
|= RB_AUTOBOOT
;
91 od
->boothowto
|= RB_ASKNAME
;
94 od
->boothowto
|= RB_KDB
;
106 redirect_output(optarg
);
112 od
->stmem_size
= atoi(optarg
);
118 od
->ttmem_size
= atoi(optarg
);
133 strcpy(kname
, argv
[0]);
138 eprintf("%s\r\n", version
);
141 * Get system info to pass to NetBSD
145 eprintf("Machine info:\r\n");
146 eprintf("ST-RAM size\t: %10d bytes\r\n",od
->stmem_size
);
147 eprintf("TT-RAM size\t: %10d bytes\r\n",od
->ttmem_size
);
148 eprintf("TT-RAM start\t: 0x%08x\r\n", od
->ttmem_start
);
149 eprintf("Cpu-type\t: 0x%08x\r\n", od
->cputype
);
153 * Find the kernel to boot and read it's exec-header
155 if ((fd
= open(kname
, O_RDONLY
)) < 0)
156 fatal(-1, "Cannot open kernel '%s'", kname
);
157 if ((err
= elf_load(fd
, od
, &errmsg
, !N_flag
)) == -1) {
161 if (err
= aout_load(fd
, od
, &errmsg
, !N_flag
)) {
163 errmsg
= "Not an ELF or NMAGIC file '%s'";
164 fatal(-1, errmsg
, kname
);
175 eprintf("\r\nKernel info:\r\n");
176 eprintf("Kernel loadaddr\t: 0x%08x\r\n", od
->kstart
);
177 eprintf("Kernel size\t: %10d bytes\r\n", od
->ksize
);
178 eprintf("Kernel entry\t: 0x%08x\r\n", od
->kentry
);
179 eprintf("Kernel esym\t: 0x%08x\r\n", od
->k_esym
);
186 eprintf("Kernel '%s' was loaded OK\r\n", kname
);
192 get_sys_info(osdsc_t
*od
)
200 if (!(od
->cputype
& ATARI_ANYCPU
))
201 fatal(-1, "Cannot determine CPU-type");
205 od
->ttmem_size
= od
->ttmem_start
= 0;
212 NetBSD loader for the Atari-TT\r
214 Usage: %s [-abdhstVD] [-S <stram-size>] [-T <ttram-size>] [kernel]\r
216 Description of options:\r
218 \t-a Boot up to multi-user mode.\r
219 \t-b Ask for root device to use.\r
220 \t-d Enter kernel debugger.\r
221 \t-D printout debug information while loading\r
222 \t-h What you're getting right now.\r
223 `t-N No symbols must be loaded.\r
224 \t-o Write output to both <output file> and stdout.\r
225 \t-s Use only ST-compatible RAM\r
226 \t-S Set amount of ST-compatible RAM\r
227 \t-T Set amount of TT-compatible RAM\r
228 \t-t Test the loader. It will do everything except executing the\r
230 \t-V Print loader version.\r
231 \t-w Wait for a keypress before exiting.\r
239 eprintf("Usage: %s [-abdhstVD] [-S <stram-size>] "
240 "[-T <ttram-size>] [kernel]\r\n", Progname
);
245 start_kernel(osdsc_t
*od
)
250 bsd_startup(&(od
->kp
));