Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src Pull up following revision(s) (requested by manu in ticke...
details: https://anonhg.NetBSD.org/src/rev/7ef8e9f681bb
branches: netbsd-9
changeset: 1000841:7ef8e9f681bb
user: martin <martin%NetBSD.org@localhost>
date: Fri Sep 13 07:00:13 2019 +0000
description:
Pull up following revision(s) (requested by manu in ticket #200):
sys/arch/i386/stand/boot/boot2.c: revision 1.72
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
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 2184 to 300 lines):
diff -r 50cc32bfd02b -r 7ef8e9f681bb share/man/man8/man8.x86/boot.8
--- a/share/man/man8/man8.x86/boot.8 Fri Sep 13 06:56:23 2019 +0000
+++ b/share/man/man8/man8.x86/boot.8 Fri Sep 13 07:00:13 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: boot.8,v 1.15 2019/05/15 17:35:02 maxv Exp $
+.\" $NetBSD: boot.8,v 1.15.2.1 2019/09/13 07:00:14 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 May 15, 2019
+.Dd August 18, 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 50cc32bfd02b -r 7ef8e9f681bb sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c Fri Sep 13 06:56:23 2019 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c Fri Sep 13 07:00:13 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot2.c,v 1.70 2017/11/14 09:55:41 maxv Exp $ */
+/* $NetBSD: boot2.c,v 1.70.8.1 2019/09/13 07:00:13 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);
@@ -160,9 +166,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;
@@ -171,7 +184,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;
@@ -180,6 +192,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;
@@ -215,6 +238,7 @@
fname = col + 1;
}
+out:
if (*fname)
*file = fname;
@@ -231,8 +255,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)";
@@ -319,7 +346,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