Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src Pull up following revision(s) (requested by manu in ticke...
details: https://anonhg.NetBSD.org/src/rev/be77da1e25b2
branches: netbsd-8
changeset: 454449:be77da1e25b2
user: martin <martin%NetBSD.org@localhost>
date: Tue Sep 17 18:26:53 2019 +0000
description:
Pull up following revision(s) (requested by manu in ticket #1373):
sys/arch/i386/stand/boot/boot2.c: revision 1.72 (patch)
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14 (patch)
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71
Add GPT and RAIDframe support to bootloaders
Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:
boot NAME=root:/netbsd
boot raid0e:/netbsd
Correct the memset(3)'s third argument in i386 biosdisk.c
The size of allocation is the size of the structure biosdisk, not the size
of a pointer.
Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs
Typo fixes, 'file system'; new sentence, new line; expand IA-32.
Bump date for previous.
Make sure devices names are copied including last byte
Fix from M. Levinson.
diffstat:
share/man/man8/man8.x86/boot.8 | 129 ++++-
sys/arch/i386/stand/boot/boot2.c | 73 ++-
sys/arch/i386/stand/boot/devopen.c | 34 +-
sys/arch/i386/stand/boot/devopen.h | 4 +-
sys/arch/i386/stand/efiboot/boot.c | 65 ++-
sys/arch/i386/stand/efiboot/devopen.c | 29 +-
sys/arch/i386/stand/efiboot/devopen.h | 6 +-
sys/arch/i386/stand/efiboot/efidisk.c | 153 +++++-
sys/arch/i386/stand/lib/Makefile | 3 +-
sys/arch/i386/stand/lib/biosdisk.c | 867 ++++++++++++++++++++++++++++++---
sys/arch/i386/stand/lib/biosdisk.h | 16 +-
11 files changed, 1217 insertions(+), 162 deletions(-)
diffs (truncated from 2182 to 300 lines):
diff -r 112032d9928c -r be77da1e25b2 share/man/man8/man8.x86/boot.8
--- a/share/man/man8/man8.x86/boot.8 Tue Sep 10 16:04:59 2019 +0000
+++ b/share/man/man8/man8.x86/boot.8 Tue Sep 17 18:26:53 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: boot.8,v 1.11.4.1 2019/09/02 16:39:24 martin Exp $
+.\" $NetBSD: boot.8,v 1.11.4.2 2019/09/17 18:26:53 martin Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)boot_i386.8 8.2 (Berkeley) 4/19/94
.\"
-.Dd February 17, 2017
+.Dd September 13, 2019
.Dt BOOT 8 x86
.Os
.Sh NAME
@@ -40,13 +40,9 @@
.Nd
system bootstrapping procedures
.Sh DESCRIPTION
-.Tn IA-32
-computers
-.Po
-the
+Intel Architecture, 32-bit (IA-32) computers (the
.Tn IBM PC
-and its clones
-.Pc
+and its clones)
that can run
.Nx Ns /i386
or
@@ -60,6 +56,11 @@
.Nx
from the system
.Tn BIOS
+.It efiboot
+bootstrap
+.Nx
+from the system
+.Tn UEFI
.It Xr x86/dosboot 8
bootstrap
.Nx
@@ -175,12 +176,32 @@
.It Ic boot Oo Va device : Oc Ns Oo Va filename Oc Oo Fl 1234abcdmqsvxz Oc
The default
.Va device
-will be set to the disk that the boot loader was
-loaded from.
+will be set to the disk from which the boot loader was loaded.
+The partition is set to the first match in this list:
+.Bl -enum -compact
+.It
+The first
+.Xr gpt 8
+partition with the
+.Va bootme
+attribute set.
+.It
+The partition from which the boot loader was loaded from, if that
+can be detected.
+.It
+The first partition with a file system that could be bootable.
+.It
+The first partition.
+.El
To boot from an alternate disk, the full name of the device should
be given at the prompt.
.Va device
is of the form
+.Va NAME=partition_label
+when booting from a
+.Xr gpt 8
+partitioned disk.
+Otherwise, the syntax is
.Xo Va xd
.Op Va N Ns Op Va x
.Xc
@@ -192,8 +213,8 @@
.Va x
is the partition letter.
.Pp
-The following list of supported devices may vary from installation to
-installation:
+In the later case, the following list of supported devices may
+vary from installation to installation:
.Pp
.Bl -hang -compact
.It hd
@@ -203,6 +224,22 @@
on SCSI controllers recognized by the BIOS.
.It fd
Floppy drives as numbered by the BIOS.
+.It cd
+CD-ROM drives as numbered by the BIOS.
+.It raid
+RAIDframe configured from hard disks recognized by the BIOS.
+Only RAID level 1 sets are supported by bootstrap code.
+If the RAID is partitioned, the first partition is used, or the
+first
+.Xr gpt 8
+partition that has the
+.Va bootme
+attribute set.
+Inner RAIDframe partitions can also be given to the
+.Ic dev
+command using he
+.Va NAME=partition_label
+syntax.
.El
.Pp
The default
@@ -700,6 +737,33 @@
.Nx
partition by
.Xr installboot 8 .
+.It Pa /usr/mdec/bootia32.efi
+.It Pa /usr/mdec/bootx64.efi
+.Tn UEFI
+bootstraps for
+.Nx Ns /i386
+and
+.Nx Ns /amd64 ,
+which should be copied to the
+.Pa /efi/boot
+directory in a
+.Tn FAT
+formatted partition of type
+.Tn EFI
+(Either
+.Xr mbr 8
+and
+.Xr gpt 8 ,
+see the
+.Sx BUGS
+section).
+.Nx
+.Tn UEFI
+bootstrap reads its configuration from the
+.Pa /efi/netBSD/boot.cfg
+file in the
+.Tn EFI
+partition.
.El
.Sh SEE ALSO
.Xr ddb 4 ,
@@ -756,3 +820,44 @@
field of the
.Nx
disklabel (if it is a hard disk).
+.Pp
+.Ic multiboot
+is not supported by
+.Tn UEFI
+bootstrap code.
+.Pp
+.Tn UEFI
+implementation are supposed to support either
+.Xr mbr 8
+or
+.Xr gpt 8
+partitionning, but some do not handle the later.
+.Tn UEFI
+Booting
+from a
+.Xr gpt 8
+partitioned disk is still possible in this case, by adding
+an overlapping
+.Tn EFI
+partition in the protective
+.Xr mbr 8
+block.
+This can be achieved using the following commands
+(you must adapt the hard disk and
+.Tn EFI
+partition start end size to fit your setup):
+.Dl Ic dd if=/dev/rwd0d bs=512 count=1 of=mbr
+.Dl Ic fdisk -FIfaui1s 4/34/32768 -c /usr/mdec/mbr mbr
+.Dl Ic dd if=mbr bs=512 count=1 of=/dev/rwd0d conv=notrunc
+The resulting
+.Xr mbr 8
+partition table will look like this:
+.Bd -unfilled -offset indent
+0: GPT Protective MBR (sysid 238)
+ start 1, size 2097151 (1024 MB, Cyls 0-130/138/8)
+ PBR is not bootable: Bad magic number (0x0000)
+1: Primary DOS with 16 bit FAT <32M (sysid 4)
+ start 34, size 32768 (16 MB, Cyls 0/0/35-2/10/42), Active
+2: <UNUSED>
+3: <UNUSED>
+.Ed
diff -r 112032d9928c -r be77da1e25b2 sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c Tue Sep 10 16:04:59 2019 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c Tue Sep 17 18:26:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot2.c,v 1.66 2016/02/03 05:27:53 christos Exp $ */
+/* $NetBSD: boot2.c,v 1.66.10.1 2019/09/17 18:26:53 martin Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -79,6 +79,7 @@
#include <libi386.h>
#include <bootmod.h>
#include <bootmenu.h>
+#include <biosdisk.h>
#include <vbe.h>
#include "devopen.h"
@@ -104,11 +105,16 @@
#define NUMNAMES (sizeof(names)/sizeof(names[0]))
#define DEFFILENAME names[0][0]
+#ifndef NO_GPT
+#define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */
+#else
#define MAXDEVNAME 16
+#endif
static char *default_devname;
static int default_unit, default_partition;
static const char *default_filename;
+static const char *default_part_name;
char *sprint_bootsel(const char *);
static void bootit(const char *, int);
@@ -158,9 +164,16 @@
int *unit, int *partition, const char **file)
{
const char *col;
+ static char savedevname[MAXDEVNAME+1];
*fsname = "ufs";
- *devname = default_devname;
+ if (default_part_name == NULL) {
+ *devname = default_devname;
+ } else {
+ snprintf(savedevname, sizeof(savedevname),
+ "NAME=%s", default_part_name);
+ *devname = savedevname;
+ }
*unit = default_unit;
*partition = default_partition;
*file = default_filename;
@@ -169,7 +182,6 @@
return 0;
if ((col = strchr(fname, ':')) != NULL) { /* device given */
- static char savedevname[MAXDEVNAME+1];
int devlen;
int u = 0, p = 0;
int i = 0;
@@ -178,6 +190,17 @@
if (devlen > MAXDEVNAME)
return EINVAL;
+#ifndef NO_GPT
+ if (strstr(fname, "NAME=") == fname) {
+ strlcpy(savedevname, fname, devlen + 1);
+ *devname = savedevname;
+ *unit = -1;
+ *partition = -1;
+ fname = col + 1;
+ goto out;
+ }
+#endif
+
#define isvalidname(c) ((c) >= 'a' && (c) <= 'z')
if (!isvalidname(fname[i]))
return EINVAL;
@@ -213,6 +236,7 @@
fname = col + 1;
}
+out:
if (*fname)
*file = fname;
@@ -229,8 +253,11 @@
if (parsebootfile(filename, &fsname, &devname, &unit,
&partition, &file) == 0) {
- snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit,
- 'a' + partition, file);
+ if (strstr(devname, "NAME=") == devname)
+ snprintf(buf, sizeof(buf), "%s:%s", devname, file);
+ else
+ snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit,
+ 'a' + partition, file);
return buf;
}
return "(invalid)";
@@ -317,7 +344,7 @@
/* try to set default device to what BIOS tells us */
bios2dev(biosdev, biossector, &default_devname, &default_unit,
- &default_partition);
+ &default_partition, &default_part_name);
Home |
Main Index |
Thread Index |
Old Index