1 /* $NetBSD: boot.c,v 1.17 2008/05/26 16:28:39 kiyohara Exp $ */
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <lib/libsa/stand.h>
35 #include <lib/libsa/loadfile.h>
36 #include <lib/libkern/libkern.h>
37 #include <sys/boot_flag.h>
38 #include <sys/reboot.h>
39 #include <machine/bootinfo.h>
40 #include <machine/cpu.h>
46 "fd(0,1,0)netbsd", "fd(0,1,0)netbsd.gz",
47 "fd(0,1,0)netbsd.old", "fd(0,1,0)netbsd.old.gz",
48 "fd(0,1,0)onetbsd", "fd(0,1,0)onetbsd.gz"
50 #define NUMNAMES (sizeof (names) / sizeof (names[0]))
53 char namebuf
[NAMELEN
];
54 char nametmp
[NAMELEN
];
56 struct btinfo_memory btinfo_memory
;
57 struct btinfo_console btinfo_console
;
58 struct btinfo_clock btinfo_clock
;
60 extern char bootprog_name
[], bootprog_rev
[], bootprog_maker
[], bootprog_date
[];
63 void exec_kernel(char *, void *);
80 cnname
= cninit(&addr
, &speed
);
85 bootinfo
= (void *)0x3030;
90 btinfo_memory
.common
.next
= sizeof (btinfo_memory
);
91 btinfo_memory
.common
.type
= BTINFO_MEMORY
;
92 btinfo_memory
.memsize
= *(int *)0x3010;
97 btinfo_console
.common
.next
= sizeof (btinfo_console
);
98 btinfo_console
.common
.type
= BTINFO_CONSOLE
;
99 strcpy(btinfo_console
.devname
, cnname
);
100 btinfo_console
.addr
= addr
;
101 btinfo_console
.speed
= speed
;
106 btinfo_clock
.common
.next
= 0;
107 btinfo_clock
.common
.type
= BTINFO_CLOCK
;
108 btinfo_clock
.ticks_per_sec
= TICKS_PER_SEC
;
111 memcpy(p
, (void *)&btinfo_memory
, sizeof (btinfo_memory
));
112 p
+= sizeof (btinfo_memory
);
113 memcpy(p
, (void *)&btinfo_console
, sizeof (btinfo_console
));
114 p
+= sizeof (btinfo_console
);
115 memcpy(p
, (void *)&btinfo_clock
, sizeof (btinfo_clock
));
118 * attached kernel check
122 runCPU1((void *)start_CPU1
);
123 wait_for(&CPU1_alive
);
125 printf(">> %s, Revision %s\n", bootprog_name
, bootprog_rev
);
126 printf(">> (%s, %s)\n", bootprog_maker
, bootprog_date
);
127 printf(">> Memory: %d k\n", btinfo_memory
.memsize
/ 1024);
134 exec_kernel(name
, bootinfo
);
142 exec_kernel(char *name
, void *bootinfo
)
146 u_long marks
[MARK_MAX
];
151 #endif /* DBMONITOR */
153 memset(namebuf
, 0, sizeof (namebuf
));
154 (void)tgets(namebuf
);
160 if (*(++ptr
) == NULL
) {
168 #endif /* DBMONITOR */
175 while ((c
= *++ptr
) && c
!= ' ')
179 while ((c
= *++ptr
) && c
!= ' ');
186 printf("Loading %s\n", name
);
188 marks
[MARK_START
] = 0;
189 if (loadfile(name
, marks
, LOAD_ALL
) == 0) {
195 #endif /* DBMONITOR */
197 printf("start=0x%lx\n\n", marks
[MARK_ENTRY
]);
199 __syncicache((void *)marks
[MARK_ENTRY
],
200 (u_int
)marks
[MARK_SYM
] - (u_int
)marks
[MARK_ENTRY
]);
202 *(volatile u_long
*)0x0080 = marks
[MARK_ENTRY
];
203 run((void *)marks
[MARK_SYM
],
204 (void *)marks
[MARK_END
],
207 (void *)marks
[MARK_ENTRY
]);