From 3b0251723f2d9ed1bf1b9b087557599e406a6628 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sat, 14 Jan 2017 06:47:05 +0100
Subject: [PATCH 4/4] Add a uefi(8) manual page giving some info on the UEFI
 boot procedure.

Adapted-from: FreeBSD
---
 sbin/reboot/boot_pc64.8 |   9 ++-
 share/man/man8/Makefile |   5 ++
 share/man/man8/uefi.8   | 150 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 162 insertions(+), 2 deletions(-)
 create mode 100644 share/man/man8/uefi.8

diff --git a/sbin/reboot/boot_pc64.8 b/sbin/reboot/boot_pc64.8
index b1d301beb8..f785a5fa81 100644
--- a/sbin/reboot/boot_pc64.8
+++ b/sbin/reboot/boot_pc64.8
@@ -36,7 +36,7 @@
 .\"
 .\" $FreeBSD: src/sbin/reboot/boot_i386.8,v 1.23.2.11 2002/04/24 17:47:58 rnordier Exp $
 .\"
-.Dd July 23, 2015
+.Dd January 14, 2017
 .Dt BOOT 8
 .Os
 .Sh NAME
@@ -56,6 +56,10 @@ Usually, BIOSes allow
 you to change this default sequence, and typically also include a CD-ROM
 drive as a boot device.
 .Pp
+Newer PCs boot using UEFI firmware, not legacy BIOS.
+That process is described in
+.Xr uefi 8 .
+.Pp
 By default, a three-stage bootstrap is employed, and control is
 automatically passed from the boot blocks (bootstrap stages one and
 two) to a separate third-stage bootstrap program,
@@ -287,7 +291,8 @@ requirement has not been adhered to.
 .Xr halt 8 ,
 .Xr loader 8 ,
 .Xr reboot 8 ,
-.Xr shutdown 8
+.Xr shutdown 8 ,
+.Xr uefi 8
 .Sh BUGS
 The
 .Xr disklabel 5
diff --git a/share/man/man8/Makefile b/share/man/man8/Makefile
index 1ce175652f..4d6f654cd7 100644
--- a/share/man/man8/Makefile
+++ b/share/man/man8/Makefile
@@ -11,6 +11,7 @@ MAN=	adding_user.8 \
 	rc.subr.8 \
 	sticky.8 \
 	swapcache.8 \
+	${_uefi.8} \
 	yp.8
 
 MLINKS=	rc.8 rc.d.8 \
@@ -22,4 +23,8 @@ MLINKS+=yp.8 nis.8 \
 	yp.8 NIS.8 \
 	yp.8 YP.8
 
+.if ${MACHINE_ARCH} == "x86_64"
+_uefi.8= uefi.8
+.endif
+
 .include <bsd.prog.mk>
diff --git a/share/man/man8/uefi.8 b/share/man/man8/uefi.8
new file mode 100644
index 0000000000..a6febfdc60
--- /dev/null
+++ b/share/man/man8/uefi.8
@@ -0,0 +1,150 @@
+.\" Copyright (c) 2014 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: head/share/man/man8/uefi.8 295522 2016-02-11 14:45:18Z emaste $
+.\"
+.Dd January 8, 2017
+.Dt UEFI 8
+.Os
+.Sh NAME
+.Nm UEFI
+.Nd Unified Extensible Firmware Interface bootstrapping procedures
+.Sh DESCRIPTION
+The
+.Nm
+Unified Extensible Firmware Interface provides boot- and run-time services
+to operating systems.
+.Nm
+is a replacement for the legacy BIOS on the i386 and amd64 CPU architectures,
+and is also used on arm64 and ia64.
+.Pp
+The
+.Nm
+boot process loads system bootstrap code located in an EFI System Partition
+(ESP).
+The ESP is a GPT or MBR partition with a specific identifier that contains an
+.Xr msdos 5
+FAT file system with a specified file hierarchy.
+.Bl -column -offset indent ".Sy Partition Scheme" ".Sy ESP Identifier"
+.It Sy "Partition Scheme" Ta Sy "ESP Identifier"
+.It GPT Ta C12A7328-F81F-11D2-BA4B-00A0C93EC93B
+.It MBR Ta 0xEF
+.El
+.Pp
+The
+.Nm
+boot process proceeds as follows:
+.Bl -enum -offset indent -compact
+.It
+.Nm
+firmware runs at power up and searches for an OS loader in the EFI system
+partition.
+The path to the loader may be set by an EFI environment variable.
+If not set, the default is
+.Pa /EFI/BOOT/BOOTX64.EFI .
+The default
+.Nm
+boot configuration for
+.Dx
+installs
+.Pa boot1.efi
+as
+.Pa /EFI/BOOT/BOOTX64.EFI .
+.It
+.Pa boot1.efi
+reads boot configuration from
+.Pa /boot.config
+or
+.Pa /boot/config .
+Unlike other first-stage boot loaders,
+.Pa boot1.efi
+passes the configuration to the next stage boot loader and does not
+itself act on the contents of the file.
+.It
+.Pa boot1.efi
+searches partitions of type
+.Sq DragonFly UFS1
+and the first
+.Xr disklabel64 5
+partition in GPT partitions of type
+.Sq DragonFly Label64
+for
+.Pa loader.efi .
+The search begins with partitions on the device from which
+.Pa boot1.efi
+was loaded, and continues with other available partitions.
+.\"If both
+.\".Li DragonFly UFS1
+.\"and
+.\".Li DragonFly Label64
+.\"partitions exist on the same device
+.\"...
+.Pa boot1.efi
+then loads and executes
+.Pa loader.efi .
+.It
+.Pa loader.efi
+loads and boots the kernel, as described in
+.Xr loader 8 .
+.El
+.Sh FILES
+.Bl -tag -width /boot/loader -compact
+.It Pa /boot/boot1.efi
+First stage
+.Nm
+bootstrap
+.It Pa /boot/loader.efi
+Final stage bootstrap
+.It Pa /boot/kernel/kernel
+default kernel
+.It Pa /boot/kernel.old/kernel
+typical non-default kernel (optional)
+.El
+.Sh SEE ALSO
+.\".Xr boot.config 5 ,
+.Xr disklabel64 5 ,
+.Xr msdos 5 ,
+.Xr boot 8 ,
+.Xr uefisign 8
+.Sh HISTORY
+.Nm
+boot support first appeared in
+.Fx 10.1
+and was brought into
+.Dx 4.5 .
+.Sh AUTHORS
+.An -nosplit
+.Nm
+boot support was developed by
+.An Benno Rice Aq Mt benno@FreeBSD.org ,
+.An \&Ed Maste Aq Mt emaste@FreeBSD.org ,
+and
+.An Nathan Whitehorn Aq Mt nwhitehorn@FreeBSD.org .
+The
+.Fx
+Foundation sponsored portions of the work.
+.Sh CAVEATS
+EFI environment variables are not supported by
+.Xr loader 8
+or the kernel.
-- 
2.11.0

