1 /* $NetBSD: bootxx.c,v 1.14 2009/03/18 16:00:10 cegger Exp $ */
4 * Copyright (c) 1995 Waldi Ravens.
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.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Waldi Ravens.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #define boot_BSD bsd_startup
35 #include <lib/libsa/stand.h>
36 #include <atari_stand.h>
39 #include <sys/boot_flag.h>
41 #include <sys/reboot.h>
42 #include <machine/cpu.h>
44 typedef int (*bxxx_t
)(void *, void *, struct osdsc
*);
46 int bootxx(void *, void *, int);
47 void boot_BSD(struct kparamb
*) __attribute__((noreturn
));
48 int bootxxx(void *, void *, struct osdsc
*);
49 int load_booter(struct osdsc
*);
50 int usr_info(struct osdsc
*);
53 bootxx(void *readsector
, void *disklabel
, int autoboot
)
55 static osdsc_t os_desc
;
56 extern char end
[], edata
[];
57 osdsc_t
*od
= &os_desc
;
58 bxxx_t bootxxx
= (bxxx_t
)(LOADADDR3
);
60 memset(edata
, 0, end
- edata
);
61 setheap(end
, (void*)(LOADADDR3
- 4));
63 printf("\033v\nNetBSD/atari secondary bootloader"
64 " ($Revision: 1.15 $)\n\n");
66 if (init_dskio(readsector
, disklabel
, -1))
70 od
->rootfs
= 0; /* partition a */
71 od
->osname
= "/netbsd";
72 od
->ostype
= &od
->osname
[1];
73 od
->boothowto
= (RB_RDONLY
);
78 od
->boothowto
= (RB_RDONLY
|RB_SINGLE
);
85 autoboot
= 0; /* in case auto boot fails */
87 if (init_dskio(readsector
, disklabel
, od
->rootfs
))
93 (*bootxxx
)(readsector
, disklabel
, od
);
100 usr_info(osdsc_t
*od
)
102 static char line
[800];
105 printf("\nEnter os-type [.%s] root-fs [:a] kernel [%s]"
106 " options [none]:\n\033e", od
->ostype
, od
->osname
);
118 if ((c
= *p
) >= 'a' && c
<= 'z')
119 od
->rootfs
= c
- 'a';
120 else if (c
>= 'A' && c
<= 'Z')
121 od
->rootfs
= c
- ('A' - 27);
131 od
->boothowto
&= ~RB_SINGLE
;
133 od
->boothowto
|= RB_ASKNAME
;
135 BOOT_FLAG(c
, od
->boothowto
);
147 while ((c
= *p
) && !isspace(c
))
157 case 'n': /* NetBSD */
159 case 'l': /* Linux */
171 load_booter(osdsc_t
*od
)
174 u_char
*bstart
= (u_char
*)(LOADADDR3
);
177 char *boot_names
[] = { /* 3rd level boot names */
178 "/boot.atari", /* in order of preference */
181 NULL
}; /* NULL terminated! */
184 * Read booter's exec-header.
186 for (fname
= boot_names
[0]; fname
!= NULL
; fname
++) {
187 if ((fd
= open(fname
, 0)) < 0)
188 printf("Cannot open '%s'\n", fname
);
194 while ((bsize
= read(fd
, bstart
, 1024)) > 0) {
205 printf("Halting...\n");