exec.c revision 1.71 1 1.71 pgoyette /* $NetBSD: exec.c,v 1.71 2019/06/24 02:48:51 pgoyette Exp $ */
2 1.23 ad
3 1.62 maxv /*
4 1.40 ad * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 1.23 ad * All rights reserved.
6 1.23 ad *
7 1.23 ad * Redistribution and use in source and binary forms, with or without
8 1.23 ad * modification, are permitted provided that the following conditions
9 1.23 ad * are met:
10 1.23 ad * 1. Redistributions of source code must retain the above copyright
11 1.23 ad * notice, this list of conditions and the following disclaimer.
12 1.23 ad * 2. Redistributions in binary form must reproduce the above copyright
13 1.23 ad * notice, this list of conditions and the following disclaimer in the
14 1.23 ad * documentation and/or other materials provided with the distribution.
15 1.23 ad *
16 1.23 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.23 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.23 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.23 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.23 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.23 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.23 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.23 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.23 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.23 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.23 ad * POSSIBILITY OF SUCH DAMAGE.
27 1.23 ad */
28 1.1 perry
29 1.1 perry /*
30 1.1 perry * Copyright (c) 1982, 1986, 1990, 1993
31 1.1 perry * The Regents of the University of California. All rights reserved.
32 1.19 agc *
33 1.19 agc * Redistribution and use in source and binary forms, with or without
34 1.19 agc * modification, are permitted provided that the following conditions
35 1.19 agc * are met:
36 1.19 agc * 1. Redistributions of source code must retain the above copyright
37 1.19 agc * notice, this list of conditions and the following disclaimer.
38 1.19 agc * 2. Redistributions in binary form must reproduce the above copyright
39 1.19 agc * notice, this list of conditions and the following disclaimer in the
40 1.19 agc * documentation and/or other materials provided with the distribution.
41 1.19 agc * 3. Neither the name of the University nor the names of its contributors
42 1.19 agc * may be used to endorse or promote products derived from this software
43 1.19 agc * without specific prior written permission.
44 1.19 agc *
45 1.19 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 1.19 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 1.19 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 1.19 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 1.19 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 1.19 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 1.19 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 1.19 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 1.19 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 1.19 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 1.19 agc * SUCH DAMAGE.
56 1.19 agc *
57 1.19 agc * @(#)boot.c 8.1 (Berkeley) 6/10/93
58 1.19 agc */
59 1.19 agc
60 1.19 agc /*
61 1.1 perry * Copyright (c) 1996
62 1.1 perry * Matthias Drochner. All rights reserved.
63 1.1 perry * Copyright (c) 1996
64 1.1 perry * Perry E. Metzger. All rights reserved.
65 1.1 perry *
66 1.1 perry * Redistribution and use in source and binary forms, with or without
67 1.1 perry * modification, are permitted provided that the following conditions
68 1.1 perry * are met:
69 1.1 perry * 1. Redistributions of source code must retain the above copyright
70 1.1 perry * notice, this list of conditions and the following disclaimer.
71 1.1 perry * 2. Redistributions in binary form must reproduce the above copyright
72 1.1 perry * notice, this list of conditions and the following disclaimer in the
73 1.1 perry * documentation and/or other materials provided with the distribution.
74 1.1 perry *
75 1.1 perry * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
76 1.1 perry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
77 1.1 perry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
78 1.1 perry * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
79 1.1 perry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
80 1.1 perry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
81 1.1 perry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
82 1.1 perry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
83 1.1 perry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
84 1.1 perry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85 1.1 perry * SUCH DAMAGE.
86 1.1 perry *
87 1.1 perry * @(#)boot.c 8.1 (Berkeley) 6/10/93
88 1.1 perry */
89 1.1 perry
90 1.2 thorpej /*
91 1.62 maxv * Starts a NetBSD ELF kernel. The low level startup is done in startprog.S.
92 1.8 christos * This is a special version of exec.c to support use of XMS.
93 1.1 perry */
94 1.8 christos
95 1.1 perry #include <sys/param.h>
96 1.1 perry #include <sys/reboot.h>
97 1.1 perry
98 1.53 jakllsch #include <i386/multiboot.h>
99 1.33 joerg
100 1.1 perry #include <lib/libsa/stand.h>
101 1.23 ad #include <lib/libkern/libkern.h>
102 1.4 drochner
103 1.6 christos #include "loadfile.h"
104 1.1 perry #include "libi386.h"
105 1.4 drochner #include "bootinfo.h"
106 1.23 ad #include "bootmod.h"
107 1.42 jmcneill #include "vbe.h"
108 1.16 jdolecek #ifdef SUPPORT_PS2
109 1.16 jdolecek #include "biosmca.h"
110 1.16 jdolecek #endif
111 1.63 nonaka #ifdef EFIBOOT
112 1.63 nonaka #include "efiboot.h"
113 1.63 nonaka #undef DEBUG /* XXX */
114 1.63 nonaka #endif
115 1.1 perry
116 1.6 christos #define BOOT_NARGS 6
117 1.1 perry
118 1.23 ad #ifndef PAGE_SIZE
119 1.23 ad #define PAGE_SIZE 4096
120 1.23 ad #endif
121 1.23 ad
122 1.43 tsutsui #define MODULE_WARNING_SEC 5
123 1.41 jmcneill
124 1.4 drochner extern struct btinfo_console btinfo_console;
125 1.4 drochner
126 1.23 ad boot_module_t *boot_modules;
127 1.23 ad bool boot_modules_enabled = true;
128 1.23 ad bool kernel_loaded;
129 1.23 ad
130 1.47 uebayasi typedef struct userconf_command {
131 1.47 uebayasi char *uc_text;
132 1.47 uebayasi size_t uc_len;
133 1.47 uebayasi struct userconf_command *uc_next;
134 1.47 uebayasi } userconf_command_t;
135 1.47 uebayasi userconf_command_t *userconf_commands = NULL;
136 1.47 uebayasi
137 1.39 jmcneill static struct btinfo_framebuffer btinfo_framebuffer;
138 1.39 jmcneill
139 1.23 ad static struct btinfo_modulelist *btinfo_modulelist;
140 1.23 ad static size_t btinfo_modulelist_size;
141 1.23 ad static uint32_t image_end;
142 1.26 ad static char module_base[64] = "/";
143 1.40 ad static int howto;
144 1.23 ad
145 1.47 uebayasi static struct btinfo_userconfcommands *btinfo_userconfcommands = NULL;
146 1.47 uebayasi static size_t btinfo_userconfcommands_size = 0;
147 1.47 uebayasi
148 1.41 jmcneill static void module_init(const char *);
149 1.57 jakllsch static void module_add_common(const char *, uint8_t);
150 1.23 ad
151 1.47 uebayasi static void userconf_init(void);
152 1.47 uebayasi
153 1.67 nonaka static void extract_device(const char *, char *, size_t);
154 1.67 nonaka static void module_base_path(char *, size_t);
155 1.67 nonaka static int module_open(boot_module_t *, int, const char *, const char *,
156 1.67 nonaka bool);
157 1.67 nonaka
158 1.34 ad void
159 1.39 jmcneill framebuffer_configure(struct btinfo_framebuffer *fb)
160 1.39 jmcneill {
161 1.39 jmcneill if (fb)
162 1.39 jmcneill btinfo_framebuffer = *fb;
163 1.39 jmcneill else {
164 1.39 jmcneill btinfo_framebuffer.physaddr = 0;
165 1.39 jmcneill btinfo_framebuffer.flags = 0;
166 1.39 jmcneill }
167 1.39 jmcneill }
168 1.39 jmcneill
169 1.39 jmcneill void
170 1.34 ad module_add(char *name)
171 1.34 ad {
172 1.46 jmcneill return module_add_common(name, BM_TYPE_KMOD);
173 1.46 jmcneill }
174 1.46 jmcneill
175 1.46 jmcneill void
176 1.46 jmcneill splash_add(char *name)
177 1.46 jmcneill {
178 1.46 jmcneill return module_add_common(name, BM_TYPE_IMAGE);
179 1.46 jmcneill }
180 1.46 jmcneill
181 1.49 tls void
182 1.49 tls rnd_add(char *name)
183 1.49 tls {
184 1.49 tls return module_add_common(name, BM_TYPE_RND);
185 1.49 tls }
186 1.49 tls
187 1.51 jmcneill void
188 1.51 jmcneill fs_add(char *name)
189 1.51 jmcneill {
190 1.51 jmcneill return module_add_common(name, BM_TYPE_FS);
191 1.51 jmcneill }
192 1.51 jmcneill
193 1.46 jmcneill static void
194 1.57 jakllsch module_add_common(const char *name, uint8_t type)
195 1.46 jmcneill {
196 1.34 ad boot_module_t *bm, *bmp;
197 1.34 ad size_t len;
198 1.34 ad char *str;
199 1.34 ad
200 1.35 ad while (*name == ' ' || *name == '\t')
201 1.35 ad ++name;
202 1.35 ad
203 1.67 nonaka for (bm = boot_modules; bm != NULL; bm = bm->bm_next)
204 1.67 nonaka if (bm->bm_type == type && strcmp(bm->bm_path, name) == 0)
205 1.67 nonaka return;
206 1.67 nonaka
207 1.34 ad bm = alloc(sizeof(boot_module_t));
208 1.34 ad len = strlen(name) + 1;
209 1.34 ad str = alloc(len);
210 1.34 ad if (bm == NULL || str == NULL) {
211 1.34 ad printf("couldn't allocate module\n");
212 1.34 ad return;
213 1.34 ad }
214 1.34 ad memcpy(str, name, len);
215 1.34 ad bm->bm_path = str;
216 1.34 ad bm->bm_next = NULL;
217 1.46 jmcneill bm->bm_type = type;
218 1.34 ad if (boot_modules == NULL)
219 1.34 ad boot_modules = bm;
220 1.34 ad else {
221 1.34 ad for (bmp = boot_modules; bmp->bm_next;
222 1.34 ad bmp = bmp->bm_next)
223 1.34 ad ;
224 1.34 ad bmp->bm_next = bm;
225 1.34 ad }
226 1.34 ad }
227 1.34 ad
228 1.47 uebayasi void
229 1.47 uebayasi userconf_add(char *cmd)
230 1.47 uebayasi {
231 1.47 uebayasi userconf_command_t *uc;
232 1.47 uebayasi size_t len;
233 1.47 uebayasi char *text;
234 1.47 uebayasi
235 1.47 uebayasi while (*cmd == ' ' || *cmd == '\t')
236 1.47 uebayasi ++cmd;
237 1.47 uebayasi
238 1.47 uebayasi uc = alloc(sizeof(*uc));
239 1.47 uebayasi if (uc == NULL) {
240 1.47 uebayasi printf("couldn't allocate command\n");
241 1.47 uebayasi return;
242 1.47 uebayasi }
243 1.47 uebayasi
244 1.47 uebayasi len = strlen(cmd) + 1;
245 1.47 uebayasi text = alloc(len);
246 1.47 uebayasi if (text == NULL) {
247 1.47 uebayasi dealloc(uc, sizeof(*uc));
248 1.47 uebayasi printf("couldn't allocate command\n");
249 1.47 uebayasi return;
250 1.47 uebayasi }
251 1.47 uebayasi memcpy(text, cmd, len);
252 1.47 uebayasi
253 1.47 uebayasi uc->uc_text = text;
254 1.47 uebayasi uc->uc_len = len;
255 1.47 uebayasi uc->uc_next = NULL;
256 1.47 uebayasi
257 1.47 uebayasi if (userconf_commands == NULL)
258 1.47 uebayasi userconf_commands = uc;
259 1.47 uebayasi else {
260 1.47 uebayasi userconf_command_t *ucp;
261 1.47 uebayasi for (ucp = userconf_commands; ucp->uc_next != NULL;
262 1.47 uebayasi ucp = ucp->uc_next)
263 1.47 uebayasi ;
264 1.47 uebayasi ucp->uc_next = uc;
265 1.47 uebayasi }
266 1.47 uebayasi }
267 1.47 uebayasi
268 1.69 maxv struct btinfo_prekern bi_prekern;
269 1.69 maxv int has_prekern = 0;
270 1.69 maxv
271 1.69 maxv static int
272 1.69 maxv common_load_prekern(const char *file, u_long *basemem, u_long *extmem,
273 1.69 maxv physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
274 1.69 maxv {
275 1.69 maxv paddr_t kernpa_start, kernpa_end;
276 1.69 maxv char prekernpath[] = "/prekern";
277 1.70 maxv u_long prekern_start;
278 1.69 maxv int fd, flags;
279 1.69 maxv
280 1.69 maxv *extmem = getextmem();
281 1.69 maxv *basemem = getbasemem();
282 1.69 maxv
283 1.69 maxv marks[MARK_START] = loadaddr;
284 1.69 maxv
285 1.69 maxv /* Load the prekern (static) */
286 1.70 maxv flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM);
287 1.69 maxv if ((fd = loadfile(prekernpath, marks, flags)) == -1)
288 1.69 maxv return EIO;
289 1.69 maxv close(fd);
290 1.69 maxv
291 1.70 maxv prekern_start = marks[MARK_START];
292 1.70 maxv
293 1.70 maxv /* The kernel starts at 2MB. */
294 1.70 maxv marks[MARK_START] = loadaddr;
295 1.70 maxv marks[MARK_END] = loadaddr + (1UL << 21);
296 1.70 maxv kernpa_start = (1UL << 21);
297 1.69 maxv
298 1.69 maxv /* Load the kernel (dynamic) */
299 1.69 maxv flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0);
300 1.69 maxv if ((fd = loadfile(file, marks, flags)) == -1)
301 1.69 maxv return EIO;
302 1.69 maxv close(fd);
303 1.69 maxv
304 1.70 maxv kernpa_end = marks[MARK_END] - loadaddr;
305 1.69 maxv
306 1.69 maxv /* If the root fs type is unusual, load its module. */
307 1.69 maxv if (fsmod != NULL)
308 1.69 maxv module_add_common(fsmod, BM_TYPE_KMOD);
309 1.69 maxv
310 1.69 maxv bi_prekern.kernpa_start = kernpa_start;
311 1.69 maxv bi_prekern.kernpa_end = kernpa_end;
312 1.69 maxv BI_ADD(&bi_prekern, BTINFO_PREKERN, sizeof(struct btinfo_prekern));
313 1.69 maxv
314 1.69 maxv /*
315 1.69 maxv * Gather some information for the kernel. Do this after the
316 1.69 maxv * "point of no return" to avoid memory leaks.
317 1.69 maxv * (but before DOS might be trashed in the XMS case)
318 1.69 maxv */
319 1.69 maxv #ifdef PASS_BIOSGEOM
320 1.69 maxv bi_getbiosgeom();
321 1.69 maxv #endif
322 1.69 maxv #ifdef PASS_MEMMAP
323 1.69 maxv bi_getmemmap();
324 1.69 maxv #endif
325 1.69 maxv
326 1.70 maxv marks[MARK_START] = prekern_start;
327 1.69 maxv marks[MARK_END] = (((u_long)marks[MARK_END] + sizeof(int) - 1)) &
328 1.69 maxv (-sizeof(int));
329 1.69 maxv image_end = marks[MARK_END];
330 1.69 maxv kernel_loaded = true;
331 1.69 maxv
332 1.69 maxv return 0;
333 1.69 maxv }
334 1.69 maxv
335 1.32 joerg static int
336 1.32 joerg common_load_kernel(const char *file, u_long *basemem, u_long *extmem,
337 1.32 joerg physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
338 1.1 perry {
339 1.32 joerg int fd;
340 1.8 christos #ifdef XMS
341 1.62 maxv u_long xmsmem;
342 1.62 maxv physaddr_t origaddr = loadaddr;
343 1.8 christos #endif
344 1.8 christos
345 1.32 joerg *extmem = getextmem();
346 1.32 joerg *basemem = getbasemem();
347 1.8 christos
348 1.8 christos #ifdef XMS
349 1.8 christos if ((getextmem1() == 0) && (xmsmem = checkxms())) {
350 1.62 maxv u_long kernsize;
351 1.8 christos
352 1.8 christos /*
353 1.8 christos * With "CONSERVATIVE_MEMDETECT", extmem is 0 because
354 1.62 maxv * getextmem() is getextmem1(). Without, the "smart"
355 1.62 maxv * methods could fail to report all memory as well.
356 1.8 christos * xmsmem is a few kB less than the actual size, but
357 1.62 maxv * better than nothing.
358 1.8 christos */
359 1.32 joerg if (xmsmem > *extmem)
360 1.32 joerg *extmem = xmsmem;
361 1.21 junyoung /*
362 1.8 christos * Get the size of the kernel
363 1.8 christos */
364 1.8 christos marks[MARK_START] = loadaddr;
365 1.12 christos if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
366 1.32 joerg return EIO;
367 1.8 christos close(fd);
368 1.8 christos
369 1.8 christos kernsize = marks[MARK_END];
370 1.8 christos kernsize = (kernsize + 1023) / 1024;
371 1.8 christos
372 1.8 christos loadaddr = xmsalloc(kernsize);
373 1.8 christos if (!loadaddr)
374 1.21 junyoung return ENOMEM;
375 1.8 christos }
376 1.8 christos #endif
377 1.7 christos marks[MARK_START] = loadaddr;
378 1.29 christos if ((fd = loadfile(file, marks,
379 1.44 christos LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1)
380 1.32 joerg return EIO;
381 1.1 perry
382 1.8 christos close(fd);
383 1.10 drochner
384 1.50 dsl /* If the root fs type is unusual, load its module. */
385 1.50 dsl if (fsmod != NULL)
386 1.57 jakllsch module_add_common(fsmod, BM_TYPE_KMOD);
387 1.34 ad
388 1.10 drochner /*
389 1.10 drochner * Gather some information for the kernel. Do this after the
390 1.10 drochner * "point of no return" to avoid memory leaks.
391 1.10 drochner * (but before DOS might be trashed in the XMS case)
392 1.10 drochner */
393 1.10 drochner #ifdef PASS_BIOSGEOM
394 1.10 drochner bi_getbiosgeom();
395 1.10 drochner #endif
396 1.10 drochner #ifdef PASS_MEMMAP
397 1.10 drochner bi_getmemmap();
398 1.10 drochner #endif
399 1.8 christos
400 1.8 christos #ifdef XMS
401 1.8 christos if (loadaddr != origaddr) {
402 1.8 christos /*
403 1.14 ross * We now have done our last DOS IO, so we may
404 1.8 christos * trash the OS. Copy the data from the temporary
405 1.20 wiz * buffer to its real address.
406 1.8 christos */
407 1.8 christos marks[MARK_START] -= loadaddr;
408 1.8 christos marks[MARK_END] -= loadaddr;
409 1.8 christos marks[MARK_SYM] -= loadaddr;
410 1.8 christos marks[MARK_END] -= loadaddr;
411 1.8 christos ppbcopy(loadaddr, origaddr, marks[MARK_END]);
412 1.8 christos }
413 1.8 christos #endif
414 1.8 christos marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) &
415 1.8 christos (-sizeof(int));
416 1.23 ad image_end = marks[MARK_END];
417 1.23 ad kernel_loaded = true;
418 1.1 perry
419 1.32 joerg return 0;
420 1.32 joerg }
421 1.32 joerg
422 1.32 joerg int
423 1.40 ad exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy,
424 1.62 maxv void (*callback)(void))
425 1.32 joerg {
426 1.62 maxv uint32_t boot_argv[BOOT_NARGS];
427 1.62 maxv u_long marks[MARK_MAX];
428 1.32 joerg struct btinfo_symtab btinfo_symtab;
429 1.62 maxv u_long extmem;
430 1.62 maxv u_long basemem;
431 1.63 nonaka int error;
432 1.64 nonaka #ifdef EFIBOOT
433 1.64 nonaka int i;
434 1.64 nonaka #endif
435 1.32 joerg
436 1.32 joerg #ifdef DEBUG
437 1.62 maxv printf("exec: file=%s loadaddr=0x%lx\n", file ? file : "NULL",
438 1.62 maxv loadaddr);
439 1.32 joerg #endif
440 1.32 joerg
441 1.61 maxv BI_ALLOC(BTINFO_MAX);
442 1.32 joerg
443 1.32 joerg BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
444 1.32 joerg
445 1.40 ad howto = boothowto;
446 1.40 ad
447 1.56 jakllsch memset(marks, 0, sizeof(marks));
448 1.56 jakllsch
449 1.69 maxv if (has_prekern) {
450 1.69 maxv error = common_load_prekern(file, &basemem, &extmem, loadaddr,
451 1.69 maxv floppy, marks);
452 1.69 maxv } else {
453 1.69 maxv error = common_load_kernel(file, &basemem, &extmem, loadaddr,
454 1.69 maxv floppy, marks);
455 1.69 maxv }
456 1.63 nonaka if (error) {
457 1.63 nonaka errno = error;
458 1.32 joerg goto out;
459 1.63 nonaka }
460 1.67 nonaka #ifdef EFIBOOT
461 1.67 nonaka /* adjust to the real load address */
462 1.67 nonaka marks[MARK_START] -= efi_loadaddr;
463 1.67 nonaka marks[MARK_ENTRY] -= efi_loadaddr;
464 1.67 nonaka marks[MARK_DATA] -= efi_loadaddr;
465 1.67 nonaka /* MARK_NSYM */
466 1.67 nonaka marks[MARK_SYM] -= efi_loadaddr;
467 1.67 nonaka marks[MARK_END] -= efi_loadaddr;
468 1.67 nonaka #endif
469 1.32 joerg
470 1.31 joerg boot_argv[0] = boothowto;
471 1.31 joerg boot_argv[1] = 0;
472 1.31 joerg boot_argv[2] = vtophys(bootinfo); /* old cyl offset */
473 1.31 joerg boot_argv[3] = marks[MARK_END];
474 1.31 joerg boot_argv[4] = extmem;
475 1.31 joerg boot_argv[5] = basemem;
476 1.31 joerg
477 1.23 ad /* pull in any modules if necessary */
478 1.23 ad if (boot_modules_enabled) {
479 1.41 jmcneill module_init(file);
480 1.23 ad if (btinfo_modulelist) {
481 1.67 nonaka #ifdef EFIBOOT
482 1.67 nonaka /* convert module loaded address to paddr */
483 1.67 nonaka struct bi_modulelist_entry *bim;
484 1.67 nonaka bim = (void *)(btinfo_modulelist + 1);
485 1.67 nonaka for (i = 0; i < btinfo_modulelist->num; i++, bim++)
486 1.67 nonaka bim->base -= efi_loadaddr;
487 1.67 nonaka btinfo_modulelist->endpa -= efi_loadaddr;
488 1.67 nonaka #endif
489 1.23 ad BI_ADD(btinfo_modulelist, BTINFO_MODULELIST,
490 1.23 ad btinfo_modulelist_size);
491 1.23 ad }
492 1.23 ad }
493 1.1 perry
494 1.47 uebayasi userconf_init();
495 1.47 uebayasi if (btinfo_userconfcommands != NULL)
496 1.47 uebayasi BI_ADD(btinfo_userconfcommands, BTINFO_USERCONFCOMMANDS,
497 1.58 jakllsch btinfo_userconfcommands_size);
498 1.47 uebayasi
499 1.1 perry #ifdef DEBUG
500 1.8 christos printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
501 1.7 christos marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]);
502 1.1 perry #endif
503 1.1 perry
504 1.8 christos btinfo_symtab.nsym = marks[MARK_NSYM];
505 1.8 christos btinfo_symtab.ssym = marks[MARK_SYM];
506 1.8 christos btinfo_symtab.esym = marks[MARK_END];
507 1.8 christos BI_ADD(&btinfo_symtab, BTINFO_SYMTAB, sizeof(struct btinfo_symtab));
508 1.8 christos
509 1.42 jmcneill /* set new video mode if necessary */
510 1.42 jmcneill vbe_commit();
511 1.42 jmcneill BI_ADD(&btinfo_framebuffer, BTINFO_FRAMEBUFFER,
512 1.42 jmcneill sizeof(struct btinfo_framebuffer));
513 1.42 jmcneill
514 1.40 ad if (callback != NULL)
515 1.40 ad (*callback)();
516 1.63 nonaka #ifdef EFIBOOT
517 1.64 nonaka /* Copy bootinfo to safe arena. */
518 1.64 nonaka for (i = 0; i < bootinfo->nentries; i++) {
519 1.64 nonaka struct btinfo_common *bi = (void *)(u_long)bootinfo->entry[i];
520 1.64 nonaka char *p = alloc(bi->len);
521 1.64 nonaka memcpy(p, bi, bi->len);
522 1.64 nonaka bootinfo->entry[i] = vtophys(p);
523 1.64 nonaka }
524 1.64 nonaka
525 1.65 nonaka efi_kernel_start = marks[MARK_START];
526 1.70 maxv efi_kernel_size = image_end - (efi_loadaddr + efi_kernel_start);
527 1.63 nonaka #endif
528 1.15 dbj startprog(marks[MARK_ENTRY], BOOT_NARGS, boot_argv,
529 1.62 maxv x86_trunc_page(basemem * 1024));
530 1.1 perry panic("exec returned");
531 1.1 perry
532 1.4 drochner out:
533 1.4 drochner BI_FREE();
534 1.60 maxv bootinfo = NULL;
535 1.21 junyoung return -1;
536 1.1 perry }
537 1.23 ad
538 1.67 nonaka int
539 1.67 nonaka count_netbsd(const char *file, u_long *rsz)
540 1.67 nonaka {
541 1.67 nonaka u_long marks[MARK_MAX];
542 1.67 nonaka char kdev[64];
543 1.68 nonaka char base_path[64] = "/";
544 1.67 nonaka struct stat st;
545 1.67 nonaka boot_module_t *bm;
546 1.67 nonaka u_long sz;
547 1.67 nonaka int err, fd;
548 1.67 nonaka
549 1.70 maxv if (has_prekern) {
550 1.70 maxv /*
551 1.70 maxv * Hardcoded for now. Need to count both the prekern and the
552 1.70 maxv * kernel. 128MB is enough in all cases, so use that.
553 1.70 maxv */
554 1.70 maxv *rsz = (128UL << 20);
555 1.70 maxv return 0;
556 1.70 maxv }
557 1.70 maxv
558 1.68 nonaka howto = AB_SILENT;
559 1.68 nonaka
560 1.67 nonaka memset(marks, 0, sizeof(marks));
561 1.68 nonaka if ((fd = loadfile(file, marks, COUNT_KERNEL | LOAD_NOTE)) == -1)
562 1.67 nonaka return -1;
563 1.67 nonaka close(fd);
564 1.67 nonaka marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) &
565 1.67 nonaka (-sizeof(int));
566 1.67 nonaka sz = marks[MARK_END];
567 1.67 nonaka
568 1.67 nonaka /* The modules must be allocated after the kernel */
569 1.67 nonaka if (boot_modules_enabled) {
570 1.67 nonaka extract_device(file, kdev, sizeof(kdev));
571 1.67 nonaka module_base_path(base_path, sizeof(base_path));
572 1.67 nonaka
573 1.67 nonaka /* If the root fs type is unusual, load its module. */
574 1.67 nonaka if (fsmod != NULL)
575 1.68 nonaka module_add_common(fsmod, BM_TYPE_KMOD);
576 1.67 nonaka
577 1.67 nonaka for (bm = boot_modules; bm; bm = bm->bm_next) {
578 1.67 nonaka fd = module_open(bm, 0, kdev, base_path, false);
579 1.67 nonaka if (fd == -1)
580 1.67 nonaka continue;
581 1.68 nonaka sz = (sz + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
582 1.67 nonaka err = fstat(fd, &st);
583 1.67 nonaka if (err == -1 || st.st_size == -1) {
584 1.67 nonaka close(fd);
585 1.67 nonaka continue;
586 1.67 nonaka }
587 1.67 nonaka sz += st.st_size;
588 1.67 nonaka close(fd);
589 1.67 nonaka }
590 1.67 nonaka }
591 1.67 nonaka
592 1.67 nonaka *rsz = sz;
593 1.67 nonaka return 0;
594 1.67 nonaka }
595 1.67 nonaka
596 1.41 jmcneill static void
597 1.41 jmcneill extract_device(const char *path, char *buf, size_t buflen)
598 1.41 jmcneill {
599 1.59 jakllsch size_t i;
600 1.41 jmcneill
601 1.41 jmcneill if (strchr(path, ':') != NULL) {
602 1.41 jmcneill for (i = 0; i < buflen - 2 && path[i] != ':'; i++)
603 1.41 jmcneill buf[i] = path[i];
604 1.41 jmcneill buf[i++] = ':';
605 1.41 jmcneill buf[i] = '\0';
606 1.41 jmcneill } else
607 1.41 jmcneill buf[0] = '\0';
608 1.41 jmcneill }
609 1.41 jmcneill
610 1.26 ad static const char *
611 1.67 nonaka module_path(boot_module_t *bm, const char *kdev, const char *base_path)
612 1.26 ad {
613 1.26 ad static char buf[256];
614 1.41 jmcneill char name_buf[256], dev_buf[64];
615 1.41 jmcneill const char *name, *name2, *p;
616 1.26 ad
617 1.26 ad name = bm->bm_path;
618 1.33 joerg for (name2 = name; *name2; ++name2) {
619 1.33 joerg if (*name2 == ' ' || *name2 == '\t') {
620 1.33 joerg strlcpy(name_buf, name, sizeof(name_buf));
621 1.59 jakllsch if ((uintptr_t)name2 - (uintptr_t)name < sizeof(name_buf))
622 1.33 joerg name_buf[name2 - name] = '\0';
623 1.33 joerg name = name_buf;
624 1.33 joerg break;
625 1.33 joerg }
626 1.33 joerg }
627 1.41 jmcneill if ((p = strchr(name, ':')) != NULL) {
628 1.41 jmcneill /* device specified, use it */
629 1.41 jmcneill if (p[1] == '/')
630 1.41 jmcneill snprintf(buf, sizeof(buf), "%s", name);
631 1.41 jmcneill else {
632 1.41 jmcneill p++;
633 1.41 jmcneill extract_device(name, dev_buf, sizeof(dev_buf));
634 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
635 1.67 nonaka dev_buf, base_path, p, p);
636 1.41 jmcneill }
637 1.41 jmcneill } else {
638 1.41 jmcneill /* device not specified; load from kernel device if known */
639 1.58 jakllsch if (name[0] == '/')
640 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s", kdev, name);
641 1.41 jmcneill else
642 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
643 1.67 nonaka kdev, base_path, name, name);
644 1.41 jmcneill }
645 1.33 joerg
646 1.26 ad return buf;
647 1.26 ad }
648 1.26 ad
649 1.36 christos static int
650 1.67 nonaka module_open(boot_module_t *bm, int mode, const char *kdev,
651 1.67 nonaka const char *base_path, bool doload)
652 1.28 chris {
653 1.28 chris int fd;
654 1.28 chris const char *path;
655 1.36 christos
656 1.28 chris /* check the expanded path first */
657 1.67 nonaka path = module_path(bm, kdev, base_path);
658 1.28 chris fd = open(path, mode);
659 1.41 jmcneill if (fd != -1) {
660 1.41 jmcneill if ((howto & AB_SILENT) == 0 && doload)
661 1.41 jmcneill printf("Loading %s ", path);
662 1.41 jmcneill } else {
663 1.28 chris /* now attempt the raw path provided */
664 1.28 chris fd = open(bm->bm_path, mode);
665 1.41 jmcneill if (fd != -1 && (howto & AB_SILENT) == 0 && doload)
666 1.41 jmcneill printf("Loading %s ", bm->bm_path);
667 1.41 jmcneill }
668 1.41 jmcneill if (!doload && fd == -1) {
669 1.41 jmcneill printf("WARNING: couldn't open %s", bm->bm_path);
670 1.41 jmcneill if (strcmp(bm->bm_path, path) != 0)
671 1.41 jmcneill printf(" (%s)", path);
672 1.41 jmcneill printf("\n");
673 1.28 chris }
674 1.28 chris return fd;
675 1.28 chris }
676 1.28 chris
677 1.23 ad static void
678 1.67 nonaka module_base_path(char *buf, size_t bufsize)
679 1.23 ad {
680 1.30 joerg const char *machine;
681 1.23 ad
682 1.30 joerg switch (netbsd_elf_class) {
683 1.30 joerg case ELFCLASS32:
684 1.30 joerg machine = "i386";
685 1.30 joerg break;
686 1.30 joerg case ELFCLASS64:
687 1.30 joerg machine = "amd64";
688 1.30 joerg break;
689 1.30 joerg default:
690 1.30 joerg machine = "generic";
691 1.30 joerg break;
692 1.30 joerg }
693 1.30 joerg if (netbsd_version / 1000000 % 100 == 99) {
694 1.30 joerg /* -current */
695 1.67 nonaka snprintf(buf, bufsize,
696 1.38 rmind "/stand/%s/%d.%d.%d/modules", machine,
697 1.30 joerg netbsd_version / 100000000,
698 1.30 joerg netbsd_version / 1000000 % 100,
699 1.30 joerg netbsd_version / 100 % 100);
700 1.30 joerg } else if (netbsd_version != 0) {
701 1.30 joerg /* release */
702 1.67 nonaka snprintf(buf, bufsize,
703 1.38 rmind "/stand/%s/%d.%d/modules", machine,
704 1.30 joerg netbsd_version / 100000000,
705 1.30 joerg netbsd_version / 1000000 % 100);
706 1.30 joerg }
707 1.67 nonaka }
708 1.67 nonaka
709 1.67 nonaka static void
710 1.67 nonaka module_init(const char *kernel_path)
711 1.67 nonaka {
712 1.67 nonaka struct bi_modulelist_entry *bi;
713 1.67 nonaka struct stat st;
714 1.67 nonaka char kdev[64];
715 1.67 nonaka char *buf;
716 1.67 nonaka boot_module_t *bm;
717 1.67 nonaka ssize_t len;
718 1.67 nonaka off_t off;
719 1.67 nonaka int err, fd, nfail = 0;
720 1.67 nonaka
721 1.67 nonaka extract_device(kernel_path, kdev, sizeof(kdev));
722 1.67 nonaka module_base_path(module_base, sizeof(module_base));
723 1.30 joerg
724 1.23 ad /* First, see which modules are valid and calculate btinfo size */
725 1.23 ad len = sizeof(struct btinfo_modulelist);
726 1.23 ad for (bm = boot_modules; bm; bm = bm->bm_next) {
727 1.67 nonaka fd = module_open(bm, 0, kdev, module_base, false);
728 1.23 ad if (fd == -1) {
729 1.23 ad bm->bm_len = -1;
730 1.41 jmcneill ++nfail;
731 1.23 ad continue;
732 1.23 ad }
733 1.23 ad err = fstat(fd, &st);
734 1.24 ad if (err == -1 || st.st_size == -1) {
735 1.28 chris printf("WARNING: couldn't stat %s\n", bm->bm_path);
736 1.23 ad close(fd);
737 1.23 ad bm->bm_len = -1;
738 1.41 jmcneill ++nfail;
739 1.23 ad continue;
740 1.23 ad }
741 1.23 ad bm->bm_len = st.st_size;
742 1.23 ad close(fd);
743 1.23 ad len += sizeof(struct bi_modulelist_entry);
744 1.23 ad }
745 1.23 ad
746 1.23 ad /* Allocate the module list */
747 1.23 ad btinfo_modulelist = alloc(len);
748 1.23 ad if (btinfo_modulelist == NULL) {
749 1.23 ad printf("WARNING: couldn't allocate module list\n");
750 1.43 tsutsui wait_sec(MODULE_WARNING_SEC);
751 1.23 ad return;
752 1.23 ad }
753 1.23 ad memset(btinfo_modulelist, 0, len);
754 1.23 ad btinfo_modulelist_size = len;
755 1.23 ad
756 1.23 ad /* Fill in btinfo structure */
757 1.23 ad buf = (char *)btinfo_modulelist;
758 1.23 ad btinfo_modulelist->num = 0;
759 1.23 ad off = sizeof(struct btinfo_modulelist);
760 1.23 ad
761 1.23 ad for (bm = boot_modules; bm; bm = bm->bm_next) {
762 1.23 ad if (bm->bm_len == -1)
763 1.23 ad continue;
764 1.67 nonaka fd = module_open(bm, 0, kdev, module_base, true);
765 1.41 jmcneill if (fd == -1)
766 1.23 ad continue;
767 1.24 ad image_end = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
768 1.52 jakllsch len = pread(fd, (void *)(uintptr_t)image_end, SSIZE_MAX);
769 1.24 ad if (len < bm->bm_len) {
770 1.40 ad if ((howto & AB_SILENT) != 0)
771 1.40 ad printf("Loading %s ", bm->bm_path);
772 1.23 ad printf(" FAILED\n");
773 1.23 ad } else {
774 1.23 ad btinfo_modulelist->num++;
775 1.23 ad bi = (struct bi_modulelist_entry *)(buf + off);
776 1.23 ad off += sizeof(struct bi_modulelist_entry);
777 1.23 ad strncpy(bi->path, bm->bm_path, sizeof(bi->path) - 1);
778 1.24 ad bi->base = image_end;
779 1.24 ad bi->len = len;
780 1.49 tls switch (bm->bm_type) {
781 1.49 tls case BM_TYPE_KMOD:
782 1.49 tls bi->type = BI_MODULE_ELF;
783 1.49 tls break;
784 1.49 tls case BM_TYPE_IMAGE:
785 1.49 tls bi->type = BI_MODULE_IMAGE;
786 1.49 tls break;
787 1.51 jmcneill case BM_TYPE_FS:
788 1.51 jmcneill bi->type = BI_MODULE_FS;
789 1.51 jmcneill break;
790 1.49 tls case BM_TYPE_RND:
791 1.49 tls default:
792 1.49 tls /* safest -- rnd checks the sha1 */
793 1.49 tls bi->type = BI_MODULE_RND;
794 1.49 tls break;
795 1.49 tls }
796 1.40 ad if ((howto & AB_SILENT) == 0)
797 1.40 ad printf(" \n");
798 1.23 ad }
799 1.24 ad if (len > 0)
800 1.24 ad image_end += len;
801 1.23 ad close(fd);
802 1.23 ad }
803 1.23 ad btinfo_modulelist->endpa = image_end;
804 1.41 jmcneill
805 1.41 jmcneill if (nfail > 0) {
806 1.41 jmcneill printf("WARNING: %d module%s failed to load\n",
807 1.41 jmcneill nfail, nfail == 1 ? "" : "s");
808 1.41 jmcneill #if notyet
809 1.43 tsutsui wait_sec(MODULE_WARNING_SEC);
810 1.41 jmcneill #endif
811 1.41 jmcneill }
812 1.23 ad }
813 1.33 joerg
814 1.47 uebayasi static void
815 1.47 uebayasi userconf_init(void)
816 1.47 uebayasi {
817 1.47 uebayasi size_t count, len;
818 1.47 uebayasi userconf_command_t *uc;
819 1.47 uebayasi char *buf;
820 1.47 uebayasi off_t off;
821 1.47 uebayasi
822 1.47 uebayasi /* Calculate the userconf commands list size */
823 1.47 uebayasi count = 0;
824 1.47 uebayasi for (uc = userconf_commands; uc != NULL; uc = uc->uc_next)
825 1.47 uebayasi count++;
826 1.55 jakllsch len = sizeof(*btinfo_userconfcommands) +
827 1.47 uebayasi count * sizeof(struct bi_userconfcommand);
828 1.47 uebayasi
829 1.47 uebayasi /* Allocate the userconf commands list */
830 1.47 uebayasi btinfo_userconfcommands = alloc(len);
831 1.47 uebayasi if (btinfo_userconfcommands == NULL) {
832 1.47 uebayasi printf("WARNING: couldn't allocate userconf commands list\n");
833 1.47 uebayasi return;
834 1.47 uebayasi }
835 1.47 uebayasi memset(btinfo_userconfcommands, 0, len);
836 1.47 uebayasi btinfo_userconfcommands_size = len;
837 1.47 uebayasi
838 1.47 uebayasi /* Fill in btinfo structure */
839 1.47 uebayasi buf = (char *)btinfo_userconfcommands;
840 1.47 uebayasi off = sizeof(*btinfo_userconfcommands);
841 1.47 uebayasi btinfo_userconfcommands->num = 0;
842 1.47 uebayasi for (uc = userconf_commands; uc != NULL; uc = uc->uc_next) {
843 1.47 uebayasi struct bi_userconfcommand *bi;
844 1.47 uebayasi bi = (struct bi_userconfcommand *)(buf + off);
845 1.47 uebayasi strncpy(bi->text, uc->uc_text, sizeof(bi->text) - 1);
846 1.47 uebayasi
847 1.47 uebayasi off += sizeof(*bi);
848 1.47 uebayasi btinfo_userconfcommands->num++;
849 1.47 uebayasi }
850 1.47 uebayasi }
851 1.47 uebayasi
852 1.33 joerg int
853 1.33 joerg exec_multiboot(const char *file, char *args)
854 1.33 joerg {
855 1.33 joerg struct multiboot_info *mbi;
856 1.33 joerg struct multiboot_module *mbm;
857 1.33 joerg struct bi_modulelist_entry *bim;
858 1.62 maxv int i, len;
859 1.62 maxv u_long marks[MARK_MAX];
860 1.62 maxv u_long extmem;
861 1.62 maxv u_long basemem;
862 1.62 maxv char *cmdline;
863 1.33 joerg
864 1.33 joerg mbi = alloc(sizeof(struct multiboot_info));
865 1.33 joerg mbi->mi_flags = MULTIBOOT_INFO_HAS_MEMORY;
866 1.33 joerg
867 1.33 joerg if (common_load_kernel(file, &basemem, &extmem, 0, 0, marks))
868 1.33 joerg goto out;
869 1.33 joerg
870 1.33 joerg mbi->mi_mem_upper = extmem;
871 1.33 joerg mbi->mi_mem_lower = basemem;
872 1.33 joerg
873 1.33 joerg if (args) {
874 1.33 joerg mbi->mi_flags |= MULTIBOOT_INFO_HAS_CMDLINE;
875 1.33 joerg len = strlen(file) + 1 + strlen(args) + 1;
876 1.33 joerg cmdline = alloc(len);
877 1.33 joerg snprintf(cmdline, len, "%s %s", file, args);
878 1.33 joerg mbi->mi_cmdline = (char *) vtophys(cmdline);
879 1.33 joerg }
880 1.33 joerg
881 1.33 joerg /* pull in any modules if necessary */
882 1.33 joerg if (boot_modules_enabled) {
883 1.41 jmcneill module_init(file);
884 1.33 joerg if (btinfo_modulelist) {
885 1.33 joerg mbm = alloc(sizeof(struct multiboot_module) *
886 1.33 joerg btinfo_modulelist->num);
887 1.33 joerg
888 1.33 joerg bim = (struct bi_modulelist_entry *)
889 1.33 joerg (((char *) btinfo_modulelist) +
890 1.33 joerg sizeof(struct btinfo_modulelist));
891 1.33 joerg for (i = 0; i < btinfo_modulelist->num; i++) {
892 1.33 joerg mbm[i].mmo_start = bim->base;
893 1.33 joerg mbm[i].mmo_end = bim->base + bim->len;
894 1.33 joerg mbm[i].mmo_string = (char *)vtophys(bim->path);
895 1.33 joerg mbm[i].mmo_reserved = 0;
896 1.33 joerg bim++;
897 1.33 joerg }
898 1.33 joerg mbi->mi_flags |= MULTIBOOT_INFO_HAS_MODS;
899 1.33 joerg mbi->mi_mods_count = btinfo_modulelist->num;
900 1.33 joerg mbi->mi_mods_addr = vtophys(mbm);
901 1.33 joerg }
902 1.33 joerg }
903 1.33 joerg
904 1.33 joerg #ifdef DEBUG
905 1.33 joerg printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
906 1.33 joerg marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]);
907 1.33 joerg #endif
908 1.33 joerg
909 1.33 joerg #if 0
910 1.33 joerg if (btinfo_symtab.nsym) {
911 1.33 joerg mbi->mi_flags |= MULTIBOOT_INFO_HAS_ELF_SYMS;
912 1.33 joerg mbi->mi_elfshdr_addr = marks[MARK_SYM];
913 1.33 joerg btinfo_symtab.nsym = marks[MARK_NSYM];
914 1.33 joerg btinfo_symtab.ssym = marks[MARK_SYM];
915 1.33 joerg btinfo_symtab.esym = marks[MARK_END];
916 1.33 joerg #endif
917 1.33 joerg
918 1.33 joerg multiboot(marks[MARK_ENTRY], vtophys(mbi),
919 1.62 maxv x86_trunc_page(mbi->mi_mem_lower * 1024));
920 1.33 joerg panic("exec returned");
921 1.33 joerg
922 1.33 joerg out:
923 1.62 maxv dealloc(mbi, 0);
924 1.33 joerg return -1;
925 1.33 joerg }
926 1.40 ad
927 1.40 ad void
928 1.40 ad x86_progress(const char *fmt, ...)
929 1.40 ad {
930 1.40 ad va_list ap;
931 1.40 ad
932 1.40 ad if ((howto & AB_SILENT) != 0)
933 1.40 ad return;
934 1.40 ad va_start(ap, fmt);
935 1.40 ad vprintf(fmt, ap);
936 1.40 ad va_end(ap);
937 1.40 ad }
938