Commit Graph

51 Commits

Author SHA1 Message Date
Emmanuel Vadot
5f306327fe Use %ju modifier for u_int64_t and %jd modifier for off_t.
off_t is long long on arm32 and long on amd64

MFC after:	1 week
2016-08-16 14:23:35 +00:00
Mark Johnston
15f6139cc2 Fix a few cosmetic issues in boot1.efi.
- Use ANSI function signatures.
- Remove unneeded checks for a NULL boot module.
- Use nitems().

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-03 17:17:01 +00:00
Ed Maste
0f3454e465 boot1.efi: fix assignment / comparison expression
PR:		210706
Submitted by:	David Binderman <dcb314@hotmail.com>
Approved by:	re (kib)
MFC after:	1 week
2016-07-04 16:50:21 +00:00
Pedro F. Giffuni
5d708ee940 sys/boot: spelling fixes in comments.
No functional change.
2016-04-30 00:26:38 +00:00
Ed Maste
ca2548451a boot1: regenerate FAT templates after r297871
Sponsored by:	The FreeBSD Foundation
2016-04-12 20:59:25 +00:00
Ed Maste
c3be7f5071 boot1.efifat: provide a fallback startup.nsh
In case the firmware falls through to executing startup.sh, populate it
with the name of our boot loader. In normal operation this should not be
necessary but may allow the system to boot if it would otherwise just
remain at a shell prompt.

Reviewed by:	andrew, imp, smh
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5878
2016-04-12 20:52:28 +00:00
Ed Maste
6d51bbb52a boot/efi: Prefer nm to objdump
Both objdump and nm are equally capable of reporting undefined symbols.

This gets us a step closer to building without binutils as we have an nm
implementation from ELF Tool Chain.

Reviewed by:	bdrewery
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5613
2016-03-12 21:44:33 +00:00
Andrew Turner
cc91c4c7b4 Print the correct size of loader.efi when failing to load it into memory.
Obtained from:	AsiaBSDCon
Sponsored by:	ABT Systems Ltd
2016-03-12 06:50:16 +00:00
Bryan Drewery
a09f4b4d12 Add more .NOMETA missed in r291320
Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:45:51 +00:00
Ed Maste
91ca23befa boot1.efi: use += to append to LDFLAGS
This is for consistency with loader.efi's Makefile and simplifies some
out-of-tree experimentation.
2016-03-08 17:45:56 +00:00
Ed Maste
796a99fc5c Remove dd xfer stats emitted during buildworld
They result in gratuitous differences when comparing build log output.
2016-02-18 14:17:28 +00:00
Bryan Drewery
9d8a81b4e4 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:14:30 +00:00
Steven Hartland
5c25653daf Fix EFI platform build failures
With warnings now enabled some plaforms where failing due to warnings.
* Fix st_size printed as a size_t when its actually an off_t.
* Fix pointer conversion in load_elf for some 32bit platforms due to 64bit
  off in ef.

MFC after:	2 days
X-MFC-With:
Sponsored by:	Multiplay
2016-02-06 22:01:25 +00:00
Steven Hartland
89b50f6b4d Fix EFI multi device boot support
Fix EFI boot support when presented with multiple valid boot partitions
across multiple devices.

It now prefers to boot from partitions that are present on the underlying
device that the boot1 image was loaded from. This means that it will boot
from the partitions on device the user chose from EFI boot menu in
preference to those on other devices.

Also fixed is the recovery from a failed attempt to boot, from a seemingly
valid partition, by continuing to trying all other available partitions
no matter what the error.

boot1 now use * to signify a partition what was accepted from the preferred
device and + otherwise.

Finally some error messages where improved and DPRINTF's with slowed boot
to aid debugging.

ZFS will still be preferred over UFS when both are available on the boot
device.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D5108
2016-02-05 15:35:33 +00:00
Warner Losh
01e288734b Read in /boot/config and /boot.config, like all the other boot
loaders and pass it along to /boot/loader.efi.

Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:55 +00:00
Warner Losh
5bbc34e185 Move all the separate copies of the same strings into paths.h. There's
nothing machine specific about these.

Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:19 +00:00
Steven Hartland
ba76113f61 Fix EFI UFS caching
EFI was mixing caching in two separate places causing issues when multiple
partitions where tested.

Eliminate this by removing fsstat and re-factoring fsread into fsread_size,
adding basic parameter validation.

Also:
* Enhance some error print outs.
* Fix compilation under UFS1_ONLY and UFS2_ONLY
* Use sizeof on vars instead of structs.
* Add basic parameter validation to fsread_size.

MFC after:	1 week
X-MFC-With:	r293268
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D4989
2016-01-21 08:58:39 +00:00
Andrew Turner
f3750b35c4 Reset the filesystem cache before reading from a potentially new
filesystem. Without this we only read from the first UFS filesystem we
find, caching the result.

X-MFC with:	The recent boot1.efi changes
2016-01-18 20:22:51 +00:00
Ed Maste
49d592ec08 boot1: correct typo in error message 2016-01-18 18:41:09 +00:00
Steven Hartland
45c5f4a4c9 Fix EFI_DEBUG option
Fix broken DPRINTF and wire up EFI_DEBUG so -DEFI_DEBUG to make works.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-18 12:02:05 +00:00
Steven Hartland
7bd249ecf0 Add EFI ZFS boot support
This builds on the modular EFI loader support added r294060 adding a
module to provide ZFS boot support on EFI systems.

It should be noted that EFI uses a fixed size memory block for all
allocations performed by the loader so it may be necessary to tune this
size.

For example when building an image which uses mfs_root e.g. mfsbsd, adding
the following to /etc/make.conf would be needed to prevent EFI from running
out of memory when loading the mfs_root image.
EFI_STAGING_SIZE=128

Submitted by:	Eric McCorkle
MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-15 02:33:47 +00:00
Steven Hartland
b2ec7c304e Modularise EFI boot loader
Make EFI boot loader modular in preparation for adding ZFS support.

This is a partial commit of the D4515.

Submitted by:	Eric McCorkle
Reviewed by:	emaste (in part)
MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D4515
2016-01-15 01:22:36 +00:00
Steven Hartland
445a2b570e Only build EFI components on supported compilers
As the in-tree GCC does not support __attribute__((ms_abi)) EFI can only
be built with Clang.

The EFI loader and boot1 validated this, but unused libefi was still built
causing issues under GCC after warnings where enabled by r293724.

Disable building all of EFI when the selected compiler is GCC.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-14 18:53:54 +00:00
Steven Hartland
022e692a47 Enable warnings in EFI boot code
Set WARNS if not set for EFI boot code and fix the issues highlighted by
setting it.

Most components are set to WARNS level 6 with few being left at lower
levels due to the amount of changes needed to fix at higher levels.

Error types fixed:
* Missing / invalid casts
* Missing inner structs
* Unused vars
* Missing static for internal only funcs
* Missing prototypes
* Alignment changes
* Use of uninitialised vars
* Unknown pragma (intrinsic)
* Missing types etc due to missing includes
* printf formatting types

Reviewed by:	emaste (in part)
MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D4839
2016-01-12 02:17:39 +00:00
Steven Hartland
1b1632a243 Remove hidden "Not ufs" printfs from boot code
Remove the printf("Not ufs\n") from the boot code which was hidden by the
local printf implementations, allowing these to have that code removed too.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-09 03:30:33 +00:00
Steven Hartland
77e4457b19 Switch EFT boot1 to use libstand
ARM and i386 already required libstand so switch to using it for all
patforms, allowing the removal of custom print and memory methods.

This is also a pre-cursor to enabling WARNS which highlighted a number
of issues with the removed methods.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-09 03:20:01 +00:00
Ed Maste
638b3cc8ce Avoid unintended $FreeBSD$ expansion in generate-fat.sh 2016-01-08 17:33:34 +00:00
Ed Maste
8f2318bdcc Add safety belt for boot1.efi file size
Reviewed by:	smh
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4833
2016-01-08 16:37:22 +00:00
Steven Hartland
858ceeb3ef Update generated efi boot image templates
r279533 increased the boot1 size from 64k to 128k but didn't regenerate the
fat templates, hence the change was never activated.

With recent and upcoming changes the efi boot1 binary is now > 64k.

To avoid fat corruption in the created boot images regenerate the
templates to activate the boot1 size increase.

MFC after:	2 weeks
X-MFC-With:	r293268
2016-01-08 13:58:36 +00:00
Steven Hartland
5fc656f187 style(9) fixes for EFI boot
Fix some style(9) nits for EFI boot code, no functional changes.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-06 20:48:29 +00:00
Ed Maste
c82e181b74 Introduce and use new EFI_ERROR_CODE macro for EFI errors
Submitted by:	smh
MFC after:	1 week
2016-01-06 19:15:16 +00:00
Ed Maste
d3525a9e36 boot1.efi: show EFI error number, not full status value
EFI return values set the high bit to indicate an error. The log
messages changed here are printed only in the case of an error,
so including the error bit is redundant. Also switch to decimal to
match the error definitions (in sys/boot/efi/include/efierr.h).

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2015-12-21 22:42:03 +00:00
Bryan Drewery
b1f92fa229 META MODE: Update dependencies with 'the-lot' and add missing directories.
This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so.  A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR.  These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package.  The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:23:19 +00:00
John Baldwin
5dc89bd2a0 Various small cleanups to EFI loader Makefiles.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D3641
2015-09-17 18:32:51 +00:00
Ian Lepore
5b1c03fd13 The self-relocation code is not efi-specific, move it to boot/common.
The function was defined as taking 4 parameters and returning EFI_STATUS,
but all existing callers (in asm code) passed only two parameters and don't
use the return value. The function signature now matches that usage, and
doesn't refer to efi-specific types.

Parameters and variables now use the cannonical typenames set up by elf.h
(Elf_Word, Elf_Addr, etc) instead of raw C types. Hopefully this will
prevent suprises as new platforms come along and use this code.

The function was renamed from _reloc() to self_reloc() to emphasize its
difference from the other elf relocation code found in boot/common.

Differential Revision:	https://reviews.freebsd.org/D2490
2015-05-10 13:24:26 +00:00
Andrew Turner
5031d03e5a Disable the use of floating-point and vector registers in the loader. They
need the vfp unit to be enabled which may not be the case.
2015-05-05 11:00:50 +00:00
Andrew Turner
0cafabf97f Add support for arm64 to loader.efi and boot1.efi
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2015-04-14 13:55:01 +00:00
Andrew Turner
c93a8403be Use MACHINE in the efi loader when it is what we mean, it may not be the
same as MACHINE_CPUARCH, it just happened to be the case the architectures
this code currently supports.

Sponsored by:	The FreeBSD Foundation
2015-04-14 10:40:37 +00:00
Andrew Turner
2d790e26e5 Create the correct symlinks for the machine directory, and only create the
x86 symlink on i386 and amd64. Before this incorrect symlinks were being
created on armi and i386.

Differential Revision:	https://reviews.freebsd.org/D2283
Reviewed by:	emaste, imp
Sponsored by:	The FreeBSD Foundation
2015-04-13 16:00:09 +00:00
Andrew Turner
23c48d2315 Print error values with hex to make it easier to find the EFI error type. 2015-04-09 10:15:47 +00:00
Andrew Turner
8ab49d66d2 Only use -fPIC when building boot1.efi for x86.
Sponsored by:	The FreeBSD Foundation
2015-04-09 10:08:10 +00:00
Ed Maste
0c8a72c0d2 Add EFI boot1 for i386
loader.efi still needs work, but boot1.efi now builds.

Differential Revision:	https://reviews.freebsd.org/D2244
Reviewed by:	rpaulo
Sponsored by:	The FreeBSD Foundation
2015-04-07 21:41:26 +00:00
Ed Maste
c6f6755c90 EFI: use common reloc.c for all architectures
Much of this file is common to the architectures we support, so share
an implementation by adding a little #ifdef-ery.

Differential Revision:	https://reviews.freebsd.org/D2241
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2015-04-07 21:34:49 +00:00
Andrew Turner
533e5098de Make global variabled only used in this file static. 2015-04-06 19:58:28 +00:00
Andrew Turner
63d071445e Add support to the efi boot1 and loader for 32-bit ARM. This will be used
by the future qemu virt support.

Differential Revision:	https://reviews.freebsd.org/D2238
Reviewed by:	emaste
2015-04-06 15:50:20 +00:00
Andrew Turner
45304e75b9 Move boot1.efi to the global CLEANFILES list, it's not x86 specific. 2015-04-05 18:57:58 +00:00
Rui Paulo
c293bc993b Remove an unnecessary space in a printf call. 2015-04-04 04:29:31 +00:00
Rui Paulo
11d48637a1 boot1 EFI: reset the screen and select the best mode.
It's necessary to reset the screen to make sure any vendor pixels are
gone when we start boot1.  In the Lenovo X1 (3rd gen), this is the
only way to clear the screen.  Previously, the Lenovo logo would only
disappear after the kernel started scrolling the display.

After resetting the screen, EFI could put us in the worst LCD mode
(oversized characters), so we now find the largest mode we can use and
hope it's the most appropriate one (it's not trivial to tell what's
the correct LCD resolution at this point).  It's worth noting that the
final stage loader has a 'mode' command that can be used to switch
text modes.

While there, enable the software cursor, just like in the legacy boot
mode.

MFC after:	1 week
2015-04-04 04:27:54 +00:00
Rui Paulo
92de577931 Remove whitespace. 2015-04-04 04:18:52 +00:00
Andrew Turner
94d3e34255 Clean up more x86 only options in the efi code. 2015-04-03 15:25:59 +00:00