boot.c revision 1.37 1 1.37 jmcneill /* $NetBSD: boot.c,v 1.37 2021/09/28 11:37:45 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2016 Kimihiro Nonaka <nonaka (at) netbsd.org>
5 1.1 jmcneill * Copyright (c) 2018 Jared McNeill <jmcneill (at) invisible.ca>
6 1.1 jmcneill * All rights reserved.
7 1.1 jmcneill *
8 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
9 1.1 jmcneill * modification, are permitted provided that the following conditions
10 1.1 jmcneill * are met:
11 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
12 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
13 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
15 1.1 jmcneill * documentation and/or other materials provided with the distribution.
16 1.1 jmcneill *
17 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 1.1 jmcneill * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.1 jmcneill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.1 jmcneill * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 1.1 jmcneill * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1 jmcneill * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.1 jmcneill * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.1 jmcneill * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.1 jmcneill * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.1 jmcneill * SUCH DAMAGE.
28 1.1 jmcneill */
29 1.1 jmcneill
30 1.1 jmcneill #include "efiboot.h"
31 1.3 jmcneill #include "efiblock.h"
32 1.25 jmcneill #include "efifile.h"
33 1.5 jmcneill #include "efifdt.h"
34 1.10 jmcneill #include "efiacpi.h"
35 1.21 riastrad #include "efirng.h"
36 1.22 jmcneill #include "module.h"
37 1.24 thorpej #include "overlay.h"
38 1.23 jmcneill #include "bootmenu.h"
39 1.1 jmcneill
40 1.1 jmcneill #include <sys/bootblock.h>
41 1.1 jmcneill #include <sys/boot_flag.h>
42 1.1 jmcneill #include <machine/limits.h>
43 1.1 jmcneill
44 1.1 jmcneill #include <loadfile.h>
45 1.23 jmcneill #include <bootcfg.h>
46 1.1 jmcneill
47 1.1 jmcneill extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
48 1.1 jmcneill
49 1.1 jmcneill extern char twiddle_toggle;
50 1.1 jmcneill
51 1.11 mrg static const char * const names[] = {
52 1.11 mrg "netbsd", "netbsd.gz",
53 1.11 mrg "onetbsd", "onetbsd.gz",
54 1.11 mrg "netbsd.old", "netbsd.old.gz",
55 1.1 jmcneill };
56 1.1 jmcneill
57 1.1 jmcneill #define NUMNAMES __arraycount(names)
58 1.1 jmcneill
59 1.13 jmcneill static const char *efi_memory_type[] = {
60 1.13 jmcneill [EfiReservedMemoryType] = "Reserved Memory Type",
61 1.13 jmcneill [EfiLoaderCode] = "Loader Code",
62 1.13 jmcneill [EfiLoaderData] = "Loader Data",
63 1.13 jmcneill [EfiBootServicesCode] = "Boot Services Code",
64 1.13 jmcneill [EfiBootServicesData] = "Boot Services Data",
65 1.13 jmcneill [EfiRuntimeServicesCode] = "Runtime Services Code",
66 1.13 jmcneill [EfiRuntimeServicesData] = "Runtime Services Data",
67 1.13 jmcneill [EfiConventionalMemory] = "Conventional Memory",
68 1.13 jmcneill [EfiUnusableMemory] = "Unusable Memory",
69 1.13 jmcneill [EfiACPIReclaimMemory] = "ACPI Reclaim Memory",
70 1.13 jmcneill [EfiACPIMemoryNVS] = "ACPI Memory NVS",
71 1.13 jmcneill [EfiMemoryMappedIO] = "MMIO",
72 1.13 jmcneill [EfiMemoryMappedIOPortSpace] = "MMIO (Port Space)",
73 1.13 jmcneill [EfiPalCode] = "Pal Code",
74 1.13 jmcneill [EfiPersistentMemory] = "Persistent Memory",
75 1.13 jmcneill };
76 1.13 jmcneill
77 1.3 jmcneill static char default_device[32];
78 1.28 jmcneill static int default_fstype = FS_UNUSED;
79 1.6 jmcneill static char initrd_path[255];
80 1.7 jmcneill static char dtb_path[255];
81 1.14 jmcneill static char netbsd_path[255];
82 1.15 skrll static char netbsd_args[255];
83 1.19 riastrad static char rndseed_path[255];
84 1.11 mrg
85 1.11 mrg #define DEFTIMEOUT 5
86 1.11 mrg #define DEFFILENAME names[0]
87 1.11 mrg
88 1.11 mrg int set_bootfile(const char *);
89 1.15 skrll int set_bootargs(const char *);
90 1.3 jmcneill
91 1.1 jmcneill void command_boot(char *);
92 1.3 jmcneill void command_dev(char *);
93 1.7 jmcneill void command_dtb(char *);
94 1.6 jmcneill void command_initrd(char *);
95 1.19 riastrad void command_rndseed(char *);
96 1.24 thorpej void command_dtoverlay(char *);
97 1.24 thorpej void command_dtoverlays(char *);
98 1.22 jmcneill void command_modules(char *);
99 1.22 jmcneill void command_load(char *);
100 1.22 jmcneill void command_unload(char *);
101 1.3 jmcneill void command_ls(char *);
102 1.37 jmcneill void command_gop(char *);
103 1.13 jmcneill void command_mem(char *);
104 1.23 jmcneill void command_menu(char *);
105 1.1 jmcneill void command_reset(char *);
106 1.1 jmcneill void command_version(char *);
107 1.1 jmcneill void command_quit(char *);
108 1.1 jmcneill
109 1.1 jmcneill const struct boot_command commands[] = {
110 1.6 jmcneill { "boot", command_boot, "boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" },
111 1.3 jmcneill { "dev", command_dev, "dev" },
112 1.7 jmcneill { "dtb", command_dtb, "dtb [dev:][filename]" },
113 1.6 jmcneill { "initrd", command_initrd, "initrd [dev:][filename]" },
114 1.35 jmcneill { "fs", command_initrd, NULL },
115 1.19 riastrad { "rndseed", command_rndseed, "rndseed [dev:][filename]" },
116 1.24 thorpej { "dtoverlay", command_dtoverlay, "dtoverlay [dev:][filename]" },
117 1.24 thorpej { "dtoverlays", command_dtoverlays, "dtoverlays [{on|off|reset}]" },
118 1.22 jmcneill { "modules", command_modules, "modules [{on|off|reset}]" },
119 1.22 jmcneill { "load", command_load, "load <module_name>" },
120 1.22 jmcneill { "unload", command_unload, "unload <module_name>" },
121 1.4 jmcneill { "ls", command_ls, "ls [hdNn:/path]" },
122 1.37 jmcneill { "gop", command_gop, "gop [mode]" },
123 1.13 jmcneill { "mem", command_mem, "mem" },
124 1.23 jmcneill { "menu", command_menu, "menu" },
125 1.9 jmcneill { "reboot", command_reset, "reboot|reset" },
126 1.9 jmcneill { "reset", command_reset, NULL },
127 1.1 jmcneill { "version", command_version, "version" },
128 1.20 jmcneill { "ver", command_version, NULL },
129 1.1 jmcneill { "help", command_help, "help|?" },
130 1.1 jmcneill { "?", command_help, NULL },
131 1.1 jmcneill { "quit", command_quit, "quit" },
132 1.1 jmcneill { NULL, NULL },
133 1.1 jmcneill };
134 1.1 jmcneill
135 1.28 jmcneill static int
136 1.28 jmcneill bootcfg_path(char *pathbuf, size_t pathbuflen)
137 1.28 jmcneill {
138 1.28 jmcneill
139 1.28 jmcneill /*
140 1.30 rin * Fallback to default_device
141 1.30 rin * - for ISO9660 (efi_file_path() succeeds but does not work correctly)
142 1.30 rin * - or whenever efi_file_path() fails (due to broken firmware)
143 1.28 jmcneill */
144 1.30 rin if (default_fstype == FS_ISO9660 || efi_bootdp == NULL ||
145 1.30 rin efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, pathbuflen))
146 1.30 rin snprintf(pathbuf, pathbuflen, "%s:%s", default_device,
147 1.30 rin BOOTCFG_FILENAME);
148 1.28 jmcneill
149 1.30 rin return 0;
150 1.28 jmcneill }
151 1.28 jmcneill
152 1.1 jmcneill void
153 1.1 jmcneill command_help(char *arg)
154 1.1 jmcneill {
155 1.1 jmcneill int n;
156 1.1 jmcneill
157 1.1 jmcneill printf("commands are:\n");
158 1.1 jmcneill for (n = 0; commands[n].c_name; n++) {
159 1.1 jmcneill if (commands[n].c_help)
160 1.1 jmcneill printf("%s\n", commands[n].c_help);
161 1.1 jmcneill }
162 1.1 jmcneill }
163 1.1 jmcneill
164 1.1 jmcneill void
165 1.1 jmcneill command_boot(char *arg)
166 1.1 jmcneill {
167 1.1 jmcneill char *fname = arg;
168 1.11 mrg const char *kernel = *fname ? fname : bootfile;
169 1.1 jmcneill char *bootargs = gettrailer(arg);
170 1.1 jmcneill
171 1.11 mrg if (!kernel || !*kernel)
172 1.11 mrg kernel = DEFFILENAME;
173 1.11 mrg
174 1.16 skrll if (!*bootargs)
175 1.16 skrll bootargs = netbsd_args;
176 1.16 skrll
177 1.32 jmcneill efi_block_set_readahead(true);
178 1.11 mrg exec_netbsd(kernel, bootargs);
179 1.32 jmcneill efi_block_set_readahead(false);
180 1.1 jmcneill }
181 1.1 jmcneill
182 1.1 jmcneill void
183 1.3 jmcneill command_dev(char *arg)
184 1.3 jmcneill {
185 1.3 jmcneill if (arg && *arg) {
186 1.3 jmcneill set_default_device(arg);
187 1.3 jmcneill } else {
188 1.3 jmcneill efi_block_show();
189 1.4 jmcneill efi_net_show();
190 1.3 jmcneill }
191 1.3 jmcneill
192 1.3 jmcneill if (strlen(default_device) > 0) {
193 1.3 jmcneill printf("\n");
194 1.3 jmcneill printf("default: %s\n", default_device);
195 1.3 jmcneill }
196 1.3 jmcneill }
197 1.3 jmcneill
198 1.3 jmcneill void
199 1.7 jmcneill command_dtb(char *arg)
200 1.7 jmcneill {
201 1.7 jmcneill set_dtb_path(arg);
202 1.7 jmcneill }
203 1.7 jmcneill
204 1.7 jmcneill void
205 1.24 thorpej command_initrd(char *arg)
206 1.18 thorpej {
207 1.24 thorpej set_initrd_path(arg);
208 1.18 thorpej }
209 1.18 thorpej
210 1.18 thorpej void
211 1.24 thorpej command_rndseed(char *arg)
212 1.24 thorpej {
213 1.24 thorpej set_rndseed_path(arg);
214 1.24 thorpej }
215 1.24 thorpej
216 1.24 thorpej void
217 1.24 thorpej command_dtoverlays(char *arg)
218 1.6 jmcneill {
219 1.24 thorpej if (arg && *arg) {
220 1.24 thorpej if (strcmp(arg, "on") == 0)
221 1.24 thorpej dtoverlay_enable(1);
222 1.24 thorpej else if (strcmp(arg, "off") == 0)
223 1.24 thorpej dtoverlay_enable(0);
224 1.24 thorpej else if (strcmp(arg, "reset") == 0)
225 1.24 thorpej dtoverlay_remove_all();
226 1.24 thorpej else {
227 1.24 thorpej command_help("");
228 1.24 thorpej return;
229 1.24 thorpej }
230 1.24 thorpej } else {
231 1.24 thorpej printf("Device Tree overlays are %sabled\n",
232 1.24 thorpej dtoverlay_enabled ? "en" : "dis");
233 1.24 thorpej }
234 1.6 jmcneill }
235 1.6 jmcneill
236 1.6 jmcneill void
237 1.24 thorpej command_dtoverlay(char *arg)
238 1.19 riastrad {
239 1.24 thorpej if (!arg || !*arg) {
240 1.24 thorpej command_help("");
241 1.24 thorpej return;
242 1.24 thorpej }
243 1.24 thorpej
244 1.24 thorpej dtoverlay_add(arg);
245 1.19 riastrad }
246 1.19 riastrad
247 1.19 riastrad void
248 1.22 jmcneill command_modules(char *arg)
249 1.22 jmcneill {
250 1.22 jmcneill if (arg && *arg) {
251 1.22 jmcneill if (strcmp(arg, "on") == 0)
252 1.22 jmcneill module_enable(1);
253 1.22 jmcneill else if (strcmp(arg, "off") == 0)
254 1.22 jmcneill module_enable(0);
255 1.22 jmcneill else if (strcmp(arg, "reset") == 0)
256 1.22 jmcneill module_remove_all();
257 1.22 jmcneill else {
258 1.22 jmcneill command_help("");
259 1.22 jmcneill return;
260 1.22 jmcneill }
261 1.22 jmcneill } else {
262 1.22 jmcneill printf("modules are %sabled\n", module_enabled ? "en" : "dis");
263 1.22 jmcneill }
264 1.22 jmcneill }
265 1.22 jmcneill
266 1.22 jmcneill void
267 1.22 jmcneill command_load(char *arg)
268 1.22 jmcneill {
269 1.22 jmcneill if (!arg || !*arg) {
270 1.22 jmcneill command_help("");
271 1.22 jmcneill return;
272 1.22 jmcneill }
273 1.22 jmcneill
274 1.22 jmcneill module_add(arg);
275 1.22 jmcneill }
276 1.22 jmcneill
277 1.22 jmcneill void
278 1.22 jmcneill command_unload(char *arg)
279 1.22 jmcneill {
280 1.22 jmcneill if (!arg || !*arg) {
281 1.22 jmcneill command_help("");
282 1.22 jmcneill return;
283 1.22 jmcneill }
284 1.22 jmcneill
285 1.22 jmcneill module_remove(arg);
286 1.22 jmcneill }
287 1.22 jmcneill
288 1.22 jmcneill void
289 1.3 jmcneill command_ls(char *arg)
290 1.3 jmcneill {
291 1.3 jmcneill ls(arg);
292 1.3 jmcneill }
293 1.3 jmcneill
294 1.3 jmcneill void
295 1.37 jmcneill command_gop(char *arg)
296 1.37 jmcneill {
297 1.37 jmcneill UINT32 mode;
298 1.37 jmcneill
299 1.37 jmcneill if (!arg || !*arg) {
300 1.37 jmcneill efi_gop_dump();
301 1.37 jmcneill return;
302 1.37 jmcneill }
303 1.37 jmcneill
304 1.37 jmcneill mode = atoi(arg);
305 1.37 jmcneill efi_gop_setmode(mode);
306 1.37 jmcneill }
307 1.37 jmcneill
308 1.37 jmcneill void
309 1.13 jmcneill command_mem(char *arg)
310 1.13 jmcneill {
311 1.13 jmcneill EFI_MEMORY_DESCRIPTOR *md, *memmap;
312 1.13 jmcneill UINTN nentries, mapkey, descsize;
313 1.13 jmcneill UINT32 descver;
314 1.13 jmcneill int n;
315 1.13 jmcneill
316 1.13 jmcneill printf("Type Start End Attributes\n");
317 1.13 jmcneill printf("---------------------- ---------------- ---------------- ----------------\n");
318 1.13 jmcneill memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
319 1.13 jmcneill for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
320 1.13 jmcneill const char *mem_type = "<unknown>";
321 1.13 jmcneill if (md->Type < __arraycount(efi_memory_type))
322 1.13 jmcneill mem_type = efi_memory_type[md->Type];
323 1.13 jmcneill
324 1.13 jmcneill printf("%-22s %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
325 1.13 jmcneill mem_type, md->PhysicalStart, md->PhysicalStart + (md->NumberOfPages * EFI_PAGE_SIZE) - 1,
326 1.13 jmcneill md->Attribute);
327 1.13 jmcneill }
328 1.13 jmcneill }
329 1.13 jmcneill
330 1.13 jmcneill void
331 1.23 jmcneill command_menu(char *arg)
332 1.23 jmcneill {
333 1.23 jmcneill if (bootcfg_info.nummenu == 0) {
334 1.23 jmcneill printf("No menu defined in boot.cfg\n");
335 1.23 jmcneill return;
336 1.23 jmcneill }
337 1.23 jmcneill
338 1.23 jmcneill doboottypemenu(); /* Does not return */
339 1.23 jmcneill }
340 1.23 jmcneill
341 1.23 jmcneill void
342 1.1 jmcneill command_version(char *arg)
343 1.1 jmcneill {
344 1.26 jmcneill char pathbuf[80];
345 1.1 jmcneill char *ufirmware;
346 1.1 jmcneill int rv;
347 1.1 jmcneill
348 1.20 jmcneill printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev);
349 1.20 jmcneill printf("EFI: %d.%02d\n",
350 1.1 jmcneill ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
351 1.1 jmcneill ufirmware = NULL;
352 1.1 jmcneill rv = ucs2_to_utf8(ST->FirmwareVendor, &ufirmware);
353 1.1 jmcneill if (rv == 0) {
354 1.20 jmcneill printf("Firmware: %s (rev 0x%x)\n", ufirmware,
355 1.17 jmcneill ST->FirmwareRevision);
356 1.1 jmcneill FreePool(ufirmware);
357 1.1 jmcneill }
358 1.28 jmcneill if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) {
359 1.26 jmcneill printf("Config path: %s\n", pathbuf);
360 1.26 jmcneill }
361 1.5 jmcneill
362 1.5 jmcneill efi_fdt_show();
363 1.10 jmcneill efi_acpi_show();
364 1.21 riastrad efi_rng_show();
365 1.29 jmcneill efi_md_show();
366 1.37 jmcneill efi_gop_show();
367 1.1 jmcneill }
368 1.1 jmcneill
369 1.1 jmcneill void
370 1.1 jmcneill command_quit(char *arg)
371 1.1 jmcneill {
372 1.1 jmcneill efi_exit();
373 1.1 jmcneill }
374 1.1 jmcneill
375 1.9 jmcneill void
376 1.9 jmcneill command_reset(char *arg)
377 1.9 jmcneill {
378 1.9 jmcneill efi_reboot();
379 1.9 jmcneill }
380 1.9 jmcneill
381 1.3 jmcneill int
382 1.11 mrg set_default_device(const char *arg)
383 1.3 jmcneill {
384 1.3 jmcneill if (strlen(arg) + 1 > sizeof(default_device))
385 1.3 jmcneill return ERANGE;
386 1.3 jmcneill strcpy(default_device, arg);
387 1.3 jmcneill return 0;
388 1.3 jmcneill }
389 1.3 jmcneill
390 1.3 jmcneill char *
391 1.3 jmcneill get_default_device(void)
392 1.3 jmcneill {
393 1.3 jmcneill return default_device;
394 1.3 jmcneill }
395 1.3 jmcneill
396 1.28 jmcneill void
397 1.28 jmcneill set_default_fstype(int fstype)
398 1.28 jmcneill {
399 1.28 jmcneill default_fstype = fstype;
400 1.28 jmcneill }
401 1.28 jmcneill
402 1.28 jmcneill int
403 1.28 jmcneill get_default_fstype(void)
404 1.28 jmcneill {
405 1.28 jmcneill return default_fstype;
406 1.28 jmcneill }
407 1.28 jmcneill
408 1.6 jmcneill int
409 1.11 mrg set_initrd_path(const char *arg)
410 1.6 jmcneill {
411 1.6 jmcneill if (strlen(arg) + 1 > sizeof(initrd_path))
412 1.6 jmcneill return ERANGE;
413 1.6 jmcneill strcpy(initrd_path, arg);
414 1.6 jmcneill return 0;
415 1.6 jmcneill }
416 1.6 jmcneill
417 1.6 jmcneill char *
418 1.6 jmcneill get_initrd_path(void)
419 1.6 jmcneill {
420 1.6 jmcneill return initrd_path;
421 1.6 jmcneill }
422 1.6 jmcneill
423 1.7 jmcneill int
424 1.11 mrg set_dtb_path(const char *arg)
425 1.7 jmcneill {
426 1.7 jmcneill if (strlen(arg) + 1 > sizeof(dtb_path))
427 1.7 jmcneill return ERANGE;
428 1.7 jmcneill strcpy(dtb_path, arg);
429 1.7 jmcneill return 0;
430 1.7 jmcneill }
431 1.7 jmcneill
432 1.7 jmcneill char *
433 1.7 jmcneill get_dtb_path(void)
434 1.7 jmcneill {
435 1.7 jmcneill return dtb_path;
436 1.7 jmcneill }
437 1.7 jmcneill
438 1.11 mrg int
439 1.19 riastrad set_rndseed_path(const char *arg)
440 1.19 riastrad {
441 1.19 riastrad if (strlen(arg) + 1 > sizeof(rndseed_path))
442 1.19 riastrad return ERANGE;
443 1.19 riastrad strcpy(rndseed_path, arg);
444 1.19 riastrad return 0;
445 1.19 riastrad }
446 1.19 riastrad
447 1.19 riastrad char *
448 1.19 riastrad get_rndseed_path(void)
449 1.19 riastrad {
450 1.19 riastrad return rndseed_path;
451 1.19 riastrad }
452 1.19 riastrad
453 1.19 riastrad int
454 1.11 mrg set_bootfile(const char *arg)
455 1.11 mrg {
456 1.14 jmcneill if (strlen(arg) + 1 > sizeof(netbsd_path))
457 1.11 mrg return ERANGE;
458 1.14 jmcneill strcpy(netbsd_path, arg);
459 1.11 mrg return 0;
460 1.11 mrg }
461 1.11 mrg
462 1.15 skrll int
463 1.15 skrll set_bootargs(const char *arg)
464 1.15 skrll {
465 1.15 skrll if (strlen(arg) + 1 > sizeof(netbsd_args))
466 1.15 skrll return ERANGE;
467 1.15 skrll strcpy(netbsd_args, arg);
468 1.15 skrll return 0;
469 1.15 skrll }
470 1.15 skrll
471 1.1 jmcneill void
472 1.1 jmcneill boot(void)
473 1.1 jmcneill {
474 1.25 jmcneill char pathbuf[80];
475 1.1 jmcneill int currname, c;
476 1.1 jmcneill
477 1.28 jmcneill if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) {
478 1.25 jmcneill twiddle_toggle = 1;
479 1.25 jmcneill parsebootconf(pathbuf);
480 1.25 jmcneill }
481 1.23 jmcneill
482 1.23 jmcneill if (bootcfg_info.clear)
483 1.23 jmcneill uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
484 1.23 jmcneill
485 1.36 nia print_bootcfg_banner(bootprog_name, bootprog_rev);
486 1.23 jmcneill
487 1.23 jmcneill /* Display menu if configured */
488 1.23 jmcneill if (bootcfg_info.nummenu > 0) {
489 1.23 jmcneill doboottypemenu(); /* No return */
490 1.23 jmcneill }
491 1.23 jmcneill
492 1.11 mrg printf("Press return to boot now, any other key for boot prompt\n");
493 1.1 jmcneill
494 1.14 jmcneill if (netbsd_path[0] != '\0')
495 1.11 mrg currname = -1;
496 1.11 mrg else
497 1.11 mrg currname = 0;
498 1.11 mrg
499 1.12 mrg for (; currname < (int)NUMNAMES; currname++) {
500 1.11 mrg if (currname >= 0)
501 1.11 mrg set_bootfile(names[currname]);
502 1.16 skrll printf("booting %s%s%s - starting in ", netbsd_path,
503 1.16 skrll netbsd_args[0] != '\0' ? " " : "", netbsd_args);
504 1.1 jmcneill
505 1.1 jmcneill c = awaitkey(DEFTIMEOUT, 1);
506 1.11 mrg if (c != '\r' && c != '\n' && c != '\0')
507 1.1 jmcneill bootprompt(); /* does not return */
508 1.1 jmcneill
509 1.32 jmcneill efi_block_set_readahead(true);
510 1.15 skrll exec_netbsd(netbsd_path, netbsd_args);
511 1.32 jmcneill efi_block_set_readahead(false);
512 1.1 jmcneill }
513 1.1 jmcneill
514 1.1 jmcneill bootprompt(); /* does not return */
515 1.1 jmcneill }
516