Wed Jul 15 15:54:50 2020 UTC ()
Pull up following revision(s) (requested by kim in ticket #1575):

	sys/arch/i386/stand/boot/boot2.c: revision 1.74
	share/man/man8/man8.x86/boot.8: revision 1.21

Let consdev command also set speed
Adapted from PR install/55490 by Sunil Nimmagadda

Document optional speed argument to consdev


(martin)
diff -r1.11.4.4 -r1.11.4.5 src/share/man/man8/man8.x86/boot.8
diff -r1.66.10.1 -r1.66.10.2 src/sys/arch/i386/stand/boot/boot2.c

cvs diff -r1.11.4.4 -r1.11.4.5 src/share/man/man8/man8.x86/boot.8 (switch to unified diff)

--- src/share/man/man8/man8.x86/boot.8 2019/09/18 17:30:05 1.11.4.4
+++ src/share/man/man8/man8.x86/boot.8 2020/07/15 15:54:50 1.11.4.5
@@ -1,862 +1,873 @@ @@ -1,862 +1,873 @@
1.\" $NetBSD: boot.8,v 1.11.4.4 2019/09/18 17:30:05 martin Exp $ 1.\" $NetBSD: boot.8,v 1.11.4.5 2020/07/15 15:54:50 martin Exp $
2.\" 2.\"
3.\" Copyright (c) 1991, 1993 3.\" Copyright (c) 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" This code is derived from software written and contributed 6.\" This code is derived from software written and contributed
7.\" to Berkeley by William Jolitz. 7.\" to Berkeley by William Jolitz.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the 15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution. 16.\" documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors 17.\" 3. Neither the name of the University nor the names of its contributors
18.\" may be used to endorse or promote products derived from this software 18.\" may be used to endorse or promote products derived from this software
19.\" without specific prior written permission. 19.\" without specific prior written permission.
20.\" 20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94 33.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94
34.\" 34.\"
35.Dd September 13, 2019 35.Dd July 15, 2020
36.Dt BOOT 8 x86 36.Dt BOOT 8 x86
37.Os 37.Os
38.Sh NAME 38.Sh NAME
39.Nm boot 39.Nm boot
40.Nd 40.Nd
41system bootstrapping procedures 41system bootstrapping procedures
42.Sh DESCRIPTION 42.Sh DESCRIPTION
43Intel Architecture, 32-bit (IA-32) computers (the 43Intel Architecture, 32-bit (IA-32) computers (the
44.Tn IBM PC 44.Tn IBM PC
45and its clones) 45and its clones)
46that can run 46that can run
47.Nx Ns /i386 47.Nx Ns /i386
48or 48or
49.Nx Ns /amd64 49.Nx Ns /amd64
50can use any of the following boot procedures, depending on what the hardware and 50can use any of the following boot procedures, depending on what the hardware and
51.Tn BIOS 51.Tn BIOS
52support: 52support:
53.Bl -tag -width "x86/pxeboot(8)" 53.Bl -tag -width "x86/pxeboot(8)"
54.It boot 54.It boot
55bootstrap 55bootstrap
56.Nx 56.Nx
57from the system 57from the system
58.Tn BIOS 58.Tn BIOS
59.It efiboot 59.It efiboot
60bootstrap 60bootstrap
61.Nx 61.Nx
62from the system 62from the system
63.Tn UEFI 63.Tn UEFI
64.It Xr x86/dosboot 8 64.It Xr x86/dosboot 8
65bootstrap 65bootstrap
66.Nx 66.Nx
67from 67from
68.Tn MS-DOS 68.Tn MS-DOS
69.It Xr x86/pxeboot 8 69.It Xr x86/pxeboot 8
70network bootstrap 70network bootstrap
71.Nx 71.Nx
72from a 72from a
73.Tn TCP/IP 73.Tn TCP/IP
74.Tn LAN 74.Tn LAN
75with 75with
76.Tn DHCP , 76.Tn DHCP ,
77.Tn TFTP , 77.Tn TFTP ,
78and 78and
79.Tn NFS . 79.Tn NFS .
80.El 80.El
81.Ss Power fail and crash recovery 81.Ss Power fail and crash recovery
82Normally, the system will reboot itself at power-up or after crashes. 82Normally, the system will reboot itself at power-up or after crashes.
83An automatic consistency check of the file systems will be performed, 83An automatic consistency check of the file systems will be performed,
84and unless this fails, the system will resume multi-user operations. 84and unless this fails, the system will resume multi-user operations.
85.Ss Cold starts 85.Ss Cold starts
86The 386 86The 386
87.Tn "PC AT" 87.Tn "PC AT"
88clones attempt to boot the floppy disk drive A (otherwise known as drive 88clones attempt to boot the floppy disk drive A (otherwise known as drive
890) first, and failing that, attempt to boot the hard disk C (otherwise 890) first, and failing that, attempt to boot the hard disk C (otherwise
90known as hard disk controller 1, drive 0). 90known as hard disk controller 1, drive 0).
91The 91The
92.Nx 92.Nx
93bootblocks are loaded and started either by the 93bootblocks are loaded and started either by the
94.Tn BIOS , 94.Tn BIOS ,
95or by a boot selector program (such as OS-BS, BOOTEASY, the OS/2 Boot Menu or 95or by a boot selector program (such as OS-BS, BOOTEASY, the OS/2 Boot Menu or
96.Nx Ns 's 96.Nx Ns 's
97.No boot-selecting 97.No boot-selecting
98master boot record - see 98master boot record - see
99.Xr x86/mbr 8 ) . 99.Xr x86/mbr 8 ) .
100.Ss Normal Operation 100.Ss Normal Operation
101Once running, a banner similar to the following will appear: 101Once running, a banner similar to the following will appear:
102.Bd -unfilled -offset indent 102.Bd -unfilled -offset indent
103>> NetBSD BIOS Boot, revision 3.0 103>> NetBSD BIOS Boot, revision 3.0
104>> (user@buildhost, builddate) 104>> (user@buildhost, builddate)
105>> Memory: 637/15360 k 105>> Memory: 637/15360 k
106Press return to boot now, any other key for boot menu 106Press return to boot now, any other key for boot menu
107booting hd0a:netbsd - starting in 5 107booting hd0a:netbsd - starting in 5
108.Ed 108.Ed
109.Pp 109.Pp
110After a countdown, the system image listed will be loaded. 110After a countdown, the system image listed will be loaded.
111In the example above, it will be 111In the example above, it will be
112.Dq Li hd0a:netbsd 112.Dq Li hd0a:netbsd
113which is the file 113which is the file
114.Pa /netbsd 114.Pa /netbsd
115on partition 115on partition
116.Dq a 116.Dq a
117of the 117of the
118.Nx 118.Nx
119.Tn MBR 119.Tn MBR
120partition of the first hard disk known to the 120partition of the first hard disk known to the
121.Tn BIOS 121.Tn BIOS
122.Po 122.Po
123which is an 123which is an
124.Tn IDE 124.Tn IDE
125or similar device - see the 125or similar device - see the
126.Sx BUGS 126.Sx BUGS
127section 127section
128.Pc . 128.Pc .
129.Pp 129.Pp
130Pressing a key within the time limit, or before the boot program starts, will 130Pressing a key within the time limit, or before the boot program starts, will
131enter interactive mode. 131enter interactive mode.
132When using a short or 0 timeout, it is often useful to interrupt the boot 132When using a short or 0 timeout, it is often useful to interrupt the boot
133by holding down a shift key, as some BIOSes and BIOS extensions will drain the 133by holding down a shift key, as some BIOSes and BIOS extensions will drain the
134keystroke buffer at various points during POST. 134keystroke buffer at various points during POST.
135.Pp 135.Pp
136If present, the file 136If present, the file
137.Pa /boot.cfg 137.Pa /boot.cfg
138will be used to configure the behaviour of the boot loader including 138will be used to configure the behaviour of the boot loader including
139setting the timeout, choosing a console device, altering the banner 139setting the timeout, choosing a console device, altering the banner
140text and displaying a menu allowing boot commands to be easily chosen. 140text and displaying a menu allowing boot commands to be easily chosen.
141See 141See
142.Xr boot.cfg 5 . 142.Xr boot.cfg 5 .
143.Ss Boot Protocol 143.Ss Boot Protocol
144The 144The
145.Nx Ns /x86 145.Nx Ns /x86
146boot loader can boot a kernel using either the native 146boot loader can boot a kernel using either the native
147.Nx 147.Nx
148boot protocol, or the 148boot protocol, or the
149.Dq multiboot 149.Dq multiboot
150protocol (which is compatible with some other operating systems). 150protocol (which is compatible with some other operating systems).
151In the native 151In the native
152.Nx 152.Nx
153boot protocol, options are passed from the boot loader 153boot protocol, options are passed from the boot loader
154to the kernel via flag bits in the 154to the kernel via flag bits in the
155.Va boothowto 155.Va boothowto
156variable (see 156variable (see
157.Xr boothowto 9 ) . 157.Xr boothowto 9 ) .
158In the multiboot protocol, options are passed from the boot loader 158In the multiboot protocol, options are passed from the boot loader
159to the kernel as strings. 159to the kernel as strings.
160.Ss Diagnostic Output 160.Ss Diagnostic Output
161If the first stage boot fails to load the boot, it will print a terse 161If the first stage boot fails to load the boot, it will print a terse
162message indicating the reason for the failure. 162message indicating the reason for the failure.
163The possible error messages and their cause are listed in 163The possible error messages and their cause are listed in
164.Xr x86/mbr 8 . 164.Xr x86/mbr 8 .
165.Pp 165.Pp
166If the first stage boot succeeds, the banner will be shown and the 166If the first stage boot succeeds, the banner will be shown and the
167error messages should be self-explanatory. 167error messages should be self-explanatory.
168.Ss Interactive mode 168.Ss Interactive mode
169In interactive mode, the boot loader will present a prompt, allowing 169In interactive mode, the boot loader will present a prompt, allowing
170input of these commands: 170input of these commands:
171.\" NOTE: much of this text is duplicated in the MI boot.8. 171.\" NOTE: much of this text is duplicated in the MI boot.8.
172.\" Some of it is 172.\" Some of it is
173.\" also duplicated in the x86-specific x86/dosboot.8 and x86/pxeboot.8; 173.\" also duplicated in the x86-specific x86/dosboot.8 and x86/pxeboot.8;
174.\" please try to keep all relevant files synchronized. 174.\" please try to keep all relevant files synchronized.
175.Bl -tag -width 04n -offset 04n 175.Bl -tag -width 04n -offset 04n
176.It Ic boot Oo Va device : Oc Ns Oo Va filename Oc Oo Fl 1234abcdmqsvxz Oc 176.It Ic boot Oo Va device : Oc Ns Oo Va filename Oc Oo Fl 1234abcdmqsvxz Oc
177The default 177The default
178.Va device 178.Va device
179will be set to the disk from which the boot loader was loaded. 179will be set to the disk from which the boot loader was loaded.
180The partition is set to the first match in this list: 180The partition is set to the first match in this list:
181.Bl -enum -compact 181.Bl -enum -compact
182.It 182.It
183The first 183The first
184.Xr gpt 8 184.Xr gpt 8
185partition with the 185partition with the
186.Va bootme 186.Va bootme
187attribute set. 187attribute set.
188.It 188.It
189The partition from which the boot loader was loaded from, if that 189The partition from which the boot loader was loaded from, if that
190can be detected. 190can be detected.
191.It 191.It
192The first partition with a file system that could be bootable. 192The first partition with a file system that could be bootable.
193.It 193.It
194The first partition. 194The first partition.
195.El 195.El
196To boot from an alternate disk, the full name of the device should 196To boot from an alternate disk, the full name of the device should
197be given at the prompt. 197be given at the prompt.
198.Va device 198.Va device
199is of the form 199is of the form
200.Va NAME=partition_label 200.Va NAME=partition_label
201when booting from a 201when booting from a
202.Xr gpt 8 202.Xr gpt 8
203partitioned disk. 203partitioned disk.
204Otherwise, the syntax is 204Otherwise, the syntax is
205.Xo Va xd 205.Xo Va xd
206.Op Va N Ns Op Va x 206.Op Va N Ns Op Va x
207.Xc 207.Xc
208where 208where
209.Va xd 209.Va xd
210is the device from which to boot, 210is the device from which to boot,
211.Va N 211.Va N
212is the unit number, and 212is the unit number, and
213.Va x 213.Va x
214is the partition letter. 214is the partition letter.
215.Pp 215.Pp
216In the later case, the following list of supported devices may 216In the later case, the following list of supported devices may
217vary from installation to installation: 217vary from installation to installation:
218.Pp 218.Pp
219.Bl -hang -compact 219.Bl -hang -compact
220.It hd 220.It hd
221Hard disks as numbered by the BIOS. 221Hard disks as numbered by the BIOS.
222This includes ST506, IDE, ESDI, RLL disks on a WD100[2367] or 222This includes ST506, IDE, ESDI, RLL disks on a WD100[2367] or
223lookalike controller(s), and SCSI disks 223lookalike controller(s), and SCSI disks
224on SCSI controllers recognized by the BIOS. 224on SCSI controllers recognized by the BIOS.
225.It fd 225.It fd
226Floppy drives as numbered by the BIOS. 226Floppy drives as numbered by the BIOS.
227.It cd 227.It cd
228CD-ROM drives as numbered by the BIOS. 228CD-ROM drives as numbered by the BIOS.
229.It raid 229.It raid
230RAIDframe configured from hard disks recognized by the BIOS. 230RAIDframe configured from hard disks recognized by the BIOS.
231Only RAID level 1 sets are supported by bootstrap code. 231Only RAID level 1 sets are supported by bootstrap code.
232If the RAID is partitioned, the first partition is used, or the 232If the RAID is partitioned, the first partition is used, or the
233first 233first
234.Xr gpt 8 234.Xr gpt 8
235partition that has the 235partition that has the
236.Va bootme 236.Va bootme
237attribute set. 237attribute set.
238Inner RAIDframe partitions can also be given to the 238Inner RAIDframe partitions can also be given to the
239.Ic dev 239.Ic dev
240command using he 240command using he
241.Va NAME=partition_label 241.Va NAME=partition_label
242syntax. 242syntax.
243.El 243.El
244.Pp 244.Pp
245The default 245The default
246.Va filename 246.Va filename
247is 247is
248.Pa netbsd ; 248.Pa netbsd ;
249if the boot loader fails to successfully 249if the boot loader fails to successfully
250open that image, it then tries 250open that image, it then tries
251.Pa netbsd.gz 251.Pa netbsd.gz
252(expected to be a kernel image compressed by gzip), followed by 252(expected to be a kernel image compressed by gzip), followed by
253.Pa netbsd.old , 253.Pa netbsd.old ,
254.Pa netbsd.old.gz , 254.Pa netbsd.old.gz ,
255.Pa onetbsd , 255.Pa onetbsd ,
256and finally 256and finally
257.Pa onetbsd.gz . 257.Pa onetbsd.gz .
258Alternate system images can be loaded by just specifying the name of the image. 258Alternate system images can be loaded by just specifying the name of the image.
259.Pp 259.Pp
260Options are: 260Options are:
261.Bl -tag -width xxx 261.Bl -tag -width xxx
262.It Fl 1 262.It Fl 1
263Sets the machine-dependent flag 263Sets the machine-dependent flag
264.Sy RB_MD1 264.Sy RB_MD1
265in 265in
266.Va boothowto . 266.Va boothowto .
267In 267In
268.Nx Ns /x86 , 268.Nx Ns /x86 ,
269this disables multiprocessor boot; 269this disables multiprocessor boot;
270the kernel will boot in uniprocessor mode. 270the kernel will boot in uniprocessor mode.
271.It Fl 2 271.It Fl 2
272Sets the machine-dependent flag 272Sets the machine-dependent flag
273.Sy RB_MD2 273.Sy RB_MD2
274in 274in
275.Va boothowto . 275.Va boothowto .
276In 276In
277.Nx Ns /x86 , 277.Nx Ns /x86 ,
278this disables ACPI. 278this disables ACPI.
279.It Fl 3 279.It Fl 3
280Sets the machine-dependent flag 280Sets the machine-dependent flag
281.Sy RB_MD3 281.Sy RB_MD3
282in 282in
283.Va boothowto . 283.Va boothowto .
284In 284In
285.Nx Ns /x86 , 285.Nx Ns /x86 ,
286this has no effect. 286this has no effect.
287.It Fl 4 287.It Fl 4
288Sets the machine-dependent flag 288Sets the machine-dependent flag
289.Sy RB_MD4 289.Sy RB_MD4
290in 290in
291.Va boothowto . 291.Va boothowto .
292In 292In
293.Nx Ns /x86 , 293.Nx Ns /x86 ,
294this has no effect. 294this has no effect.
295.It Fl a 295.It Fl a
296Sets the 296Sets the
297.Sy RB_ASKNAME 297.Sy RB_ASKNAME
298flag in 298flag in
299.Va boothowto . 299.Va boothowto .
300This causes the kernel to prompt for the root file system device, 300This causes the kernel to prompt for the root file system device,
301the system crash dump device, and the path to 301the system crash dump device, and the path to
302.Xr init 8 . 302.Xr init 8 .
303.It Fl b 303.It Fl b
304Sets the 304Sets the
305.Sy RB_HALT 305.Sy RB_HALT
306flag in 306flag in
307.Va boothowto . 307.Va boothowto .
308This causes subsequent reboot attempts to halt instead of rebooting. 308This causes subsequent reboot attempts to halt instead of rebooting.
309.It Fl c 309.It Fl c
310Sets the 310Sets the
311.Sy RB_USERCONF 311.Sy RB_USERCONF
312flag in 312flag in
313.Va boothowto . 313.Va boothowto .
314This causes the kernel to enter the 314This causes the kernel to enter the
315.Xr userconf 4 315.Xr userconf 4
316device configuration manager as soon as possible during the boot. 316device configuration manager as soon as possible during the boot.
317.Xr userconf 4 317.Xr userconf 4
318allows devices to be enabled or disabled, and allows device locators 318allows devices to be enabled or disabled, and allows device locators
319(such as hardware addresses or bus numbers) 319(such as hardware addresses or bus numbers)
320to be modified before the kernel attempts to attach the devices. 320to be modified before the kernel attempts to attach the devices.
321.It Fl d 321.It Fl d
322Sets the 322Sets the
323.Sy RB_KDB 323.Sy RB_KDB
324flag in 324flag in
325.Va boothowto . 325.Va boothowto .
326Requests the kernel to enter debug mode, in which it 326Requests the kernel to enter debug mode, in which it
327waits for a connection from a kernel debugger; see 327waits for a connection from a kernel debugger; see
328.Xr ddb 4 . 328.Xr ddb 4 .
329.It Fl m 329.It Fl m
330Sets the 330Sets the
331.Sy RB_MINIROOT 331.Sy RB_MINIROOT
332flag in 332flag in
333.Va boothowto . 333.Va boothowto .
334Informs the kernel that a mini-root file system is present in memory. 334Informs the kernel that a mini-root file system is present in memory.
335.It Fl q 335.It Fl q
336Sets the 336Sets the
337.Sy AB_QUIET 337.Sy AB_QUIET
338flag in 338flag in
339.Va boothowto . 339.Va boothowto .
340Boot the system in quiet mode. 340Boot the system in quiet mode.
341.It Fl s 341.It Fl s
342Sets the 342Sets the
343.Sy RB_SINGLE 343.Sy RB_SINGLE
344flag in 344flag in
345.Va boothowto . 345.Va boothowto .
346Boot the system in single-user mode. 346Boot the system in single-user mode.
347.It Fl v 347.It Fl v
348Sets the 348Sets the
349.Sy AB_VERBOSE 349.Sy AB_VERBOSE
350flag in 350flag in
351.Va boothowto . 351.Va boothowto .
352Boot the system in verbose mode. 352Boot the system in verbose mode.
353.It Fl x 353.It Fl x
354Sets the 354Sets the
355.Sy AB_DEBUG 355.Sy AB_DEBUG
356flag in 356flag in
357.Va boothowto . 357.Va boothowto .
358Boot the system with debug messages enabled. 358Boot the system with debug messages enabled.
359.It Fl z 359.It Fl z
360Sets the 360Sets the
361.Sy AB_SILENT 361.Sy AB_SILENT
362flag in 362flag in
363.Va boothowto . 363.Va boothowto .
364Boot the system in silent mode. 364Boot the system in silent mode.
365.El 365.El
366.It Ic consdev Va dev 366.It Ic consdev Va dev Ns Oo Ns , Ns Va speed Oc
367Immediately switch the console to the specified device 367Immediately switch the console to the specified device
368.Va dev 368.Va dev
369and reprint the banner. 369and reprint the banner.
370.Va dev 370.Va dev
371must be one of 371must be one of
372.\" .Bl -item -width com[0123]kbd -offset indent -compact 372.\" .Bl -item -width com[0123]kbd -offset indent -compact
373.Ar pc , com0 , com1 , com2 , 373.Ar pc , com0 , com1 , com2 ,
374.Ar com3 , com0kbd , com1kbd , com2kbd , 374.Ar com3 , com0kbd , com1kbd , com2kbd ,
375.Ar com3kbd , 375.Ar com3kbd ,
376or 376or
377.Ar auto . 377.Ar auto .
378See 378See
379.Sx Console Selection Policy 379.Sx Console Selection Policy
380in 380in
381.Xr x86/boot_console 8 . 381.Xr x86/boot_console 8 .
 382.Pp
 383A
 384.Va speed
 385for the serial port is optional and defaults to 9600.
 386If a value of zero is specified, then the current baud rate (set by the
 387BIOS) will be used.
 388Setting the
 389.Va speed
 390with the
 391.Ar pc
 392device is not possible.
382.It Ic dev Op Va device 393.It Ic dev Op Va device
383Set the default drive and partition for subsequent file system 394Set the default drive and partition for subsequent file system
384operations. 395operations.
385Without an argument, print the current setting. 396Without an argument, print the current setting.
386.Va device 397.Va device
387is of the form specified in 398is of the form specified in
388.Cm boot . 399.Cm boot .
389.It Ic fs Va file 400.It Ic fs Va file
390Load a file system image from the specified 401Load a file system image from the specified
391.Ar file , 402.Ar file ,
392and request the kernel to use it as the root file system. 403and request the kernel to use it as the root file system.
393The 404The
394.Xr makefs 8 405.Xr makefs 8
395utility may be used to create suitable file system images. 406utility may be used to create suitable file system images.
396.It Ic help 407.It Ic help
397Print an overview about commands and arguments. 408Print an overview about commands and arguments.
398.It Ic load Va module Op Ar arguments 409.It Ic load Va module Op Ar arguments
399Load the specified kernel 410Load the specified kernel
400.Va module , 411.Va module ,
401and pass it the specified 412and pass it the specified
402.Ar arguments . 413.Ar arguments .
403If the module name is not an absolute path, 414If the module name is not an absolute path,
404.Pa /stand/ Xo Ns 415.Pa /stand/ Xo Ns
405.Aq Sy arch Ns 416.Aq Sy arch Ns
406.Pa / Ns 417.Pa / Ns
407.Aq Sy osversion Ns 418.Aq Sy osversion Ns
408.Pa /modules/ Ns 419.Pa /modules/ Ns
409.Aq Sy module Ns 420.Aq Sy module Ns
410.Pa / Ns 421.Pa / Ns
411.Aq Sy module Ns 422.Aq Sy module Ns
412.Pa .kmod 423.Pa .kmod
413.Xc 424.Xc
414is used. 425is used.
415Possible uses of the 426Possible uses of the
416.Ic load 427.Ic load
417command include loading a memory disk image before booting a kernel, 428command include loading a memory disk image before booting a kernel,
418or loading a 429or loading a
419.Tn Xen 430.Tn Xen
420DOM0 kernel before booting the 431DOM0 kernel before booting the
421.Tn Xen 432.Tn Xen
422hypervisor. 433hypervisor.
423See 434See
424.Xr boot.cfg 5 435.Xr boot.cfg 5
425for examples. 436for examples.
426.Pp 437.Pp
427In addition to the 438In addition to the
428.Cm boot 439.Cm boot
429options specified above, the 440options specified above, the
430.Tn Xen 441.Tn Xen
431DOM0 kernel accepts 442DOM0 kernel accepts
432.Po Ar arguments 443.Po Ar arguments
433being separated with spaces 444being separated with spaces
434.Pc : 445.Pc :
435.Bl -tag -width xxx 446.Bl -tag -width xxx
436.It Ic bootdev Ns = Ns Ar dev Po or Ic root Ns = Ns Ar dev Pc 447.It Ic bootdev Ns = Ns Ar dev Po or Ic root Ns = Ns Ar dev Pc
437Override the default boot device. 448Override the default boot device.
438.Ar dev 449.Ar dev
439is of the form 450is of the form
440.Va NAME=partition_label 451.Va NAME=partition_label
441for 452for
442.Xr gpt 8 453.Xr gpt 8
443partitionned disks. It can also be a unit name 454partitionned disks. It can also be a unit name
444.Po Dq wd0 455.Po Dq wd0
445.Pc , 456.Pc ,
446or an interface name 457or an interface name
447.Po Dq bge0 , 458.Po Dq bge0 ,
448.Dq wm0 , 459.Dq wm0 ,
449\&... 460\&...
450.Pc 461.Pc
451for cases where the root file system has to be loaded 462for cases where the root file system has to be loaded
452from network (see the 463from network (see the
453.Sx BUGS 464.Sx BUGS
454section in 465section in
455.Xr x86/pxeboot 8 ) . 466.Xr x86/pxeboot 8 ) .
456.It Ic console Ns = Ns Ar dev 467.It Ic console Ns = Ns Ar dev
457Console used by DOM0 kernel during boot. 468Console used by DOM0 kernel during boot.
458.Ar dev 469.Ar dev
459accepts the same values as the ones given for the 470accepts the same values as the ones given for the
460.Cm consdev 471.Cm consdev
461command. 472command.
462See 473See
463.Sx Console Selection Policy 474.Sx Console Selection Policy
464in 475in
465.Xr x86/boot_console 8 . 476.Xr x86/boot_console 8 .
466.It Xo Ic ip Ns = Ns 477.It Xo Ic ip Ns = Ns
467.Ar my_ip Ns : Ns Ar serv_ip Ns : Ns Ar gw_ip Ns : Ns 478.Ar my_ip Ns : Ns Ar serv_ip Ns : Ns Ar gw_ip Ns : Ns
468.Ar mask Ns : Ns Ar host Ns : Ns Ar iface 479.Ar mask Ns : Ns Ar host Ns : Ns Ar iface
469.Xc 480.Xc
470Specify various parameters for a network boot (IPs are in 481Specify various parameters for a network boot (IPs are in
471dot notation), 482dot notation),
472each one separated by a colon: 483each one separated by a colon:
473.Bl -tag -width xxxxxxx 484.Bl -tag -width xxxxxxx
474.It Va my_ip 485.It Va my_ip
475address of the host 486address of the host
476.It Va serv_ip 487.It Va serv_ip
477address of the NFS server 488address of the NFS server
478.It Va gw_ip 489.It Va gw_ip
479address of the gateway 490address of the gateway
480.It Va mask 491.It Va mask
481network mask 492network mask
482.It Va host 493.It Va host
483address of the host 494address of the host
484.It Va iface 495.It Va iface
485interface 496interface
486.Po e.g., Dq xennet0 497.Po e.g., Dq xennet0
487or 498or
488.Dq eth0 499.Dq eth0
489.Pc 500.Pc
490.El 501.El
491.It Ic nfsroot Ns = Ns Ar address Ns : Ns Ar rootpath 502.It Ic nfsroot Ns = Ns Ar address Ns : Ns Ar rootpath
492Boot the system with root on NFS. 503Boot the system with root on NFS.
493.Ar address 504.Ar address
494is the address of the NFS server, and 505is the address of the NFS server, and
495.Ar rootpath 506.Ar rootpath
496is the remote mount point for the root file system. 507is the remote mount point for the root file system.
497.It Ic pciback.hide Ns = Ns Ar pcidevs 508.It Ic pciback.hide Ns = Ns Ar pcidevs
498Pass a list of PCI IDs for use with the PCI backend driver, 509Pass a list of PCI IDs for use with the PCI backend driver,
499.Xr pciback 4 . 510.Xr pciback 4 .
500.Ar pcidevs 511.Ar pcidevs
501is formed of multiple IDs (in bus:device.function notation), 512is formed of multiple IDs (in bus:device.function notation),
502each ID being surrounded with brackets. 513each ID being surrounded with brackets.
503PCI domain IDs are currently ignored. 514PCI domain IDs are currently ignored.
504See 515See
505.Xr pciback 4 . 516.Xr pciback 4 .
506.El 517.El
507.It Ic ls Op Pa path 518.It Ic ls Op Pa path
508Print a directory listing of 519Print a directory listing of
509.Pa path , 520.Pa path ,
510containing inode number, filename, and file type. 521containing inode number, filename, and file type.
511.Pa path 522.Pa path
512can contain a device specification. 523can contain a device specification.
513.It Ic menu 524.It Ic menu
514Display the boot menu and initiate a countdown, 525Display the boot menu and initiate a countdown,
515similarly to what would have happened if interactive mode 526similarly to what would have happened if interactive mode
516had not been entered. 527had not been entered.
517.It Ic modules Bro Ar on | off | enabled | disabled Brc 528.It Ic modules Bro Ar on | off | enabled | disabled Brc
518The values 529The values
519.Ar enabled , on 530.Ar enabled , on
520will enable module loading for 531will enable module loading for
521.Cm boot 532.Cm boot
522and 533and
523.Cm multiboot , 534.Cm multiboot ,
524whereas 535whereas
525.Ar disabled , off 536.Ar disabled , off
526will turn off the feature. 537will turn off the feature.
527.It Ic multiboot Va kernel Op Ar arguments 538.It Ic multiboot Va kernel Op Ar arguments
528Boot the specified 539Boot the specified
529.Va kernel , 540.Va kernel ,
530using the 541using the
531.Dq multiboot 542.Dq multiboot
532protocol instead of the native 543protocol instead of the native
533.Nx 544.Nx
534boot protocol. 545boot protocol.
535The 546The
536.Va kernel 547.Va kernel
537is specified in the same way as with the 548is specified in the same way as with the
538.Ic boot 549.Ic boot
539command. 550command.
540.Pp 551.Pp
541The multiboot protocol may be used in the following cases: 552The multiboot protocol may be used in the following cases:
542.Bl -tag -width indent 553.Bl -tag -width indent
543.It Nx Ns / Ns Xen No kernels 554.It Nx Ns / Ns Xen No kernels
544The 555The
545.Tn Xen 556.Tn Xen
546DOM0 kernel must be loaded as a module using the 557DOM0 kernel must be loaded as a module using the
547.Ic load 558.Ic load
548command, and the 559command, and the
549.Tn Xen 560.Tn Xen
550hypervisor must be booted using the 561hypervisor must be booted using the
551.Ic multiboot 562.Ic multiboot
552command. 563command.
553Options for the DOM0 kernel (such as 564Options for the DOM0 kernel (such as
554.Dq -s 565.Dq -s
555for single user mode) must be passed as options to the 566for single user mode) must be passed as options to the
556.Ic load 567.Ic load
557command. 568command.
558Options for the hypervisor (such as 569Options for the hypervisor (such as
559.Dq dom0_mem=256M 570.Dq dom0_mem=256M
560to reserve 256 MB of memory for DOM0) 571to reserve 256 MB of memory for DOM0)
561must be passed as options to the 572must be passed as options to the
562.Ic multiboot 573.Ic multiboot
563command. 574command.
564See 575See
565.Xr boot.cfg 5 576.Xr boot.cfg 5
566for examples on how to boot 577for examples on how to boot
567.Nx Ns / Ns Xen. 578.Nx Ns / Ns Xen.
568.It Nx No multiboot kernels 579.It Nx No multiboot kernels
569A 580A
570.Nx 581.Nx
571kernel that was built with 582kernel that was built with
572.Cd options MULTIBOOT 583.Cd options MULTIBOOT
573(see 584(see
574.Xr x86/multiboot 8 ) 585.Xr x86/multiboot 8 )
575may be booted with either the 586may be booted with either the
576.Ic boot 587.Ic boot
577or 588or
578.Ic multiboot 589.Ic multiboot
579command, passing the same 590command, passing the same
580.Ar arguments 591.Ar arguments
581in either case. 592in either case.
582.It Non- Ns Nx No kernels 593.It Non- Ns Nx No kernels
583A kernel for a 594A kernel for a
584.No non- Ns Nx 595.No non- Ns Nx
585operating system that expects to be booted using the 596operating system that expects to be booted using the
586multiboot protocol (such as by the GNU 597multiboot protocol (such as by the GNU
587.Dq GRUB 598.Dq GRUB
588boot loader) 599boot loader)
589may be booted using the 600may be booted using the
590.Ic multiboot 601.Ic multiboot
591command. 602command.
592See the foreign operating system's documentation for the available 603See the foreign operating system's documentation for the available
593.Ar arguments . 604.Ar arguments .
594.El 605.El
595.It Ic quit 606.It Ic quit
596Reboot the system. 607Reboot the system.
597.It Ic rndseed Ar file 608.It Ic rndseed Ar file
598Load the specified 609Load the specified
599.Ar file 610.Ar file
600and request the kernel to use it as a seed for the 611and request the kernel to use it as a seed for the
601.Xr rnd 4 612.Xr rnd 4
602random number generator. 613random number generator.
603The 614The
604.Ar file 615.Ar file
605should be in the private format used by 616should be in the private format used by
606.Xr rndctl 8 , 617.Xr rndctl 8 ,
607and should have been saved by 618and should have been saved by
608.Ql "rndctl -S" 619.Ql "rndctl -S"
609shortly before the previous shutdown. 620shortly before the previous shutdown.
610See the 621See the
611.Va random_seed 622.Va random_seed
612and 623and
613.Va random_file 624.Va random_file
614variables in 625variables in
615.Xr rc.conf 5 , 626.Xr rc.conf 5 ,
616and the 627and the
617.Pa /etc/rc.d/random_seed 628.Pa /etc/rc.d/random_seed
618script, for a way to manage the seed file. 629script, for a way to manage the seed file.
619Using the same seed file on more then one host, 630Using the same seed file on more then one host,
620or for more than one boot on the same host, 631or for more than one boot on the same host,
621will reduce the quality of random numbers 632will reduce the quality of random numbers
622and may impact system security. 633and may impact system security.
623.It Ic userconf Va command 634.It Ic userconf Va command
624Pass command 635Pass command
625.Va command 636.Va command
626to 637to
627.Xr userconf 4 638.Xr userconf 4
628at boot time. 639at boot time.
629These commands are processed before the interactive 640These commands are processed before the interactive
630.Xr userconf 4 641.Xr userconf 4
631shell is executed, if requested. 642shell is executed, if requested.
632.It Ic splash Ar file 643.It Ic splash Ar file
633Load a graphical image from the specified 644Load a graphical image from the specified
634.Ar file 645.Ar file
635and request the kernel to use it as a splash screen. 646and request the kernel to use it as a splash screen.
636The 647The
637.Ar file 648.Ar file
638should contain an image in one of these formats: 649should contain an image in one of these formats:
639JPEG (baseline only, not progressive), 650JPEG (baseline only, not progressive),
640PNG (8-bit only), 651PNG (8-bit only),
641TGA, 652TGA,
642BMP (non-1bpp, non-RLE), 653BMP (non-1bpp, non-RLE),
643GIF, 654GIF,
644PSD (composited view only), 655PSD (composited view only),
645or 656or
646PIC. 657PIC.
647.It Ic vesa Bro Va modenum | Ar on | off | enabled | disabled | list Brc 658.It Ic vesa Bro Va modenum | Ar on | off | enabled | disabled | list Brc
648Initialise the video card to the specified resolution and bit depth. 659Initialise the video card to the specified resolution and bit depth.
649The 660The
650.Va modenum 661.Va modenum
651should be in the form of 662should be in the form of
652.Ar 0x100 , 800x600 , 800x600x32 . 663.Ar 0x100 , 800x600 , 800x600x32 .
653The values 664The values
654.Ar enabled , on 665.Ar enabled , on
655put the display into the default mode, and 666put the display into the default mode, and
656.Ar disabled , off 667.Ar disabled , off
657returns the display into standard vga mode. 668returns the display into standard vga mode.
658The value 669The value
659.Ar list 670.Ar list
660lists all supported modes. 671lists all supported modes.
661.El 672.El
662.Pp 673.Pp
663In an emergency, the bootstrap methods described in the 674In an emergency, the bootstrap methods described in the
664.Nx 675.Nx
665installation notes for the x86 architectures 676installation notes for the x86 architectures
666can be used to boot from floppy or other media, 677can be used to boot from floppy or other media,
667or over the network. 678or over the network.
668.Ss Locating the root file system 679.Ss Locating the root file system
669The kernel uses information from the bootloader to locate the 680The kernel uses information from the bootloader to locate the
670file system to mount as root. 681file system to mount as root.
671There are three methods: 682There are three methods:
672.Bl -tag -width 04n -offset 04n 683.Bl -tag -width 04n -offset 04n
673.It Ic BTINFO_ROOTDEVICE Va from 684.It Ic BTINFO_ROOTDEVICE Va from
674.Xr boot.cfg 5 685.Xr boot.cfg 5
675or multiboot. 686or multiboot.
676The bootloader passes the root device name as driver, unit, and 687The bootloader passes the root device name as driver, unit, and
677partition (like sd0a). 688partition (like sd0a).
678This will be automatically substituted by a 689This will be automatically substituted by a
679.Xr dk 4 690.Xr dk 4
680wedge if one is discovered. 691wedge if one is discovered.
681.Pp 692.Pp
682The bootloader passes a wedge name as "wedge:" followed by the name. 693The bootloader passes a wedge name as "wedge:" followed by the name.
683The kernel will search for a 694The kernel will search for a
684.Xr dk 4 695.Xr dk 4
685device with that name. 696device with that name.
686.It Ic BTINFO_BOOTWEDGE Va determined by bootblock 697.It Ic BTINFO_BOOTWEDGE Va determined by bootblock
687The bootloader passes start offset and length of a hard disk partition 698The bootloader passes start offset and length of a hard disk partition
688and a offset, size and hash of a "boot area". 699and a offset, size and hash of a "boot area".
689Then kernel searches 700Then kernel searches
690all disks and wedges for a block sequence at that offset with a 701all disks and wedges for a block sequence at that offset with a
691matching hash. 702matching hash.
692If one is found, the kernel will look for a wedge 703If one is found, the kernel will look for a wedge
693on that device at the same offset. 704on that device at the same offset.
694.Pp 705.Pp
695An additional partition number is provided if the bootloader also 706An additional partition number is provided if the bootloader also
696passed a BTINFO_BOOTDISK record. 707passed a BTINFO_BOOTDISK record.
697This (or partition 'a') will be used 708This (or partition 'a') will be used
698by the kernel as a fallback if there is no matching wedge. 709by the kernel as a fallback if there is no matching wedge.
699.It Ic BTINFO_BOOTDISK Va determined by bootblock 710.It Ic BTINFO_BOOTDISK Va determined by bootblock
700This uses the device number passed by the BIOS that 711This uses the device number passed by the BIOS that
701distinguishes between floppy, hard drive and CD-ROM boot. 712distinguishes between floppy, hard drive and CD-ROM boot.
702.Bl -tag -width xxx 713.Bl -tag -width xxx
703.It Ic Floppy 714.It Ic Floppy
704The kernel searches for the 715The kernel searches for the
705.Xr fd 4 716.Xr fd 4
706device with the correct unit, the partition number is used 717device with the correct unit, the partition number is used
707to select a specific disk format. 718to select a specific disk format.
708See 719See
709.Xr fd 4 720.Xr fd 4
710for details. 721for details.
711.It Ic Hard drive 722.It Ic Hard drive
712The bootloader passed a partition number and disklabel 723The bootloader passed a partition number and disklabel
713data (offset, type, checksum, packname). 724data (offset, type, checksum, packname).
714The kernel searches 725The kernel searches
715all disks for a matching disklabel. 726all disks for a matching disklabel.
716If one is found, the 727If one is found, the
717kernel will use that device and partition number. 728kernel will use that device and partition number.
718.It Ic CDROM 729.It Ic CDROM
719The BIOS does not distinguish between multiple CD devices. 730The BIOS does not distinguish between multiple CD devices.
720The kernel searches for the first 731The kernel searches for the first
721.Xr cd 4 732.Xr cd 4
722device. 733device.
723So you can only boot from unit 0. 734So you can only boot from unit 0.
724.El 735.El
725.El 736.El
726.Sh FILES 737.Sh FILES
727.Bl -tag -width /usr/mdec/bootxx_fstype -compact 738.Bl -tag -width /usr/mdec/bootxx_fstype -compact
728.It Pa /boot 739.It Pa /boot
729boot program code loaded by the primary bootstrap 740boot program code loaded by the primary bootstrap
730.It Pa /boot.cfg 741.It Pa /boot.cfg
731optional configuration file 742optional configuration file
732.It Pa /netbsd 743.It Pa /netbsd
733system code 744system code
734.It Pa /netbsd.gz 745.It Pa /netbsd.gz
735gzip-compressed system code 746gzip-compressed system code
736.It Pa /usr/mdec/boot 747.It Pa /usr/mdec/boot
737master copy of the boot program (copy to /boot) 748master copy of the boot program (copy to /boot)
738.It Pa /usr/mdec/bootxx_fstype 749.It Pa /usr/mdec/bootxx_fstype
739primary bootstrap for file system type fstype, copied to the start of 750primary bootstrap for file system type fstype, copied to the start of
740the 751the
741.Nx 752.Nx
742partition by 753partition by
743.Xr installboot 8 . 754.Xr installboot 8 .
744.It Pa /usr/mdec/bootia32.efi 755.It Pa /usr/mdec/bootia32.efi
745.It Pa /usr/mdec/bootx64.efi 756.It Pa /usr/mdec/bootx64.efi
746.Tn UEFI 757.Tn UEFI
747bootstraps for 758bootstraps for
748.Nx Ns /i386 759.Nx Ns /i386
749and 760and
750.Nx Ns /amd64 , 761.Nx Ns /amd64 ,
751which should be copied to the 762which should be copied to the
752.Pa /efi/boot 763.Pa /efi/boot
753directory in a 764directory in a
754.Tn FAT 765.Tn FAT
755formatted partition of type 766formatted partition of type
756.Tn EFI 767.Tn EFI
757(Either 768(Either
758.Xr mbr 8 769.Xr mbr 8
759and 770and
760.Xr gpt 8 , 771.Xr gpt 8 ,
761see the 772see the
762.Sx BUGS 773.Sx BUGS
763section). 774section).
764.Nx 775.Nx
765.Tn UEFI 776.Tn UEFI
766bootstrap reads its configuration from the 777bootstrap reads its configuration from the
767.Pa /efi/netBSD/boot.cfg 778.Pa /efi/netBSD/boot.cfg
768file in the 779file in the
769.Tn EFI 780.Tn EFI
770partition. 781partition.
771.El 782.El
772.Sh SEE ALSO 783.Sh SEE ALSO
773.Xr ddb 4 , 784.Xr ddb 4 ,
774.Xr fd 4 , 785.Xr fd 4 ,
775.Xr pciback 4 , 786.Xr pciback 4 ,
776.Xr userconf 4 , 787.Xr userconf 4 ,
777.Xr boot.cfg 5 , 788.Xr boot.cfg 5 ,
778.Xr halt 8 , 789.Xr halt 8 ,
779.Xr installboot 8 , 790.Xr installboot 8 ,
780.Xr reboot 8 , 791.Xr reboot 8 ,
781.Xr rescue 8 , 792.Xr rescue 8 ,
782.Xr shutdown 8 , 793.Xr shutdown 8 ,
783.Xr x86/boot_console 8 , 794.Xr x86/boot_console 8 ,
784.Xr x86/dosboot 8 , 795.Xr x86/dosboot 8 ,
785.Xr x86/mbr 8 , 796.Xr x86/mbr 8 ,
786.Xr x86/multiboot 8 , 797.Xr x86/multiboot 8 ,
787.Xr x86/pxeboot 8 , 798.Xr x86/pxeboot 8 ,
788.Xr boothowto 9 799.Xr boothowto 9
789.Sh BUGS 800.Sh BUGS
790The kernel file name must be specified before, not after, the boot options. 801The kernel file name must be specified before, not after, the boot options.
791Any 802Any
792.Ar filename 803.Ar filename
793specified after the boot options, e.g.: 804specified after the boot options, e.g.:
794.Pp 805.Pp
795.Bd -unfilled -offset indent -compact 806.Bd -unfilled -offset indent -compact
796.Cm boot -d netbsd.test 807.Cm boot -d netbsd.test
797.Ed 808.Ed
798.Pp 809.Pp
799is ignored, and the default kernel is booted. 810is ignored, and the default kernel is booted.
800.Pp 811.Pp
801Hard disks are always accessed by 812Hard disks are always accessed by
802.Tn BIOS 813.Tn BIOS
803functions. 814functions.
804Unit numbers are 815Unit numbers are
805.Tn BIOS 816.Tn BIOS
806device numbers which might differ from numbering in the 817device numbers which might differ from numbering in the
807.Nx 818.Nx
808kernel or physical parameters 819kernel or physical parameters
809.Po 820.Po
810e.g., 821e.g.,
811.Tn SCSI 822.Tn SCSI
812slave numbers 823slave numbers
813.Pc . 824.Pc .
814There isn't any distinction between 825There isn't any distinction between
815.Dq sd 826.Dq sd
816and 827and
817.Dq wd 828.Dq wd
818devices at the bootloader level. 829devices at the bootloader level.
819This is less a bug of the bootloader code than 830This is less a bug of the bootloader code than
820a shortcoming of the PC architecture. 831a shortcoming of the PC architecture.
821The default disk device's name printed in the starting message 832The default disk device's name printed in the starting message
822is derived from the 833is derived from the
823.Dq type 834.Dq type
824field of the 835field of the
825.Nx 836.Nx
826disklabel (if it is a hard disk). 837disklabel (if it is a hard disk).
827.Pp 838.Pp
828.Tn UEFI 839.Tn UEFI
829implementation are supposed to support either 840implementation are supposed to support either
830.Xr mbr 8 841.Xr mbr 8
831or 842or
832.Xr gpt 8 843.Xr gpt 8
833partitionning, but some do not handle the later. 844partitionning, but some do not handle the later.
834.Tn UEFI 845.Tn UEFI
835Booting 846Booting
836from a 847from a
837.Xr gpt 8 848.Xr gpt 8
838partitioned disk is still possible in this case, by adding 849partitioned disk is still possible in this case, by adding
839an overlapping 850an overlapping
840.Tn EFI 851.Tn EFI
841partition in the protective 852partition in the protective
842.Xr mbr 8 853.Xr mbr 8
843block. 854block.
844This can be achieved using the following commands 855This can be achieved using the following commands
845(you must adapt the hard disk and 856(you must adapt the hard disk and
846.Tn EFI 857.Tn EFI
847partition start end size to fit your setup): 858partition start end size to fit your setup):
848.Dl Ic dd if=/dev/rwd0d bs=512 count=1 of=mbr 859.Dl Ic dd if=/dev/rwd0d bs=512 count=1 of=mbr
849.Dl Ic fdisk -FIfaui1s 4/34/32768 -c /usr/mdec/mbr mbr 860.Dl Ic fdisk -FIfaui1s 4/34/32768 -c /usr/mdec/mbr mbr
850.Dl Ic dd if=mbr bs=512 count=1 of=/dev/rwd0d conv=notrunc 861.Dl Ic dd if=mbr bs=512 count=1 of=/dev/rwd0d conv=notrunc
851The resulting 862The resulting
852.Xr mbr 8 863.Xr mbr 8
853partition table will look like this: 864partition table will look like this:
854.Bd -unfilled -offset indent 865.Bd -unfilled -offset indent
8550: GPT Protective MBR (sysid 238) 8660: GPT Protective MBR (sysid 238)
856 start 1, size 2097151 (1024 MB, Cyls 0-130/138/8) 867 start 1, size 2097151 (1024 MB, Cyls 0-130/138/8)
857 PBR is not bootable: Bad magic number (0x0000) 868 PBR is not bootable: Bad magic number (0x0000)
8581: Primary DOS with 16 bit FAT <32M (sysid 4) 8691: Primary DOS with 16 bit FAT <32M (sysid 4)
859 start 34, size 32768 (16 MB, Cyls 0/0/35-2/10/42), Active 870 start 34, size 32768 (16 MB, Cyls 0/0/35-2/10/42), Active
8602: <UNUSED> 8712: <UNUSED>
8613: <UNUSED> 8723: <UNUSED>
862.Ed 873.Ed

cvs diff -r1.66.10.1 -r1.66.10.2 src/sys/arch/i386/stand/boot/boot2.c (switch to unified diff)

--- src/sys/arch/i386/stand/boot/boot2.c 2019/09/17 18:26:53 1.66.10.1
+++ src/sys/arch/i386/stand/boot/boot2.c 2020/07/15 15:54:50 1.66.10.2
@@ -1,618 +1,636 @@ @@ -1,618 +1,636 @@
1/* $NetBSD: boot2.c,v 1.66.10.1 2019/09/17 18:26:53 martin Exp $ */ 1/* $NetBSD: boot2.c,v 1.66.10.2 2020/07/15 15:54:50 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * Copyright (c) 2003 30 * Copyright (c) 2003
31 * David Laight. All rights reserved 31 * David Laight. All rights reserved
32 * Copyright (c) 1996, 1997, 1999 32 * Copyright (c) 1996, 1997, 1999
33 * Matthias Drochner. All rights reserved. 33 * Matthias Drochner. All rights reserved.
34 * Copyright (c) 1996, 1997 34 * Copyright (c) 1996, 1997
35 * Perry E. Metzger. All rights reserved. 35 * Perry E. Metzger. All rights reserved.
36 * Copyright (c) 1997 36 * Copyright (c) 1997
37 * Jason R. Thorpe. All rights reserved 37 * Jason R. Thorpe. All rights reserved
38 * 38 *
39 * Redistribution and use in source and binary forms, with or without 39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions 40 * modification, are permitted provided that the following conditions
41 * are met: 41 * are met:
42 * 1. Redistributions of source code must retain the above copyright 42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer. 43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright 44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the 45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution. 46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software 47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgements: 48 * must display the following acknowledgements:
49 * This product includes software developed for the NetBSD Project 49 * This product includes software developed for the NetBSD Project
50 * by Matthias Drochner. 50 * by Matthias Drochner.
51 * This product includes software developed for the NetBSD Project 51 * This product includes software developed for the NetBSD Project
52 * by Perry E. Metzger. 52 * by Perry E. Metzger.
53 * 4. The names of the authors may not be used to endorse or promote products 53 * 4. The names of the authors may not be used to endorse or promote products
54 * derived from this software without specific prior written permission. 54 * derived from this software without specific prior written permission.
55 * 55 *
56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 57 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
58 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 58 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
59 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 59 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 60 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
62 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 62 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
63 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 63 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 64 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 65 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 */ 66 */
67 67
68/* Based on stand/biosboot/main.c */ 68/* Based on stand/biosboot/main.c */
69 69
70#include <sys/types.h> 70#include <sys/types.h>
71#include <sys/reboot.h> 71#include <sys/reboot.h>
72#include <sys/bootblock.h> 72#include <sys/bootblock.h>
73 73
74#include <lib/libsa/stand.h> 74#include <lib/libsa/stand.h>
75#include <lib/libsa/bootcfg.h> 75#include <lib/libsa/bootcfg.h>
76#include <lib/libsa/ufs.h> 76#include <lib/libsa/ufs.h>
77#include <lib/libkern/libkern.h> 77#include <lib/libkern/libkern.h>
78 78
79#include <libi386.h> 79#include <libi386.h>
80#include <bootmod.h> 80#include <bootmod.h>
81#include <bootmenu.h> 81#include <bootmenu.h>
82#include <biosdisk.h> 82#include <biosdisk.h>
83#include <vbe.h> 83#include <vbe.h>
84#include "devopen.h" 84#include "devopen.h"
85 85
86#ifdef SUPPORT_PS2 86#ifdef SUPPORT_PS2
87#include <biosmca.h> 87#include <biosmca.h>
88#endif 88#endif
89 89
90extern struct x86_boot_params boot_params; 90extern struct x86_boot_params boot_params;
91 91
92extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[]; 92extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
93 93
94int errno; 94int errno;
95 95
96int boot_biosdev; 96int boot_biosdev;
97daddr_t boot_biossector; 97daddr_t boot_biossector;
98 98
99static const char * const names[][2] = { 99static const char * const names[][2] = {
100 { "netbsd", "netbsd.gz" }, 100 { "netbsd", "netbsd.gz" },
101 { "onetbsd", "onetbsd.gz" }, 101 { "onetbsd", "onetbsd.gz" },
102 { "netbsd.old", "netbsd.old.gz" }, 102 { "netbsd.old", "netbsd.old.gz" },
103}; 103};
104 104
105#define NUMNAMES (sizeof(names)/sizeof(names[0])) 105#define NUMNAMES (sizeof(names)/sizeof(names[0]))
106#define DEFFILENAME names[0][0] 106#define DEFFILENAME names[0][0]
107 107
108#ifndef NO_GPT 108#ifndef NO_GPT
109#define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */ 109#define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */
110#else 110#else
111#define MAXDEVNAME 16 111#define MAXDEVNAME 16
112#endif 112#endif
113 113
114static char *default_devname; 114static char *default_devname;
115static int default_unit, default_partition; 115static int default_unit, default_partition;
116static const char *default_filename; 116static const char *default_filename;
117static const char *default_part_name; 117static const char *default_part_name;
118 118
119char *sprint_bootsel(const char *); 119char *sprint_bootsel(const char *);
120static void bootit(const char *, int); 120static void bootit(const char *, int);
121void print_banner(void); 121void print_banner(void);
122void boot2(int, uint64_t); 122void boot2(int, uint64_t);
123 123
124void command_help(char *); 124void command_help(char *);
125#if LIBSA_ENABLE_LS_OP 125#if LIBSA_ENABLE_LS_OP
126void command_ls(char *); 126void command_ls(char *);
127#endif 127#endif
128void command_quit(char *); 128void command_quit(char *);
129void command_boot(char *); 129void command_boot(char *);
130void command_dev(char *); 130void command_dev(char *);
131void command_consdev(char *); 131void command_consdev(char *);
132#ifndef SMALL 132#ifndef SMALL
133void command_menu(char *); 133void command_menu(char *);
134#endif 134#endif
135void command_modules(char *); 135void command_modules(char *);
136void command_multiboot(char *); 136void command_multiboot(char *);
137 137
138const struct bootblk_command commands[] = { 138const struct bootblk_command commands[] = {
139 { "help", command_help }, 139 { "help", command_help },
140 { "?", command_help }, 140 { "?", command_help },
141#if LIBSA_ENABLE_LS_OP 141#if LIBSA_ENABLE_LS_OP
142 { "ls", command_ls }, 142 { "ls", command_ls },
143#endif 143#endif
144 { "quit", command_quit }, 144 { "quit", command_quit },
145 { "boot", command_boot }, 145 { "boot", command_boot },
146 { "dev", command_dev }, 146 { "dev", command_dev },
147 { "consdev", command_consdev }, 147 { "consdev", command_consdev },
148#ifndef SMALL 148#ifndef SMALL
149 { "menu", command_menu }, 149 { "menu", command_menu },
150#endif 150#endif
151 { "modules", command_modules }, 151 { "modules", command_modules },
152 { "load", module_add }, 152 { "load", module_add },
153 { "multiboot", command_multiboot }, 153 { "multiboot", command_multiboot },
154 { "vesa", command_vesa }, 154 { "vesa", command_vesa },
155 { "splash", splash_add }, 155 { "splash", splash_add },
156 { "rndseed", rnd_add }, 156 { "rndseed", rnd_add },
157 { "fs", fs_add }, 157 { "fs", fs_add },
158 { "userconf", userconf_add }, 158 { "userconf", userconf_add },
159 { NULL, NULL }, 159 { NULL, NULL },
160}; 160};
161 161
162int 162int
163parsebootfile(const char *fname, char **fsname, char **devname, 163parsebootfile(const char *fname, char **fsname, char **devname,
164 int *unit, int *partition, const char **file) 164 int *unit, int *partition, const char **file)
165{ 165{
166 const char *col; 166 const char *col;
167 static char savedevname[MAXDEVNAME+1]; 167 static char savedevname[MAXDEVNAME+1];
168 168
169 *fsname = "ufs"; 169 *fsname = "ufs";
170 if (default_part_name == NULL) { 170 if (default_part_name == NULL) {
171 *devname = default_devname; 171 *devname = default_devname;
172 } else { 172 } else {
173 snprintf(savedevname, sizeof(savedevname), 173 snprintf(savedevname, sizeof(savedevname),
174 "NAME=%s", default_part_name); 174 "NAME=%s", default_part_name);
175 *devname = savedevname; 175 *devname = savedevname;
176 } 176 }
177 *unit = default_unit; 177 *unit = default_unit;
178 *partition = default_partition; 178 *partition = default_partition;
179 *file = default_filename; 179 *file = default_filename;
180 180
181 if (fname == NULL) 181 if (fname == NULL)
182 return 0; 182 return 0;
183 183
184 if ((col = strchr(fname, ':')) != NULL) { /* device given */ 184 if ((col = strchr(fname, ':')) != NULL) { /* device given */
185 int devlen; 185 int devlen;
186 int u = 0, p = 0; 186 int u = 0, p = 0;
187 int i = 0; 187 int i = 0;
188 188
189 devlen = col - fname; 189 devlen = col - fname;
190 if (devlen > MAXDEVNAME) 190 if (devlen > MAXDEVNAME)
191 return EINVAL; 191 return EINVAL;
192 192
193#ifndef NO_GPT 193#ifndef NO_GPT
194 if (strstr(fname, "NAME=") == fname) { 194 if (strstr(fname, "NAME=") == fname) {
195 strlcpy(savedevname, fname, devlen + 1); 195 strlcpy(savedevname, fname, devlen + 1);
196 *devname = savedevname; 196 *devname = savedevname;
197 *unit = -1; 197 *unit = -1;
198 *partition = -1; 198 *partition = -1;
199 fname = col + 1; 199 fname = col + 1;
200 goto out; 200 goto out;
201 } 201 }
202#endif 202#endif
203 203
204#define isvalidname(c) ((c) >= 'a' && (c) <= 'z') 204#define isvalidname(c) ((c) >= 'a' && (c) <= 'z')
205 if (!isvalidname(fname[i])) 205 if (!isvalidname(fname[i]))
206 return EINVAL; 206 return EINVAL;
207 do { 207 do {
208 savedevname[i] = fname[i]; 208 savedevname[i] = fname[i];
209 i++; 209 i++;
210 } while (isvalidname(fname[i])); 210 } while (isvalidname(fname[i]));
211 savedevname[i] = '\0'; 211 savedevname[i] = '\0';
212 212
213#define isnum(c) ((c) >= '0' && (c) <= '9') 213#define isnum(c) ((c) >= '0' && (c) <= '9')
214 if (i < devlen) { 214 if (i < devlen) {
215 if (!isnum(fname[i])) 215 if (!isnum(fname[i]))
216 return EUNIT; 216 return EUNIT;
217 do { 217 do {
218 u *= 10; 218 u *= 10;
219 u += fname[i++] - '0'; 219 u += fname[i++] - '0';
220 } while (isnum(fname[i])); 220 } while (isnum(fname[i]));
221 } 221 }
222 222
223#define isvalidpart(c) ((c) >= 'a' && (c) <= 'z') 223#define isvalidpart(c) ((c) >= 'a' && (c) <= 'z')
224 if (i < devlen) { 224 if (i < devlen) {
225 if (!isvalidpart(fname[i])) 225 if (!isvalidpart(fname[i]))
226 return EPART; 226 return EPART;
227 p = fname[i++] - 'a'; 227 p = fname[i++] - 'a';
228 } 228 }
229 229
230 if (i != devlen) 230 if (i != devlen)
231 return ENXIO; 231 return ENXIO;
232 232
233 *devname = savedevname; 233 *devname = savedevname;
234 *unit = u; 234 *unit = u;
235 *partition = p; 235 *partition = p;
236 fname = col + 1; 236 fname = col + 1;
237 } 237 }
238 238
239out: 239out:
240 if (*fname) 240 if (*fname)
241 *file = fname; 241 *file = fname;
242 242
243 return 0; 243 return 0;
244} 244}
245 245
246char * 246char *
247sprint_bootsel(const char *filename) 247sprint_bootsel(const char *filename)
248{ 248{
249 char *fsname, *devname; 249 char *fsname, *devname;
250 int unit, partition; 250 int unit, partition;
251 const char *file; 251 const char *file;
252 static char buf[80]; 252 static char buf[80];
253 253
254 if (parsebootfile(filename, &fsname, &devname, &unit, 254 if (parsebootfile(filename, &fsname, &devname, &unit,
255 &partition, &file) == 0) { 255 &partition, &file) == 0) {
256 if (strstr(devname, "NAME=") == devname) 256 if (strstr(devname, "NAME=") == devname)
257 snprintf(buf, sizeof(buf), "%s:%s", devname, file); 257 snprintf(buf, sizeof(buf), "%s:%s", devname, file);
258 else 258 else
259 snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit, 259 snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit,
260 'a' + partition, file); 260 'a' + partition, file);
261 return buf; 261 return buf;
262 } 262 }
263 return "(invalid)"; 263 return "(invalid)";
264} 264}
265 265
266static void 266static void
267clearit(void) 267clearit(void)
268{ 268{
269 269
270 if (bootcfg_info.clear) 270 if (bootcfg_info.clear)
271 clear_pc_screen(); 271 clear_pc_screen();
272} 272}
273 273
274static void 274static void
275bootit(const char *filename, int howto) 275bootit(const char *filename, int howto)
276{ 276{
277 if (howto & AB_VERBOSE) 277 if (howto & AB_VERBOSE)
278 printf("booting %s (howto 0x%x)\n", sprint_bootsel(filename), 278 printf("booting %s (howto 0x%x)\n", sprint_bootsel(filename),
279 howto); 279 howto);
280 280
281 if (exec_netbsd(filename, 0, howto, boot_biosdev < 0x80, clearit) < 0) 281 if (exec_netbsd(filename, 0, howto, boot_biosdev < 0x80, clearit) < 0)
282 printf("boot: %s: %s\n", sprint_bootsel(filename), 282 printf("boot: %s: %s\n", sprint_bootsel(filename),
283 strerror(errno)); 283 strerror(errno));
284 else 284 else
285 printf("boot returned\n"); 285 printf("boot returned\n");
286} 286}
287 287
288void 288void
289print_banner(void) 289print_banner(void)
290{ 290{
291 291
292 clearit(); 292 clearit();
293#ifndef SMALL 293#ifndef SMALL
294 int n; 294 int n;
295 if (bootcfg_info.banner[0]) { 295 if (bootcfg_info.banner[0]) {
296 for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n]; 296 for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n];
297 n++)  297 n++)
298 printf("%s\n", bootcfg_info.banner[n]); 298 printf("%s\n", bootcfg_info.banner[n]);
299 } else { 299 } else {
300#endif /* !SMALL */ 300#endif /* !SMALL */
301 printf("\n" 301 printf("\n"
302 ">> %s, Revision %s (from NetBSD %s)\n" 302 ">> %s, Revision %s (from NetBSD %s)\n"
303 ">> Memory: %d/%d k\n", 303 ">> Memory: %d/%d k\n",
304 bootprog_name, bootprog_rev, bootprog_kernrev, 304 bootprog_name, bootprog_rev, bootprog_kernrev,
305 getbasemem(), getextmem()); 305 getbasemem(), getextmem());
306 306
307#ifndef SMALL 307#ifndef SMALL
308 } 308 }
309#endif /* !SMALL */ 309#endif /* !SMALL */
310} 310}
311 311
312/* 312/*
313 * Called from the initial entry point boot_start in biosboot.S 313 * Called from the initial entry point boot_start in biosboot.S
314 * 314 *
315 * biosdev: BIOS drive number the system booted from 315 * biosdev: BIOS drive number the system booted from
316 * biossector: Sector number of the NetBSD partition 316 * biossector: Sector number of the NetBSD partition
317 */ 317 */
318void 318void
319boot2(int biosdev, uint64_t biossector) 319boot2(int biosdev, uint64_t biossector)
320{ 320{
321 extern char twiddle_toggle; 321 extern char twiddle_toggle;
322 int currname; 322 int currname;
323 char c; 323 char c;
324 324
325 twiddle_toggle = 1; /* no twiddling until we're ready */ 325 twiddle_toggle = 1; /* no twiddling until we're ready */
326 326
327 initio(boot_params.bp_consdev); 327 initio(boot_params.bp_consdev);
328 328
329#ifdef SUPPORT_PS2 329#ifdef SUPPORT_PS2
330 biosmca(); 330 biosmca();
331#endif 331#endif
332 gateA20(); 332 gateA20();
333 333
334 boot_modules_enabled = !(boot_params.bp_flags 334 boot_modules_enabled = !(boot_params.bp_flags
335 & X86_BP_FLAGS_NOMODULES); 335 & X86_BP_FLAGS_NOMODULES);
336 if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO) 336 if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO)
337 biosvideomode(); 337 biosvideomode();
338 338
339 vbe_init(); 339 vbe_init();
340 340
341 /* need to remember these */ 341 /* need to remember these */
342 boot_biosdev = biosdev; 342 boot_biosdev = biosdev;
343 boot_biossector = biossector; 343 boot_biossector = biossector;
344 344
345 /* try to set default device to what BIOS tells us */ 345 /* try to set default device to what BIOS tells us */
346 bios2dev(biosdev, biossector, &default_devname, &default_unit, 346 bios2dev(biosdev, biossector, &default_devname, &default_unit,
347 &default_partition, &default_part_name); 347 &default_partition, &default_part_name);
348 348
349 /* if the user types "boot" without filename */ 349 /* if the user types "boot" without filename */
350 default_filename = DEFFILENAME; 350 default_filename = DEFFILENAME;
351 351
352#ifndef SMALL 352#ifndef SMALL
353 if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) { 353 if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) {
354 parsebootconf(BOOTCFG_FILENAME); 354 parsebootconf(BOOTCFG_FILENAME);
355 } else { 355 } else {
356 bootcfg_info.timeout = boot_params.bp_timeout; 356 bootcfg_info.timeout = boot_params.bp_timeout;
357 } 357 }
358  358
359 359
360 /* 360 /*
361 * If console set in boot.cfg, switch to it. 361 * If console set in boot.cfg, switch to it.
362 * This will print the banner, so we don't need to explicitly do it 362 * This will print the banner, so we don't need to explicitly do it
363 */ 363 */
364 if (bootcfg_info.consdev) 364 if (bootcfg_info.consdev)
365 command_consdev(bootcfg_info.consdev); 365 command_consdev(bootcfg_info.consdev);
366 else  366 else
367 print_banner(); 367 print_banner();
368 368
369 /* Display the menu, if applicable */ 369 /* Display the menu, if applicable */
370 twiddle_toggle = 0; 370 twiddle_toggle = 0;
371 if (bootcfg_info.nummenu > 0) { 371 if (bootcfg_info.nummenu > 0) {
372 /* Does not return */ 372 /* Does not return */
373 doboottypemenu(); 373 doboottypemenu();
374 } 374 }
375 375
376#else 376#else
377 twiddle_toggle = 0; 377 twiddle_toggle = 0;
378 print_banner(); 378 print_banner();
379#endif 379#endif
380 380
381 printf("Press return to boot now, any other key for boot menu\n"); 381 printf("Press return to boot now, any other key for boot menu\n");
382 for (currname = 0; currname < NUMNAMES; currname++) { 382 for (currname = 0; currname < NUMNAMES; currname++) {
383 printf("booting %s - starting in ", 383 printf("booting %s - starting in ",
384 sprint_bootsel(names[currname][0])); 384 sprint_bootsel(names[currname][0]));
385 385
386#ifdef SMALL 386#ifdef SMALL
387 c = awaitkey(boot_params.bp_timeout, 1); 387 c = awaitkey(boot_params.bp_timeout, 1);
388#else 388#else
389 c = awaitkey((bootcfg_info.timeout < 0) ? 0 389 c = awaitkey((bootcfg_info.timeout < 0) ? 0
390 : bootcfg_info.timeout, 1); 390 : bootcfg_info.timeout, 1);
391#endif 391#endif
392 if ((c != '\r') && (c != '\n') && (c != '\0')) { 392 if ((c != '\r') && (c != '\n') && (c != '\0')) {
393 if ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0) { 393 if ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0) {
394 /* do NOT ask for password */ 394 /* do NOT ask for password */
395 bootmenu(); /* does not return */ 395 bootmenu(); /* does not return */
396 } else { 396 } else {
397 /* DO ask for password */ 397 /* DO ask for password */
398 if (check_password((char *)boot_params.bp_password)) { 398 if (check_password((char *)boot_params.bp_password)) {
399 /* password ok */ 399 /* password ok */
400 printf("type \"?\" or \"help\" for help.\n"); 400 printf("type \"?\" or \"help\" for help.\n");
401 bootmenu(); /* does not return */ 401 bootmenu(); /* does not return */
402 } else { 402 } else {
403 /* bad password */ 403 /* bad password */
404 printf("Wrong password.\n"); 404 printf("Wrong password.\n");
405 currname = 0; 405 currname = 0;
406 continue; 406 continue;
407 } 407 }
408 } 408 }
409 } 409 }
410 410
411 /* 411 /*
412 * try pairs of names[] entries, foo and foo.gz 412 * try pairs of names[] entries, foo and foo.gz
413 */ 413 */
414 /* don't print "booting..." again */ 414 /* don't print "booting..." again */
415 bootit(names[currname][0], 0); 415 bootit(names[currname][0], 0);
416 /* since it failed, try compressed bootfile. */ 416 /* since it failed, try compressed bootfile. */
417 bootit(names[currname][1], AB_VERBOSE); 417 bootit(names[currname][1], AB_VERBOSE);
418 } 418 }
419 419
420 bootmenu(); /* does not return */ 420 bootmenu(); /* does not return */
421} 421}
422 422
423/* ARGSUSED */ 423/* ARGSUSED */
424void 424void
425command_help(char *arg) 425command_help(char *arg)
426{ 426{
427 427
428 printf("commands are:\n" 428 printf("commands are:\n"
429 "boot [dev:][filename] [-12acdqsvxz]\n" 429 "boot [dev:][filename] [-12acdqsvxz]\n"
430#ifndef NO_RAIDFRAME 430#ifndef NO_RAIDFRAME
431 " dev syntax is (hd|fd|cd|raid)[N[x]]\n" 431 " dev syntax is (hd|fd|cd|raid)[N[x]]\n"
432#else 432#else
433 " dev syntax is (hd|fd|cd)[N[x]]n" 433 " dev syntax is (hd|fd|cd)[N[x]]n"
434#endif 434#endif
435#ifndef NO_GPT 435#ifndef NO_GPT
436 " or NAME=gpt_label\n" 436 " or NAME=gpt_label\n"
437#endif 437#endif
438 " (ex. \"hd0a:netbsd.old -s\")\n" 438 " (ex. \"hd0a:netbsd.old -s\")\n"
439#if LIBSA_ENABLE_LS_OP 439#if LIBSA_ENABLE_LS_OP
440 "ls [dev:][path]\n" 440 "ls [dev:][path]\n"
441#endif 441#endif
442 "dev [dev:]\n" 442 "dev [dev:]\n"
443 "consdev {pc|com[0123]|com[0123]kbd|auto}\n" 443 "consdev {pc|{com[0123]|com[0123]kbd|auto}[,{speed}]}\n"
444 "vesa {modenum|on|off|enabled|disabled|list}\n" 444 "vesa {modenum|on|off|enabled|disabled|list}\n"
445#ifndef SMALL 445#ifndef SMALL
446 "menu (reenters boot menu, if defined in boot.cfg)\n" 446 "menu (reenters boot menu, if defined in boot.cfg)\n"
447#endif 447#endif
448 "modules {on|off|enabled|disabled}\n" 448 "modules {on|off|enabled|disabled}\n"
449 "load {path_to_module}\n" 449 "load {path_to_module}\n"
450 "multiboot [dev:][filename] [<args>]\n" 450 "multiboot [dev:][filename] [<args>]\n"
451 "splash {path_to_image_file}\n" 451 "splash {path_to_image_file}\n"
452 "userconf {command}\n" 452 "userconf {command}\n"
453 "rndseed {path_to_rndseed_file}\n" 453 "rndseed {path_to_rndseed_file}\n"
454 "help|?\n" 454 "help|?\n"
455 "quit\n"); 455 "quit\n");
456} 456}
457 457
458#if LIBSA_ENABLE_LS_OP 458#if LIBSA_ENABLE_LS_OP
459void 459void
460command_ls(char *arg) 460command_ls(char *arg)
461{ 461{
462 const char *save = default_filename; 462 const char *save = default_filename;
463 463
464 default_filename = "/"; 464 default_filename = "/";
465 ls(arg); 465 ls(arg);
466 default_filename = save; 466 default_filename = save;
467} 467}
468#endif 468#endif
469 469
470/* ARGSUSED */ 470/* ARGSUSED */
471void 471void
472command_quit(char *arg) 472command_quit(char *arg)
473{ 473{
474 474
475 printf("Exiting...\n"); 475 printf("Exiting...\n");
476 delay(1000000); 476 delay(1000000);
477 reboot(); 477 reboot();
478 /* Note: we shouldn't get to this point! */ 478 /* Note: we shouldn't get to this point! */
479 panic("Could not reboot!"); 479 panic("Could not reboot!");
480} 480}
481 481
482void 482void
483command_boot(char *arg) 483command_boot(char *arg)
484{ 484{
485 char *filename; 485 char *filename;
486 int howto; 486 int howto;
487 487
488 if (!parseboot(arg, &filename, &howto)) 488 if (!parseboot(arg, &filename, &howto))
489 return; 489 return;
490 490
491 if (filename != NULL) { 491 if (filename != NULL) {
492 bootit(filename, howto); 492 bootit(filename, howto);
493 } else { 493 } else {
494 int i; 494 int i;
495 495
496#ifndef SMALL 496#ifndef SMALL
497 if (howto == 0) 497 if (howto == 0)
498 bootdefault(); 498 bootdefault();
499#endif 499#endif
500 for (i = 0; i < NUMNAMES; i++) { 500 for (i = 0; i < NUMNAMES; i++) {
501 bootit(names[i][0], howto); 501 bootit(names[i][0], howto);
502 bootit(names[i][1], howto); 502 bootit(names[i][1], howto);
503 } 503 }
504 } 504 }
505} 505}
506 506
507void 507void
508command_dev(char *arg) 508command_dev(char *arg)
509{ 509{
510 static char savedevname[MAXDEVNAME + 1]; 510 static char savedevname[MAXDEVNAME + 1];
511 char *fsname, *devname; 511 char *fsname, *devname;
512 const char *file; /* dummy */ 512 const char *file; /* dummy */
513 513
514 if (*arg == '\0') { 514 if (*arg == '\0') {
515 biosdisk_probe(); 515 biosdisk_probe();
516 516
517#ifndef NO_GPT 517#ifndef NO_GPT
518 if (default_part_name) 518 if (default_part_name)
519 printf("default NAME=%s on %s%d\n", default_part_name, 519 printf("default NAME=%s on %s%d\n", default_part_name,
520 default_devname, default_unit); 520 default_devname, default_unit);
521 else 521 else
522#endif 522#endif
523 printf("default %s%d%c\n", 523 printf("default %s%d%c\n",
524 default_devname, default_unit, 524 default_devname, default_unit,
525 'a' + default_partition); 525 'a' + default_partition);
526 return; 526 return;
527 } 527 }
528 528
529 if (strchr(arg, ':') == NULL || 529 if (strchr(arg, ':') == NULL ||
530 parsebootfile(arg, &fsname, &devname, &default_unit, 530 parsebootfile(arg, &fsname, &devname, &default_unit,
531 &default_partition, &file)) { 531 &default_partition, &file)) {
532 command_help(NULL); 532 command_help(NULL);
533 return; 533 return;
534 } 534 }
535 535
536 /* put to own static storage */ 536 /* put to own static storage */
537 strncpy(savedevname, devname, MAXDEVNAME + 1); 537 strncpy(savedevname, devname, MAXDEVNAME + 1);
538 default_devname = savedevname; 538 default_devname = savedevname;
539 539
540 /* +5 to skip leading NAME= */ 540 /* +5 to skip leading NAME= */
541 if (strstr(devname, "NAME=") == devname) 541 if (strstr(devname, "NAME=") == devname)
542 default_part_name = default_devname + 5; 542 default_part_name = default_devname + 5;
543} 543}
544 544
545static const struct cons_devs { 545static const struct cons_devs {
546 const char *name; 546 const char *name;
547 u_int tag; 547 u_int tag;
548} cons_devs[] = { 548} cons_devs[] = {
549 { "pc", CONSDEV_PC }, 549 { "pc", CONSDEV_PC },
550 { "com0", CONSDEV_COM0 }, 550 { "com0", CONSDEV_COM0 },
551 { "com1", CONSDEV_COM1 }, 551 { "com1", CONSDEV_COM1 },
552 { "com2", CONSDEV_COM2 }, 552 { "com2", CONSDEV_COM2 },
553 { "com3", CONSDEV_COM3 }, 553 { "com3", CONSDEV_COM3 },
554 { "com0kbd", CONSDEV_COM0KBD }, 554 { "com0kbd", CONSDEV_COM0KBD },
555 { "com1kbd", CONSDEV_COM1KBD }, 555 { "com1kbd", CONSDEV_COM1KBD },
556 { "com2kbd", CONSDEV_COM2KBD }, 556 { "com2kbd", CONSDEV_COM2KBD },
557 { "com3kbd", CONSDEV_COM3KBD }, 557 { "com3kbd", CONSDEV_COM3KBD },
558 { "auto", CONSDEV_AUTO }, 558 { "auto", CONSDEV_AUTO },
559 { NULL, 0 } 559 { NULL, 0 }
560}; 560};
561 561
562void 562void
563command_consdev(char *arg) 563command_consdev(char *arg)
564{ 564{
565 const struct cons_devs *cdp; 565 const struct cons_devs *cdp;
 566 char *sep;
 567 int speed;
 568
 569 sep = strchr(arg, ',');
 570 if (sep != NULL)
 571 *sep++ = '\0';
566 572
567 for (cdp = cons_devs; cdp->name; cdp++) { 573 for (cdp = cons_devs; cdp->name; cdp++) {
568 if (strcmp(arg, cdp->name) == 0) { 574 if (strcmp(arg, cdp->name) != 0)
569 initio(cdp->tag); 575 continue;
570 print_banner(); 576
571 return; 577 if (sep != NULL) {
 578 if (cdp->tag == CONSDEV_PC)
 579 goto error;
 580
 581 speed = atoi(sep);
 582 if (speed < 0)
 583 goto error;
 584 boot_params.bp_conspeed = speed;
572 } 585 }
 586
 587 initio(cdp->tag);
 588 print_banner();
 589 return;
573 } 590 }
 591error:
574 printf("invalid console device.\n"); 592 printf("invalid console device.\n");
575} 593}
576 594
577#ifndef SMALL 595#ifndef SMALL
578/* ARGSUSED */ 596/* ARGSUSED */
579void 597void
580command_menu(char *arg) 598command_menu(char *arg)
581{ 599{
582 600
583 if (bootcfg_info.nummenu > 0) { 601 if (bootcfg_info.nummenu > 0) {
584 /* Does not return */ 602 /* Does not return */
585 doboottypemenu(); 603 doboottypemenu();
586 } else { 604 } else {
587 printf("No menu defined in boot.cfg\n"); 605 printf("No menu defined in boot.cfg\n");
588 } 606 }
589} 607}
590#endif /* !SMALL */ 608#endif /* !SMALL */
591 609
592void 610void
593command_modules(char *arg) 611command_modules(char *arg)
594{ 612{
595 613
596 if (strcmp(arg, "enabled") == 0 || 614 if (strcmp(arg, "enabled") == 0 ||
597 strcmp(arg, "on") == 0) 615 strcmp(arg, "on") == 0)
598 boot_modules_enabled = true; 616 boot_modules_enabled = true;
599 else if (strcmp(arg, "disabled") == 0 || 617 else if (strcmp(arg, "disabled") == 0 ||
600 strcmp(arg, "off") == 0) 618 strcmp(arg, "off") == 0)
601 boot_modules_enabled = false; 619 boot_modules_enabled = false;
602 else 620 else
603 printf("invalid flag, must be 'enabled' or 'disabled'.\n"); 621 printf("invalid flag, must be 'enabled' or 'disabled'.\n");
604} 622}
605 623
606void 624void
607command_multiboot(char *arg) 625command_multiboot(char *arg)
608{ 626{
609 char *filename; 627 char *filename;
610 628
611 filename = arg; 629 filename = arg;
612 if (exec_multiboot(filename, gettrailer(arg)) < 0) 630 if (exec_multiboot(filename, gettrailer(arg)) < 0)
613 printf("multiboot: %s: %s\n", sprint_bootsel(filename), 631 printf("multiboot: %s: %s\n", sprint_bootsel(filename),
614 strerror(errno)); 632 strerror(errno));
615 else 633 else
616 printf("boot returned\n"); 634 printf("boot returned\n");
617} 635}
618 636