exec.c revision 1.80 1 1.80 mlelstv /* $NetBSD: exec.c,v 1.80 2024/01/06 21:26:43 mlelstv 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.1 perry #include <lib/libsa/stand.h>
99 1.23 ad #include <lib/libkern/libkern.h>
100 1.4 drochner
101 1.6 christos #include "loadfile.h"
102 1.1 perry #include "libi386.h"
103 1.4 drochner #include "bootinfo.h"
104 1.23 ad #include "bootmod.h"
105 1.42 jmcneill #include "vbe.h"
106 1.16 jdolecek #ifdef SUPPORT_PS2
107 1.16 jdolecek #include "biosmca.h"
108 1.16 jdolecek #endif
109 1.63 nonaka #ifdef EFIBOOT
110 1.63 nonaka #include "efiboot.h"
111 1.80 mlelstv #include "biosdisk.h"
112 1.80 mlelstv #include "efidisk.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.72 pgoyette #define MAXMODNAME 32 /* from <sys/module.h> */
125 1.72 pgoyette
126 1.4 drochner extern struct btinfo_console btinfo_console;
127 1.77 mlelstv extern struct btinfo_rootdevice bi_root;
128 1.4 drochner
129 1.23 ad boot_module_t *boot_modules;
130 1.23 ad bool boot_modules_enabled = true;
131 1.23 ad bool kernel_loaded;
132 1.23 ad
133 1.47 uebayasi typedef struct userconf_command {
134 1.47 uebayasi char *uc_text;
135 1.47 uebayasi size_t uc_len;
136 1.47 uebayasi struct userconf_command *uc_next;
137 1.47 uebayasi } userconf_command_t;
138 1.47 uebayasi userconf_command_t *userconf_commands = NULL;
139 1.47 uebayasi
140 1.74 manu struct btinfo_framebuffer btinfo_framebuffer;
141 1.39 jmcneill
142 1.74 manu struct btinfo_modulelist *btinfo_modulelist;
143 1.23 ad static size_t btinfo_modulelist_size;
144 1.23 ad static uint32_t image_end;
145 1.26 ad static char module_base[64] = "/";
146 1.40 ad static int howto;
147 1.23 ad
148 1.47 uebayasi static struct btinfo_userconfcommands *btinfo_userconfcommands = NULL;
149 1.47 uebayasi static size_t btinfo_userconfcommands_size = 0;
150 1.47 uebayasi
151 1.41 jmcneill static void module_init(const char *);
152 1.57 jakllsch static void module_add_common(const char *, uint8_t);
153 1.23 ad
154 1.47 uebayasi static void userconf_init(void);
155 1.47 uebayasi
156 1.67 nonaka static void extract_device(const char *, char *, size_t);
157 1.76 christos static void module_base_path(char *, size_t, const char *);
158 1.67 nonaka static int module_open(boot_module_t *, int, const char *, const char *,
159 1.67 nonaka bool);
160 1.67 nonaka
161 1.34 ad void
162 1.39 jmcneill framebuffer_configure(struct btinfo_framebuffer *fb)
163 1.39 jmcneill {
164 1.39 jmcneill if (fb)
165 1.39 jmcneill btinfo_framebuffer = *fb;
166 1.39 jmcneill else {
167 1.39 jmcneill btinfo_framebuffer.physaddr = 0;
168 1.39 jmcneill btinfo_framebuffer.flags = 0;
169 1.39 jmcneill }
170 1.39 jmcneill }
171 1.39 jmcneill
172 1.39 jmcneill void
173 1.34 ad module_add(char *name)
174 1.34 ad {
175 1.46 jmcneill return module_add_common(name, BM_TYPE_KMOD);
176 1.46 jmcneill }
177 1.46 jmcneill
178 1.46 jmcneill void
179 1.46 jmcneill splash_add(char *name)
180 1.46 jmcneill {
181 1.46 jmcneill return module_add_common(name, BM_TYPE_IMAGE);
182 1.46 jmcneill }
183 1.46 jmcneill
184 1.49 tls void
185 1.49 tls rnd_add(char *name)
186 1.49 tls {
187 1.49 tls return module_add_common(name, BM_TYPE_RND);
188 1.49 tls }
189 1.49 tls
190 1.51 jmcneill void
191 1.51 jmcneill fs_add(char *name)
192 1.51 jmcneill {
193 1.51 jmcneill return module_add_common(name, BM_TYPE_FS);
194 1.51 jmcneill }
195 1.51 jmcneill
196 1.72 pgoyette /*
197 1.72 pgoyette * Add a /-separated list of module names to the boot list
198 1.72 pgoyette */
199 1.72 pgoyette void
200 1.72 pgoyette module_add_split(const char *name, uint8_t type)
201 1.72 pgoyette {
202 1.72 pgoyette char mod_name[MAXMODNAME];
203 1.72 pgoyette int i;
204 1.72 pgoyette const char *mp = name;
205 1.72 pgoyette char *ep;
206 1.72 pgoyette
207 1.72 pgoyette while (*mp) { /* scan list of module names */
208 1.72 pgoyette i = MAXMODNAME;
209 1.72 pgoyette ep = mod_name;
210 1.72 pgoyette while (--i) { /* scan for end of first name */
211 1.72 pgoyette *ep = *mp;
212 1.72 pgoyette if (*ep == '/') /* NUL-terminate the name */
213 1.72 pgoyette *ep = '\0';
214 1.72 pgoyette
215 1.72 pgoyette if (*ep == 0 ) { /* add non-empty name */
216 1.72 pgoyette if (ep != mod_name)
217 1.72 pgoyette module_add_common(mod_name, type);
218 1.72 pgoyette break;
219 1.72 pgoyette }
220 1.72 pgoyette ep++; mp++;
221 1.72 pgoyette }
222 1.72 pgoyette if (*ep != 0) {
223 1.72 pgoyette printf("module name too long\n");
224 1.72 pgoyette return;
225 1.72 pgoyette }
226 1.72 pgoyette if (*mp == '/') { /* skip separator if more */
227 1.72 pgoyette mp++;
228 1.72 pgoyette }
229 1.72 pgoyette }
230 1.72 pgoyette }
231 1.72 pgoyette
232 1.46 jmcneill static void
233 1.57 jakllsch module_add_common(const char *name, uint8_t type)
234 1.46 jmcneill {
235 1.34 ad boot_module_t *bm, *bmp;
236 1.34 ad size_t len;
237 1.34 ad char *str;
238 1.34 ad
239 1.35 ad while (*name == ' ' || *name == '\t')
240 1.35 ad ++name;
241 1.35 ad
242 1.67 nonaka for (bm = boot_modules; bm != NULL; bm = bm->bm_next)
243 1.67 nonaka if (bm->bm_type == type && strcmp(bm->bm_path, name) == 0)
244 1.67 nonaka return;
245 1.67 nonaka
246 1.34 ad bm = alloc(sizeof(boot_module_t));
247 1.34 ad len = strlen(name) + 1;
248 1.34 ad str = alloc(len);
249 1.34 ad if (bm == NULL || str == NULL) {
250 1.34 ad printf("couldn't allocate module\n");
251 1.34 ad return;
252 1.34 ad }
253 1.34 ad memcpy(str, name, len);
254 1.34 ad bm->bm_path = str;
255 1.34 ad bm->bm_next = NULL;
256 1.46 jmcneill bm->bm_type = type;
257 1.34 ad if (boot_modules == NULL)
258 1.34 ad boot_modules = bm;
259 1.34 ad else {
260 1.34 ad for (bmp = boot_modules; bmp->bm_next;
261 1.34 ad bmp = bmp->bm_next)
262 1.34 ad ;
263 1.34 ad bmp->bm_next = bm;
264 1.34 ad }
265 1.34 ad }
266 1.34 ad
267 1.47 uebayasi void
268 1.47 uebayasi userconf_add(char *cmd)
269 1.47 uebayasi {
270 1.47 uebayasi userconf_command_t *uc;
271 1.47 uebayasi size_t len;
272 1.47 uebayasi char *text;
273 1.47 uebayasi
274 1.47 uebayasi while (*cmd == ' ' || *cmd == '\t')
275 1.47 uebayasi ++cmd;
276 1.47 uebayasi
277 1.47 uebayasi uc = alloc(sizeof(*uc));
278 1.47 uebayasi if (uc == NULL) {
279 1.47 uebayasi printf("couldn't allocate command\n");
280 1.47 uebayasi return;
281 1.47 uebayasi }
282 1.47 uebayasi
283 1.47 uebayasi len = strlen(cmd) + 1;
284 1.47 uebayasi text = alloc(len);
285 1.47 uebayasi if (text == NULL) {
286 1.47 uebayasi dealloc(uc, sizeof(*uc));
287 1.47 uebayasi printf("couldn't allocate command\n");
288 1.47 uebayasi return;
289 1.47 uebayasi }
290 1.47 uebayasi memcpy(text, cmd, len);
291 1.47 uebayasi
292 1.47 uebayasi uc->uc_text = text;
293 1.47 uebayasi uc->uc_len = len;
294 1.47 uebayasi uc->uc_next = NULL;
295 1.47 uebayasi
296 1.47 uebayasi if (userconf_commands == NULL)
297 1.47 uebayasi userconf_commands = uc;
298 1.47 uebayasi else {
299 1.47 uebayasi userconf_command_t *ucp;
300 1.47 uebayasi for (ucp = userconf_commands; ucp->uc_next != NULL;
301 1.47 uebayasi ucp = ucp->uc_next)
302 1.47 uebayasi ;
303 1.47 uebayasi ucp->uc_next = uc;
304 1.47 uebayasi }
305 1.47 uebayasi }
306 1.47 uebayasi
307 1.69 maxv struct btinfo_prekern bi_prekern;
308 1.69 maxv int has_prekern = 0;
309 1.69 maxv
310 1.69 maxv static int
311 1.69 maxv common_load_prekern(const char *file, u_long *basemem, u_long *extmem,
312 1.69 maxv physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
313 1.69 maxv {
314 1.69 maxv paddr_t kernpa_start, kernpa_end;
315 1.69 maxv char prekernpath[] = "/prekern";
316 1.70 maxv u_long prekern_start;
317 1.69 maxv int fd, flags;
318 1.69 maxv
319 1.69 maxv *extmem = getextmem();
320 1.69 maxv *basemem = getbasemem();
321 1.69 maxv
322 1.69 maxv marks[MARK_START] = loadaddr;
323 1.69 maxv
324 1.69 maxv /* Load the prekern (static) */
325 1.70 maxv flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM);
326 1.69 maxv if ((fd = loadfile(prekernpath, marks, flags)) == -1)
327 1.75 christos return errno;
328 1.69 maxv close(fd);
329 1.69 maxv
330 1.70 maxv prekern_start = marks[MARK_START];
331 1.70 maxv
332 1.70 maxv /* The kernel starts at 2MB. */
333 1.70 maxv marks[MARK_START] = loadaddr;
334 1.70 maxv marks[MARK_END] = loadaddr + (1UL << 21);
335 1.70 maxv kernpa_start = (1UL << 21);
336 1.69 maxv
337 1.69 maxv /* Load the kernel (dynamic) */
338 1.69 maxv flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0);
339 1.69 maxv if ((fd = loadfile(file, marks, flags)) == -1)
340 1.75 christos return errno;
341 1.69 maxv close(fd);
342 1.69 maxv
343 1.70 maxv kernpa_end = marks[MARK_END] - loadaddr;
344 1.69 maxv
345 1.69 maxv /* If the root fs type is unusual, load its module. */
346 1.69 maxv if (fsmod != NULL)
347 1.72 pgoyette module_add_split(fsmod, BM_TYPE_KMOD);
348 1.69 maxv
349 1.69 maxv bi_prekern.kernpa_start = kernpa_start;
350 1.69 maxv bi_prekern.kernpa_end = kernpa_end;
351 1.69 maxv BI_ADD(&bi_prekern, BTINFO_PREKERN, sizeof(struct btinfo_prekern));
352 1.69 maxv
353 1.69 maxv /*
354 1.69 maxv * Gather some information for the kernel. Do this after the
355 1.69 maxv * "point of no return" to avoid memory leaks.
356 1.69 maxv * (but before DOS might be trashed in the XMS case)
357 1.69 maxv */
358 1.69 maxv #ifdef PASS_BIOSGEOM
359 1.69 maxv bi_getbiosgeom();
360 1.69 maxv #endif
361 1.69 maxv #ifdef PASS_MEMMAP
362 1.69 maxv bi_getmemmap();
363 1.69 maxv #endif
364 1.69 maxv
365 1.70 maxv marks[MARK_START] = prekern_start;
366 1.69 maxv marks[MARK_END] = (((u_long)marks[MARK_END] + sizeof(int) - 1)) &
367 1.69 maxv (-sizeof(int));
368 1.69 maxv image_end = marks[MARK_END];
369 1.69 maxv kernel_loaded = true;
370 1.69 maxv
371 1.69 maxv return 0;
372 1.69 maxv }
373 1.69 maxv
374 1.32 joerg static int
375 1.32 joerg common_load_kernel(const char *file, u_long *basemem, u_long *extmem,
376 1.32 joerg physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX])
377 1.1 perry {
378 1.32 joerg int fd;
379 1.8 christos #ifdef XMS
380 1.62 maxv u_long xmsmem;
381 1.62 maxv physaddr_t origaddr = loadaddr;
382 1.8 christos #endif
383 1.8 christos
384 1.32 joerg *extmem = getextmem();
385 1.32 joerg *basemem = getbasemem();
386 1.8 christos
387 1.8 christos #ifdef XMS
388 1.8 christos if ((getextmem1() == 0) && (xmsmem = checkxms())) {
389 1.62 maxv u_long kernsize;
390 1.8 christos
391 1.8 christos /*
392 1.8 christos * With "CONSERVATIVE_MEMDETECT", extmem is 0 because
393 1.62 maxv * getextmem() is getextmem1(). Without, the "smart"
394 1.62 maxv * methods could fail to report all memory as well.
395 1.8 christos * xmsmem is a few kB less than the actual size, but
396 1.62 maxv * better than nothing.
397 1.8 christos */
398 1.32 joerg if (xmsmem > *extmem)
399 1.32 joerg *extmem = xmsmem;
400 1.21 junyoung /*
401 1.8 christos * Get the size of the kernel
402 1.8 christos */
403 1.8 christos marks[MARK_START] = loadaddr;
404 1.12 christos if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
405 1.75 christos return errno;
406 1.8 christos close(fd);
407 1.8 christos
408 1.8 christos kernsize = marks[MARK_END];
409 1.8 christos kernsize = (kernsize + 1023) / 1024;
410 1.8 christos
411 1.8 christos loadaddr = xmsalloc(kernsize);
412 1.8 christos if (!loadaddr)
413 1.21 junyoung return ENOMEM;
414 1.8 christos }
415 1.8 christos #endif
416 1.7 christos marks[MARK_START] = loadaddr;
417 1.29 christos if ((fd = loadfile(file, marks,
418 1.44 christos LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1)
419 1.75 christos return errno;
420 1.1 perry
421 1.8 christos close(fd);
422 1.10 drochner
423 1.50 dsl /* If the root fs type is unusual, load its module. */
424 1.50 dsl if (fsmod != NULL)
425 1.72 pgoyette module_add_split(fsmod, BM_TYPE_KMOD);
426 1.34 ad
427 1.10 drochner /*
428 1.10 drochner * Gather some information for the kernel. Do this after the
429 1.10 drochner * "point of no return" to avoid memory leaks.
430 1.10 drochner * (but before DOS might be trashed in the XMS case)
431 1.10 drochner */
432 1.10 drochner #ifdef PASS_BIOSGEOM
433 1.10 drochner bi_getbiosgeom();
434 1.10 drochner #endif
435 1.10 drochner #ifdef PASS_MEMMAP
436 1.10 drochner bi_getmemmap();
437 1.10 drochner #endif
438 1.8 christos
439 1.8 christos #ifdef XMS
440 1.8 christos if (loadaddr != origaddr) {
441 1.8 christos /*
442 1.14 ross * We now have done our last DOS IO, so we may
443 1.8 christos * trash the OS. Copy the data from the temporary
444 1.20 wiz * buffer to its real address.
445 1.8 christos */
446 1.8 christos marks[MARK_START] -= loadaddr;
447 1.8 christos marks[MARK_END] -= loadaddr;
448 1.8 christos marks[MARK_SYM] -= loadaddr;
449 1.8 christos marks[MARK_END] -= loadaddr;
450 1.8 christos ppbcopy(loadaddr, origaddr, marks[MARK_END]);
451 1.8 christos }
452 1.8 christos #endif
453 1.8 christos marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) &
454 1.8 christos (-sizeof(int));
455 1.23 ad image_end = marks[MARK_END];
456 1.23 ad kernel_loaded = true;
457 1.1 perry
458 1.32 joerg return 0;
459 1.32 joerg }
460 1.32 joerg
461 1.32 joerg int
462 1.40 ad exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy,
463 1.62 maxv void (*callback)(void))
464 1.32 joerg {
465 1.62 maxv uint32_t boot_argv[BOOT_NARGS];
466 1.62 maxv u_long marks[MARK_MAX];
467 1.32 joerg struct btinfo_symtab btinfo_symtab;
468 1.62 maxv u_long extmem;
469 1.62 maxv u_long basemem;
470 1.79 manu u_long entry;
471 1.63 nonaka int error;
472 1.64 nonaka #ifdef EFIBOOT
473 1.64 nonaka int i;
474 1.64 nonaka #endif
475 1.32 joerg
476 1.32 joerg #ifdef DEBUG
477 1.62 maxv printf("exec: file=%s loadaddr=0x%lx\n", file ? file : "NULL",
478 1.62 maxv loadaddr);
479 1.32 joerg #endif
480 1.32 joerg
481 1.61 maxv BI_ALLOC(BTINFO_MAX);
482 1.32 joerg
483 1.32 joerg BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
484 1.77 mlelstv if (bi_root.devname[0])
485 1.77 mlelstv BI_ADD(&bi_root, BTINFO_ROOTDEVICE, sizeof(struct btinfo_rootdevice));
486 1.32 joerg
487 1.40 ad howto = boothowto;
488 1.40 ad
489 1.56 jakllsch memset(marks, 0, sizeof(marks));
490 1.56 jakllsch
491 1.69 maxv if (has_prekern) {
492 1.69 maxv error = common_load_prekern(file, &basemem, &extmem, loadaddr,
493 1.69 maxv floppy, marks);
494 1.69 maxv } else {
495 1.69 maxv error = common_load_kernel(file, &basemem, &extmem, loadaddr,
496 1.69 maxv floppy, marks);
497 1.69 maxv }
498 1.63 nonaka if (error) {
499 1.63 nonaka errno = error;
500 1.32 joerg goto out;
501 1.63 nonaka }
502 1.67 nonaka #ifdef EFIBOOT
503 1.80 mlelstv BI_ADD(&bi_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
504 1.80 mlelstv BI_ADD(&bi_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
505 1.80 mlelstv efidisk_getbiosgeom();
506 1.80 mlelstv
507 1.79 manu efi_load_start = marks[MARK_START];
508 1.79 manu
509 1.67 nonaka /* adjust to the real load address */
510 1.67 nonaka marks[MARK_START] -= efi_loadaddr;
511 1.67 nonaka marks[MARK_ENTRY] -= efi_loadaddr;
512 1.67 nonaka marks[MARK_DATA] -= efi_loadaddr;
513 1.67 nonaka /* MARK_NSYM */
514 1.67 nonaka marks[MARK_SYM] -= efi_loadaddr;
515 1.67 nonaka marks[MARK_END] -= efi_loadaddr;
516 1.67 nonaka #endif
517 1.32 joerg
518 1.31 joerg boot_argv[0] = boothowto;
519 1.31 joerg boot_argv[1] = 0;
520 1.31 joerg boot_argv[2] = vtophys(bootinfo); /* old cyl offset */
521 1.31 joerg boot_argv[3] = marks[MARK_END];
522 1.31 joerg boot_argv[4] = extmem;
523 1.31 joerg boot_argv[5] = basemem;
524 1.31 joerg
525 1.23 ad /* pull in any modules if necessary */
526 1.23 ad if (boot_modules_enabled) {
527 1.41 jmcneill module_init(file);
528 1.23 ad if (btinfo_modulelist) {
529 1.67 nonaka #ifdef EFIBOOT
530 1.67 nonaka /* convert module loaded address to paddr */
531 1.67 nonaka struct bi_modulelist_entry *bim;
532 1.67 nonaka bim = (void *)(btinfo_modulelist + 1);
533 1.67 nonaka for (i = 0; i < btinfo_modulelist->num; i++, bim++)
534 1.67 nonaka bim->base -= efi_loadaddr;
535 1.67 nonaka btinfo_modulelist->endpa -= efi_loadaddr;
536 1.67 nonaka #endif
537 1.23 ad BI_ADD(btinfo_modulelist, BTINFO_MODULELIST,
538 1.23 ad btinfo_modulelist_size);
539 1.23 ad }
540 1.23 ad }
541 1.1 perry
542 1.47 uebayasi userconf_init();
543 1.47 uebayasi if (btinfo_userconfcommands != NULL)
544 1.47 uebayasi BI_ADD(btinfo_userconfcommands, BTINFO_USERCONFCOMMANDS,
545 1.58 jakllsch btinfo_userconfcommands_size);
546 1.47 uebayasi
547 1.1 perry #ifdef DEBUG
548 1.8 christos printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
549 1.7 christos marks[MARK_NSYM], marks[MARK_SYM], marks[MARK_END]);
550 1.1 perry #endif
551 1.1 perry
552 1.8 christos btinfo_symtab.nsym = marks[MARK_NSYM];
553 1.8 christos btinfo_symtab.ssym = marks[MARK_SYM];
554 1.8 christos btinfo_symtab.esym = marks[MARK_END];
555 1.8 christos BI_ADD(&btinfo_symtab, BTINFO_SYMTAB, sizeof(struct btinfo_symtab));
556 1.8 christos
557 1.42 jmcneill /* set new video mode if necessary */
558 1.42 jmcneill vbe_commit();
559 1.42 jmcneill BI_ADD(&btinfo_framebuffer, BTINFO_FRAMEBUFFER,
560 1.42 jmcneill sizeof(struct btinfo_framebuffer));
561 1.42 jmcneill
562 1.40 ad if (callback != NULL)
563 1.40 ad (*callback)();
564 1.79 manu
565 1.79 manu entry = marks[MARK_ENTRY];
566 1.63 nonaka #ifdef EFIBOOT
567 1.64 nonaka /* Copy bootinfo to safe arena. */
568 1.64 nonaka for (i = 0; i < bootinfo->nentries; i++) {
569 1.64 nonaka struct btinfo_common *bi = (void *)(u_long)bootinfo->entry[i];
570 1.64 nonaka char *p = alloc(bi->len);
571 1.64 nonaka memcpy(p, bi, bi->len);
572 1.64 nonaka bootinfo->entry[i] = vtophys(p);
573 1.64 nonaka }
574 1.64 nonaka
575 1.65 nonaka efi_kernel_start = marks[MARK_START];
576 1.70 maxv efi_kernel_size = image_end - (efi_loadaddr + efi_kernel_start);
577 1.79 manu
578 1.79 manu switch (efi_reloc_type) {
579 1.79 manu case RELOC_NONE:
580 1.79 manu entry += (efi_load_start - efi_kernel_start);
581 1.79 manu efi_kernel_start = efi_load_start;
582 1.79 manu break;
583 1.79 manu case RELOC_ADDR:
584 1.79 manu entry += (efi_kernel_reloc - efi_kernel_start);
585 1.79 manu efi_kernel_start = efi_kernel_reloc;
586 1.79 manu break;
587 1.79 manu case RELOC_DEFAULT:
588 1.79 manu default:
589 1.79 manu break;
590 1.79 manu }
591 1.63 nonaka #endif
592 1.79 manu startprog(entry, BOOT_NARGS, boot_argv,
593 1.62 maxv x86_trunc_page(basemem * 1024));
594 1.1 perry panic("exec returned");
595 1.1 perry
596 1.4 drochner out:
597 1.4 drochner BI_FREE();
598 1.60 maxv bootinfo = NULL;
599 1.21 junyoung return -1;
600 1.1 perry }
601 1.23 ad
602 1.41 jmcneill static void
603 1.41 jmcneill extract_device(const char *path, char *buf, size_t buflen)
604 1.41 jmcneill {
605 1.59 jakllsch size_t i;
606 1.41 jmcneill
607 1.41 jmcneill if (strchr(path, ':') != NULL) {
608 1.41 jmcneill for (i = 0; i < buflen - 2 && path[i] != ':'; i++)
609 1.41 jmcneill buf[i] = path[i];
610 1.41 jmcneill buf[i++] = ':';
611 1.41 jmcneill buf[i] = '\0';
612 1.41 jmcneill } else
613 1.41 jmcneill buf[0] = '\0';
614 1.41 jmcneill }
615 1.41 jmcneill
616 1.26 ad static const char *
617 1.67 nonaka module_path(boot_module_t *bm, const char *kdev, const char *base_path)
618 1.26 ad {
619 1.26 ad static char buf[256];
620 1.41 jmcneill char name_buf[256], dev_buf[64];
621 1.41 jmcneill const char *name, *name2, *p;
622 1.26 ad
623 1.26 ad name = bm->bm_path;
624 1.33 joerg for (name2 = name; *name2; ++name2) {
625 1.33 joerg if (*name2 == ' ' || *name2 == '\t') {
626 1.33 joerg strlcpy(name_buf, name, sizeof(name_buf));
627 1.59 jakllsch if ((uintptr_t)name2 - (uintptr_t)name < sizeof(name_buf))
628 1.33 joerg name_buf[name2 - name] = '\0';
629 1.33 joerg name = name_buf;
630 1.33 joerg break;
631 1.33 joerg }
632 1.33 joerg }
633 1.41 jmcneill if ((p = strchr(name, ':')) != NULL) {
634 1.41 jmcneill /* device specified, use it */
635 1.41 jmcneill if (p[1] == '/')
636 1.41 jmcneill snprintf(buf, sizeof(buf), "%s", name);
637 1.41 jmcneill else {
638 1.41 jmcneill p++;
639 1.41 jmcneill extract_device(name, dev_buf, sizeof(dev_buf));
640 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
641 1.67 nonaka dev_buf, base_path, p, p);
642 1.41 jmcneill }
643 1.41 jmcneill } else {
644 1.41 jmcneill /* device not specified; load from kernel device if known */
645 1.58 jakllsch if (name[0] == '/')
646 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s", kdev, name);
647 1.41 jmcneill else
648 1.41 jmcneill snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
649 1.67 nonaka kdev, base_path, name, name);
650 1.41 jmcneill }
651 1.33 joerg
652 1.26 ad return buf;
653 1.26 ad }
654 1.26 ad
655 1.36 christos static int
656 1.67 nonaka module_open(boot_module_t *bm, int mode, const char *kdev,
657 1.67 nonaka const char *base_path, bool doload)
658 1.28 chris {
659 1.28 chris int fd;
660 1.28 chris const char *path;
661 1.36 christos
662 1.28 chris /* check the expanded path first */
663 1.67 nonaka path = module_path(bm, kdev, base_path);
664 1.28 chris fd = open(path, mode);
665 1.41 jmcneill if (fd != -1) {
666 1.41 jmcneill if ((howto & AB_SILENT) == 0 && doload)
667 1.41 jmcneill printf("Loading %s ", path);
668 1.41 jmcneill } else {
669 1.28 chris /* now attempt the raw path provided */
670 1.28 chris fd = open(bm->bm_path, mode);
671 1.41 jmcneill if (fd != -1 && (howto & AB_SILENT) == 0 && doload)
672 1.41 jmcneill printf("Loading %s ", bm->bm_path);
673 1.41 jmcneill }
674 1.41 jmcneill if (!doload && fd == -1) {
675 1.41 jmcneill printf("WARNING: couldn't open %s", bm->bm_path);
676 1.41 jmcneill if (strcmp(bm->bm_path, path) != 0)
677 1.41 jmcneill printf(" (%s)", path);
678 1.41 jmcneill printf("\n");
679 1.28 chris }
680 1.28 chris return fd;
681 1.28 chris }
682 1.28 chris
683 1.23 ad static void
684 1.76 christos module_base_path(char *buf, size_t bufsize, const char *kernel_path)
685 1.23 ad {
686 1.76 christos #ifdef KERNEL_DIR
687 1.76 christos /* we cheat here, because %.* does not work with the mini printf */
688 1.76 christos char *ptr = strrchr(kernel_path, '/');
689 1.76 christos if (ptr) *ptr = '\0';
690 1.76 christos snprintf(buf, bufsize, "%s/modules", kernel_path);
691 1.76 christos if (ptr) *ptr = '/';
692 1.76 christos #else
693 1.30 joerg const char *machine;
694 1.23 ad
695 1.30 joerg switch (netbsd_elf_class) {
696 1.30 joerg case ELFCLASS32:
697 1.30 joerg machine = "i386";
698 1.30 joerg break;
699 1.30 joerg case ELFCLASS64:
700 1.30 joerg machine = "amd64";
701 1.30 joerg break;
702 1.30 joerg default:
703 1.30 joerg machine = "generic";
704 1.30 joerg break;
705 1.30 joerg }
706 1.30 joerg if (netbsd_version / 1000000 % 100 == 99) {
707 1.30 joerg /* -current */
708 1.67 nonaka snprintf(buf, bufsize,
709 1.38 rmind "/stand/%s/%d.%d.%d/modules", machine,
710 1.30 joerg netbsd_version / 100000000,
711 1.30 joerg netbsd_version / 1000000 % 100,
712 1.78 riastrad netbsd_version / 100 % 10000);
713 1.30 joerg } else if (netbsd_version != 0) {
714 1.30 joerg /* release */
715 1.67 nonaka snprintf(buf, bufsize,
716 1.38 rmind "/stand/%s/%d.%d/modules", machine,
717 1.30 joerg netbsd_version / 100000000,
718 1.30 joerg netbsd_version / 1000000 % 100);
719 1.30 joerg }
720 1.76 christos #endif
721 1.67 nonaka }
722 1.67 nonaka
723 1.67 nonaka static void
724 1.67 nonaka module_init(const char *kernel_path)
725 1.67 nonaka {
726 1.67 nonaka struct bi_modulelist_entry *bi;
727 1.67 nonaka struct stat st;
728 1.67 nonaka char kdev[64];
729 1.67 nonaka char *buf;
730 1.67 nonaka boot_module_t *bm;
731 1.67 nonaka ssize_t len;
732 1.67 nonaka off_t off;
733 1.67 nonaka int err, fd, nfail = 0;
734 1.67 nonaka
735 1.67 nonaka extract_device(kernel_path, kdev, sizeof(kdev));
736 1.76 christos module_base_path(module_base, sizeof(module_base), kernel_path);
737 1.30 joerg
738 1.23 ad /* First, see which modules are valid and calculate btinfo size */
739 1.23 ad len = sizeof(struct btinfo_modulelist);
740 1.23 ad for (bm = boot_modules; bm; bm = bm->bm_next) {
741 1.67 nonaka fd = module_open(bm, 0, kdev, module_base, false);
742 1.23 ad if (fd == -1) {
743 1.23 ad bm->bm_len = -1;
744 1.41 jmcneill ++nfail;
745 1.23 ad continue;
746 1.23 ad }
747 1.23 ad err = fstat(fd, &st);
748 1.24 ad if (err == -1 || st.st_size == -1) {
749 1.28 chris printf("WARNING: couldn't stat %s\n", bm->bm_path);
750 1.23 ad close(fd);
751 1.23 ad bm->bm_len = -1;
752 1.41 jmcneill ++nfail;
753 1.23 ad continue;
754 1.23 ad }
755 1.23 ad bm->bm_len = st.st_size;
756 1.23 ad close(fd);
757 1.23 ad len += sizeof(struct bi_modulelist_entry);
758 1.23 ad }
759 1.23 ad
760 1.23 ad /* Allocate the module list */
761 1.23 ad btinfo_modulelist = alloc(len);
762 1.23 ad if (btinfo_modulelist == NULL) {
763 1.23 ad printf("WARNING: couldn't allocate module list\n");
764 1.43 tsutsui wait_sec(MODULE_WARNING_SEC);
765 1.23 ad return;
766 1.23 ad }
767 1.23 ad memset(btinfo_modulelist, 0, len);
768 1.23 ad btinfo_modulelist_size = len;
769 1.23 ad
770 1.23 ad /* Fill in btinfo structure */
771 1.23 ad buf = (char *)btinfo_modulelist;
772 1.23 ad btinfo_modulelist->num = 0;
773 1.23 ad off = sizeof(struct btinfo_modulelist);
774 1.23 ad
775 1.23 ad for (bm = boot_modules; bm; bm = bm->bm_next) {
776 1.23 ad if (bm->bm_len == -1)
777 1.23 ad continue;
778 1.67 nonaka fd = module_open(bm, 0, kdev, module_base, true);
779 1.41 jmcneill if (fd == -1)
780 1.23 ad continue;
781 1.24 ad image_end = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
782 1.52 jakllsch len = pread(fd, (void *)(uintptr_t)image_end, SSIZE_MAX);
783 1.24 ad if (len < bm->bm_len) {
784 1.40 ad if ((howto & AB_SILENT) != 0)
785 1.40 ad printf("Loading %s ", bm->bm_path);
786 1.23 ad printf(" FAILED\n");
787 1.23 ad } else {
788 1.23 ad btinfo_modulelist->num++;
789 1.23 ad bi = (struct bi_modulelist_entry *)(buf + off);
790 1.23 ad off += sizeof(struct bi_modulelist_entry);
791 1.23 ad strncpy(bi->path, bm->bm_path, sizeof(bi->path) - 1);
792 1.24 ad bi->base = image_end;
793 1.24 ad bi->len = len;
794 1.49 tls switch (bm->bm_type) {
795 1.49 tls case BM_TYPE_KMOD:
796 1.49 tls bi->type = BI_MODULE_ELF;
797 1.49 tls break;
798 1.49 tls case BM_TYPE_IMAGE:
799 1.49 tls bi->type = BI_MODULE_IMAGE;
800 1.49 tls break;
801 1.51 jmcneill case BM_TYPE_FS:
802 1.51 jmcneill bi->type = BI_MODULE_FS;
803 1.51 jmcneill break;
804 1.49 tls case BM_TYPE_RND:
805 1.49 tls default:
806 1.49 tls /* safest -- rnd checks the sha1 */
807 1.49 tls bi->type = BI_MODULE_RND;
808 1.49 tls break;
809 1.49 tls }
810 1.40 ad if ((howto & AB_SILENT) == 0)
811 1.40 ad printf(" \n");
812 1.23 ad }
813 1.24 ad if (len > 0)
814 1.24 ad image_end += len;
815 1.23 ad close(fd);
816 1.23 ad }
817 1.23 ad btinfo_modulelist->endpa = image_end;
818 1.41 jmcneill
819 1.41 jmcneill if (nfail > 0) {
820 1.41 jmcneill printf("WARNING: %d module%s failed to load\n",
821 1.41 jmcneill nfail, nfail == 1 ? "" : "s");
822 1.41 jmcneill #if notyet
823 1.43 tsutsui wait_sec(MODULE_WARNING_SEC);
824 1.41 jmcneill #endif
825 1.41 jmcneill }
826 1.23 ad }
827 1.33 joerg
828 1.47 uebayasi static void
829 1.47 uebayasi userconf_init(void)
830 1.47 uebayasi {
831 1.47 uebayasi size_t count, len;
832 1.47 uebayasi userconf_command_t *uc;
833 1.47 uebayasi char *buf;
834 1.47 uebayasi off_t off;
835 1.47 uebayasi
836 1.47 uebayasi /* Calculate the userconf commands list size */
837 1.47 uebayasi count = 0;
838 1.47 uebayasi for (uc = userconf_commands; uc != NULL; uc = uc->uc_next)
839 1.47 uebayasi count++;
840 1.55 jakllsch len = sizeof(*btinfo_userconfcommands) +
841 1.47 uebayasi count * sizeof(struct bi_userconfcommand);
842 1.47 uebayasi
843 1.47 uebayasi /* Allocate the userconf commands list */
844 1.47 uebayasi btinfo_userconfcommands = alloc(len);
845 1.47 uebayasi if (btinfo_userconfcommands == NULL) {
846 1.47 uebayasi printf("WARNING: couldn't allocate userconf commands list\n");
847 1.47 uebayasi return;
848 1.47 uebayasi }
849 1.47 uebayasi memset(btinfo_userconfcommands, 0, len);
850 1.47 uebayasi btinfo_userconfcommands_size = len;
851 1.47 uebayasi
852 1.47 uebayasi /* Fill in btinfo structure */
853 1.47 uebayasi buf = (char *)btinfo_userconfcommands;
854 1.47 uebayasi off = sizeof(*btinfo_userconfcommands);
855 1.47 uebayasi btinfo_userconfcommands->num = 0;
856 1.47 uebayasi for (uc = userconf_commands; uc != NULL; uc = uc->uc_next) {
857 1.47 uebayasi struct bi_userconfcommand *bi;
858 1.47 uebayasi bi = (struct bi_userconfcommand *)(buf + off);
859 1.47 uebayasi strncpy(bi->text, uc->uc_text, sizeof(bi->text) - 1);
860 1.47 uebayasi
861 1.47 uebayasi off += sizeof(*bi);
862 1.47 uebayasi btinfo_userconfcommands->num++;
863 1.47 uebayasi }
864 1.47 uebayasi }
865 1.47 uebayasi
866 1.33 joerg int
867 1.33 joerg exec_multiboot(const char *file, char *args)
868 1.33 joerg {
869 1.74 manu physaddr_t loadaddr = 0;
870 1.62 maxv u_long marks[MARK_MAX];
871 1.62 maxv u_long extmem;
872 1.62 maxv u_long basemem;
873 1.74 manu struct multiboot_package *mbp = NULL;
874 1.33 joerg
875 1.74 manu #ifndef NO_MULTIBOOT2
876 1.74 manu if ((mbp = probe_multiboot2(file)) != NULL)
877 1.74 manu goto is_multiboot;
878 1.74 manu #endif
879 1.33 joerg
880 1.74 manu if ((mbp = probe_multiboot1(file)) != NULL) {
881 1.74 manu #ifdef EFIBOOT
882 1.74 manu printf("EFI boot requires multiboot 2 kernel\n");
883 1.33 joerg goto out;
884 1.74 manu #else
885 1.74 manu goto is_multiboot;
886 1.74 manu #endif
887 1.74 manu }
888 1.33 joerg
889 1.74 manu #ifndef NO_MULTIBOOT2
890 1.74 manu printf("%s is not a multiboot kernel\n", file);
891 1.74 manu #else
892 1.74 manu printf("%s is not a multiboot 1 kernel "
893 1.74 manu "(multiboot 2 support is not built in)\n", file);
894 1.74 manu #endif
895 1.74 manu goto out;
896 1.33 joerg
897 1.74 manu is_multiboot:
898 1.74 manu #ifdef EFIBOOT
899 1.74 manu loadaddr = efi_loadaddr;
900 1.74 manu #endif
901 1.74 manu if (common_load_kernel(file, &basemem, &extmem, loadaddr, 0, marks))
902 1.74 manu goto out;
903 1.33 joerg
904 1.74 manu if (boot_modules_enabled)
905 1.41 jmcneill module_init(file);
906 1.33 joerg
907 1.74 manu mbp->mbp_args = args;
908 1.74 manu mbp->mbp_basemem = basemem;
909 1.74 manu mbp->mbp_extmem = extmem;
910 1.74 manu mbp->mbp_loadaddr = loadaddr;
911 1.74 manu mbp->mbp_marks = marks;
912 1.33 joerg
913 1.74 manu /* Only returns on error */
914 1.74 manu (void)mbp->mbp_exec(mbp);
915 1.33 joerg
916 1.33 joerg out:
917 1.74 manu if (mbp != NULL)
918 1.74 manu mbp->mbp_cleanup(mbp);
919 1.74 manu
920 1.33 joerg return -1;
921 1.33 joerg }
922 1.40 ad
923 1.40 ad void
924 1.40 ad x86_progress(const char *fmt, ...)
925 1.40 ad {
926 1.40 ad va_list ap;
927 1.40 ad
928 1.40 ad if ((howto & AB_SILENT) != 0)
929 1.40 ad return;
930 1.40 ad va_start(ap, fmt);
931 1.40 ad vprintf(fmt, ap);
932 1.40 ad va_end(ap);
933 1.40 ad }
934