Commit Graph

3366 Commits

Author SHA1 Message Date
Warner Losh
1e97830083 Implement -P for boot loader. It's a bit easier to implement here than
in boot1, like is normally done. When a keyboard appears in the UEFI
device tree, assume -D -h, just like on a BIOS boot.

# It is unclear if an ACPI keyboard appearing in the tree means there's
# a real keyboard or not. A USB keyboard doesn't seem to appear unless
# it is really there.

Differential Revision: https://reviews.freebsd.org/D5223
2016-02-08 19:34:17 +00:00
Ed Maste
afae3eed15 Restore kgzldr on i386 only
I previously disconnected kgzdr based on a misunderstanding.

I'd still like to transition to supporting only the loader(8)-based
boot path for handling compressed kernels, but that can follow the
standard deprecation procedure.

This reverts r291113.

Requested by:	dteske
2016-02-08 16:59:52 +00:00
Allan Jude
9cdff681a4 Do not set vfs.root.mountfrom unnecessarily
This causes boot from external media (installer USB image) to mount / from
the default ZFS BE, rather than the USB device.

Reported by:	kmoore
MFC after:	5 days
Sponsored by:	ScaleEngine Inc.
2016-02-07 00:49:15 +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
Andrew Turner
1485c016ba Still open the network interface when EFI_OPEN_PROTOCOL_EXCLUSIVE failed.
Not all UEFI implementations support this protocol.
2016-02-03 14:34:25 +00:00
Andrew Turner
b0d2533fb2 Add suppor to loader.efi to load files off hte network. For this we need
to open the device in exclusive mode as, without this, the firmware may
also be reading packets off the interface leading to a race.

Reviewed by:	emaste
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D4132
2016-02-02 10:39:18 +00:00
Ruslan Bukin
28029b68c0 Welcome the RISC-V 64-bit kernel.
This is the final step required allowing to compile and to run RISC-V
kernel and userland from HEAD.

RISC-V is a completely open ISA that is freely available to academia
and industry.

Thanks to all the people involved! Special thanks to Andrew Turner,
David Chisnall, Ed Maste, Konstantin Belousov, John Baldwin and
Arun Thomas for their help.
Thanks to Robert Watson for organizing this project.

This project sponsored by UK Higher Education Innovation Fund (HEIF5) and
DARPA CTSRD project at the University of Cambridge Computer Laboratory.

FreeBSD/RISC-V project home: https://wiki.freebsd.org/riscv

Reviewed by:	andrew, emaste, kib
Relnotes:	Yes
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D4982
2016-01-29 15:12:31 +00:00
Allan Jude
d28e78bacf ficl on i386 should cast to unsigned char output to support efi i386
make it possible for efi_console to recognize and translate box characters
on i386 build (unsigned versus signed char passed as int issue).

Submitted by:	Toomas Soome <tsoome at me.com>
Reviewed by:	emaste, smh, dteske
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D4993
2016-01-27 16:45:23 +00:00
Warner Losh
6422ac8292 Fix mistake when transitioning to the new defines with ZFS loader. I
hate adding yet another define, but it is the lessor of the evil
choices available. Kill another evil by removing PATH_BOOT3 and
replacing it with PATH_LOADER or PATH_LOADER_ZFS as appropriate.

PR: 206659
2016-01-27 16:36:18 +00:00
Warner Losh
545ed21a78 Remove static from these two. They slipped through the cracks.
MFC After: 1 week
2016-01-26 18:39:30 +00:00
Warner Losh
b69d02ee50 Allow new lines as white space for arguments that are parsed to allow
boot1 to pass in files with newlines in them. Now that the EFI loader
groks foo=bar on the command line, this can allow a more general setup
than traditional boot loader args will allow.

Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:56 +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
33fcb4aff8 Parse the command line arguments, and do it before we initialize the
console so it can be changed by the command line arguments.

Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:46 +00:00
Warner Losh
5063232c10 RBX_ defines are in rbx.h, move it there.
Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:44 +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
Ed Maste
5abb4cd79f Use MAN= to specify that no man page is provided
NO_MAN is deprecated.

Reviewed by:	imp
2016-01-22 21:33:27 +00:00
Wojciech Macek
a8d8da1b1f Provide busdma stubs for loader/kshim
Simple bus space stubs require the VA-PA mapping
    to be identical.

Approved by:           hselasky, cognet (mentor)
Differential revision: https://reviews.freebsd.org/D4314
2016-01-22 06:26:11 +00:00
Wojciech Macek
9526c20a50 Fix compilation errors in usb/kshim
Remove old header from the include list and declare extern symbol
    for delay() function.

Approved by:           hselasky, cognet (mentor)
Differential revision: https://reviews.freebsd.org/D5012
2016-01-22 06:05:31 +00:00
Steven Hartland
9e055ad144 Prevent loader.conf load failure due to unknown console entries
When processing loader.conf if console contained an entry for an unsupported
console then cons_set would return an error refusing to set any console.

This has two side effects:

1. Forth would throw a syntax error and stop processing loader.conf at that
  point.
2. The value of console is ignored.

#1 Means other important loader.conf entries may not be processed, which is
   clearly undesirable.
#2 Means the users preference for console aren't applied even if they did
   contain valid options. Now we have support for multi boot paths from a
   single image e.g. bios and efi mode the console preference needs to deal
   with the need to set preference for more than one source.

Fix this by:
* Returning CMD_OK where possible from cons_set.
* Allowing set with at least one valid console to proceed.

Reviewed by:	allanjude
MFC after:	1 week
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D5018
2016-01-21 15:27:44 +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
Ed Maste
7a73d15e90 Increase BERI boot components section alignment to 16
The .text, .bss, and .data sections claimed 16-byte alignment, but were
only aligned to 8 by the linker script.

Discovered with elfcopy(1) from elftoolchain, which performs validation
absent from the binutils strip(1). ELF tool chain ticket #512.

Reported by:	brooks
Reviewed by:	brooks
Sponsored by:	DARPA, AFRL
2016-01-20 18:35:43 +00:00
Zbigniew Bodek
0538eb3458 Change DTS entry of PCIe controller for Armada38x
Invalid (in FreeBSD) definition of PCI controller was
replaced with another one, working in FreeBSD environment.

PCI controller's entry had to move from its parent node
so as to be recognized properly by FBSD.

PCI was enabled in kernel configuration file.

Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4379
2016-01-20 14:14:30 +00:00
Zbigniew Bodek
8abfc69d11 Fix busy-detect when using DesignWare UART
uart_dev_ns8250 now relies on compatible property instead of additional
'busy-detect' cell. All drivers with compatible = "snps,dw-apb-uart" have
busy detection turned on. DTS files of devices affected by the change
were modified and 'busy-detect' property was removed.

Reviewed by:    andrew, ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4218
2016-01-20 13:51:14 +00:00
Zbigniew Bodek
e5165b9e23 Add global mpcore timer node to Armada 38x DTS
Changes:
- global mpcore timer dts node added
- required by driver 'clock-frequency' property added

Reviewed by:    ian
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4213
2016-01-20 13:40:54 +00:00
Zbigniew Bodek
ed5d3a971c Correct ranges in Armada38x dts
Ranges property of 'soc' node used two-cell addresses which resulted in
casting errors as simplebus resource allocation works with 32-bit u_long
variables. FDT ranges were simplified.

Reviewed by:    imp
Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4212
2016-01-20 13:32:13 +00:00
Zbigniew Bodek
f8742b0da3 Introduce initial support for Marvell Armada38x
This commit introduces initial support for Marvell Armada38x platform.
Changes:
- Add common DTS files for Armada38x SoCs and DTS file for A388-GP
- Add ARMADA38X kernel configuration
- Add option SOC_MV_ARMADA38X and set MV_PCI_PORTS
- Add list of files to compile
- Implement get_tclk(), get_sar_value(), cpu_reset() functions
- Add CPU ID and SoC numbers
- Correct ifdefs in arm/mv/timer.c

Reviewed by:    ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4210
2016-01-20 13:14:36 +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
Allan Jude
1b65ef2908 Connect the ZFS boot environment menu to the UEFI loader
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-15 05:45:45 +00:00
Allan Jude
fbe958861e Move init_zfs_bootenv to sys/boot/zfs/zfs.c instead of having a copy in each loader
While here, add a filter to ignore special datasets

MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-15 05:45:10 +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
108d68faae Ensure boot fsread correctly probes all partitions
The boot code fsread was caching the result of meta data request and
reusing it even for calls with inode = 0, which is used to partitions
trigger a probe.

The result was that success was incorrectly returned for all partition
probes after the first valid success, even for partitions which are not
UFS.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-15 01:06:37 +00:00
Steven Hartland
dc9ba0270b Make common boot file_loadraw name parameter const
Fix compiler warnings about dropping const qualifier by changing file_loadraw
name param to const, and updating method to make that the case (it was
abusing the variable).

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-15 00:55:36 +00:00
Juli Mallett
e83ddf77d4 Make it possible to specify the path to userboot.so with the -b flag.
Reviewed by:	neel
2016-01-14 22:07:35 +00:00
Steven Hartland
bff57f7053 Remove unused reg param from fdt_fixup_memory
MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-14 21:39:10 +00:00
Steven Hartland
276a15676c Prevent bogus compiler in ZFS boot code
Silence a bogus compiler warning about indexing past the end of dn_bonus.

The ZFS code ensures this is not possible but the compiler can't determine
this so added an additional check to prevent this warning.

Sponsored by:	Multiplay
2016-01-14 21:31:26 +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
8171acf3ad Revert r293903
Revert r293903 as EFI shouldn't be built on this platform that the this
was reported on.

Sponsored by:	Multiplay
2016-01-14 18:46:57 +00:00
Steven Hartland
bb39a9ed8e Fix GCC warnings causing build failure after r293724
Disable some compiler warnings for GCC (non-standard compiler) fixing
build failures introduced by r293724, which enabled WARNS in the EFI boot
code, when compiling with none standard compiler (GCC).

Raised by:	ian
MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-14 09:22:01 +00:00
Steven Hartland
4b09a8fdbc Improve non-interactive forth cmd error reporting
Non-interactive forth command errors where silent even for critical issues
e.g. failing to load a required kernel module or mfs_root.

This resulted in later unexplained and hard to trace errors such as mount
root failures.

This introduces additional command return codes that are treated
appropriately by the non-interactive command processor (bf_command).
* CMD_CRIT = print error
* CMD_FATAL = panic

Also fix minor style(9) issues with command_load return codes.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-13 18:33:12 +00:00
Steven Hartland
1b383bfca2 Fix typo in libefi.c
Fix a typo in libefl.c (removal or L) introduced by r293724

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-13 00:37:28 +00:00
Ian Lepore
d45f99dee1 Go back to using uintptr_t, because code that actually compiles is
infinitely less buggy than code that is theoretically correct in some
alternate universe.

The uintfptr_t type is apparently a freebsd invention, and exists only when
compiling the kernel.  It's a little hard to say for sure, since it doesn't
seem to be documented anywhere except in email advice to unsuspecting and
overly-trusting souls, who then get to wear the pointy hat for blindly
following advice without investigating or testing it first.
2016-01-13 00:22:12 +00:00
Ian Lepore
c1f892e0d1 Cast using uintfptr_t and eliminate the cast to uint64_t which is uneeded
because rounding down cannot increase the number of bits needed to express
the result.

I had no idea there was such a thing as uintfptr_t.

Requested by: bde
2016-01-12 16:31:07 +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
Allan Jude
076b613091 DIOCGSECTORSIZE expects to write to a u_int, but struct zfs_probe_args
member secsz was a uint16_t

sys/boot/zfs/zfs.c has a probe args structure member, secsz, that is a
uint16_t for media sector size; it is used as an argument for ioctl()
at line 484. however, this ioctl writes 32 bits of data (u_int *) and
therefore this ioctl will overwrite and corrupt 16 bits of memory.
other use cases seem to use correct u_int type for secsz.

PR:		204358
Submitted by:	Toomas Soome <tsoome at me.com>
Reviewed by:	asomers, delphij, smh
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D4811
2016-01-11 15:35:29 +00:00
Allan Jude
d036e72f4b Return call to init_zfs_bootenv to its previous location
When called to early, new_currdev->d_type was not yet set
zfs_fmtdev() would then return null

While here, guard call to init_zfs_bootenv with if d_type == DEVT_ZFS

Reported by:	tsoome at me.com
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-09 19:13:25 +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
Allan Jude
fce8d0e350 Only call init_zfs_bootenv() when the system was booted with ZFS
Add a few other safeguards to ensure things do not break when the
boot device cannot be determined

Reported by:	flo
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-09 00:54:08 +00:00
Bryan Drewery
eefa1c373f Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-01-09 00:43:11 +00:00
Ed Maste
873e5b5e14 Reduce libstand Makefile duplication
Userboot's copy of the libstand Makefile had more extensive changes
compared to the one in sys/boot/libstand32, but it turns out these are
not intentional and we can just include lib/libstand/Makefile as done
for libstand32 in r293040.

Reviewed by:	imp, jhb
Tested by:	allanjude
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4793
2016-01-08 19:12:26 +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
Allan Jude
adff67c988 Add support for ZFS Boot Environments to userboot (for bhyve and others)
While here, also fix a possible null pointer

Reported by:	lattera
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-08 05:09:55 +00:00
Bryan Drewery
e3ebb82118 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-01-07 19:58:23 +00:00
Bryan Drewery
25e85b1fbc Don't install /usr/include/stand.h twice after r293040.
Only install it from lib/libstand.

Sponsored by:	EMC / Isilon Storage Division
2016-01-07 19:19:23 +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
Steven Hartland
5d07d143e6 Fix return from zfs_probe_dev
Ensure zfs_probe_dev returns the correct value.

Also fix a style(9) trailing whitespace issue while here.

MFC after:	2 weeks
X-MFC-With:	r293268
Sponsored by:	Multiplay
2016-01-06 20:25:41 +00:00
Steven Hartland
d446abfaec Fix _MSC_EXTENSIONS checks
Use #ifdef instead of #if checks to prevent warnings generated by checks
to be enabled shortly.

MFC after:	2 weeks
Sponsored by:	Multiplay
2016-01-06 20:22:28 +00:00
Ed Maste
f548a62da9 loader.efi style(9) cleanup
Submitted by:	smh
2016-01-06 19:18:43 +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
353e5e6e30 Enable the beastie menu for the UEFI console
As of r293233 the UEFI console includes basic terminal emulator support.

MFC after:	2 weeks
Relnotes:	Yes
2016-01-06 15:50:21 +00:00
Ed Maste
a93236cfcc loader.efi: add terminal emulation support
This is based on the vidconsole implementation.

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	adrian
MFC after:	2 weeks
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D4797
2016-01-06 15:38:39 +00:00
Ed Maste
1d3b741492 loader.efi: support non-contiguous console modes
Submitted by:	Toomas Soome <tsoome@me.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D4760
2016-01-04 17:22:06 +00:00
Ian Lepore
24bbe7a40c Cast pointer through uintptr_t on the way to uint64_t to squelch a warning. 2016-01-02 22:55:59 +00:00
Ian Lepore
577353fcbf Use 64-bit math when finding a block of ram to hold the kernel. This fixes
a problem on 32-bit systems which have ram occupying the end of the physical
address space -- for example, a block of ram at 0x80000000 with a size of
0x80000000 was overflowing 32 bit math and ending up with a calculated size
of zero.

This is a fix for one of the two problems mentioned in the PR.  Something
similar will need to be done on the kernel side before the PR is closed.

PR:		201614
2016-01-02 18:16:24 +00:00
Ian Lepore
3110868268 Revert accidental change that snuck into r293045. 2016-01-02 03:00:31 +00:00
Ian Lepore
69dcb7e771 Make the 'env' directive described in config(5) work on all architectures,
providing compiled-in static environment data that is used instead of any
data passed in from a boot loader.

Previously 'env' worked only on i386 and arm xscale systems, because it
required the MD startup code to examine the global envmode variable and
decide whether to use static_env or an environment obtained from the boot
loader, and set the global kern_envp accordingly.  Most startup code wasn't
doing so.  Making things even more complex, some mips startup code uses an
alternate scheme that involves calling init_static_kenv() to pass an empty
buffer and its size, then uses a series of kern_setenv() calls to populate
that buffer.

Now all MD startup code calls init_static_kenv(), and that routine provides
a single point where envmode is checked and the decision is made whether to
use the compiled-in static_kenv or the values provided by the MD code.

The routine also continues to serve its original purpose for mips; if a
non-zero buffer size is passed the routine installs the empty buffer ready
to accept kern_setenv() values.  Now if the size is zero, the provided buffer
full of existing env data is installed.  A NULL pointer can be passed if the
boot loader provides no env data; this allows the static env to be installed
if envmode is set to do so.

Most of the work here is a near-mechanical change to call the init function
instead of directly setting kern_envp.  A notable exception is in xen/pv.c;
that code was originally installing a buffer full of preformatted env data
along with its non-zero size (like mips code does), which would have allowed
kern_setenv() calls to wipe out the preformatted data.  Now it passes a zero
for the size so that the buffer of data it installs is treated as
non-writeable.
2016-01-02 02:53:48 +00:00
Ed Maste
9ed9d9bc3c Reduce libstand Makefile duplication
libstand is built in three places (lib/libstand, sys/boot/libstand32,
and sys/boot/userboot/libstand). Reduce Makefile duplication by
.including libstand/Makefile from sys/boot/libstand32/Makefile.

sys/boot/userboot/libstand/Makefile will be addressed later, as it
contains additional differences yet to be handled.

This change also switches libstand32 to use the new uuid_from_string
and uuid_to_string, which was not included in r292473.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4747
2016-01-01 15:30:11 +00:00
Allan Jude
f1aba489c1 Introduce the ZFS Boot Environments menu to the loader menu
If the system was booted with ZFS, a new menu item (#7) appears
It contains an autogenerated list of ZFS Boot Environments

This allows the user to switch to an alternate root file system
Use Cases:
 - Revert a failed upgrade
 - Concurrently run different versions of FreeBSD with common home directory
 - Easier integration with the sysadmin/beadm utility

Requested by:	many
Reviewed by:	dteske
MFC after:	10 days
Relnotes:	yes
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D3167
2015-12-31 20:00:53 +00:00
Devin Teske
29a46b5320 Remove supposition comment that code would better live elsewhere.
Thinking this through, and looking at process_assignment, I believe
moving the code would be wrong considering that set_conf_files is
called in one condition while set_nextboot_conf is guarded by a
different condition of having nextboot_enable="YES". So these must
stay separated and not combined.

MFC after:	1 week
2015-12-31 19:37:14 +00:00
Devin Teske
40c94e0168 Fix a memory leak. nextboot_conf_file is not volatile, as far as I
can tell, and thus the strdup is entirely unnecessary.

Thanks to:	Toomas Soome (tsoome at-me dot-com)
MFC after:	1 week
2015-12-31 19:33:17 +00:00
Devin Teske
7e0feeac69 Remove debugging messages. NB: SVN r187143 reads:
comment out some debugging messages that slipped in by mistake
(removing them 7 years after they have been commented out)

MFC after:	1 week
2015-12-31 19:00:45 +00:00
Devin Teske
3461218b15 Fix stack leak introduced by SVN r97201 (nextboot_conf support).
Fix erroneous error path in error messages when processing boot_conf.
Fixup stack comments for functions introduced by SVN r97201.
Remove a questioning stack comment introduced by SVN r186789.
NB: Comment removed because strdup usage here is correct/not a leak.

MFC after:	1 week
2015-12-30 02:15:12 +00:00
Ian Lepore
b8466276a1 Fix the error checking for the ubenv command. This moves the check for an
empty ldvar (which amounts to the varname string starting with '=') into
the if block that manipulates ldvar, which avoids later referencing ldvar
when it was never initialized.

Submitted by:	Thomas Skibo
Pointy hat:	ian
2015-12-29 21:29:05 +00:00
John Baldwin
9beae9a046 Fix remaining direct tests of the carry flag in the v86 %eflags via a
magic number to use V86_CY() instead.  These should have been fixed as
part of the cleanup in r226746 but were missed.

The md5 sums of the object files were unchanged, so there should be no
functional change.

PR:		205424
Submitted by:	Alexander Kuleshov <kuleshovmail@gmail.com>
MFC after:	1 week
2015-12-24 06:22:41 +00:00
Ed Maste
7ebeabcf9b Revert accidental whitespace changes included with r292623 2015-12-22 20:40:34 +00:00
Ed Maste
6ee0db8b76 Support a.out format in nlist only on i386
i386 is the only current FreeBSD architecture that ever used a.out
format.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4687
2015-12-22 20:36:14 +00:00
Ian Lepore
21fddb1173 Set env vars from values on the efi loader command line.
Examine each cmdline arg and if it contains an '=' convert it to ascii and
pass it to putenv(). This allows var=value settings to come in on the
command line.

This will allow overriding dhcp server-provided data in loader(8), as
discussed in PR 202098

PR:		202098
Differential Revision:	https://reviews.freebsd.org/D4561
2015-12-22 03:07:38 +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
Ed Maste
2dfc9e2cd4 loader.efi: strip trailing whitespace
Sponsored by:	The FreeBSD Foundation
2015-12-21 19:56:11 +00:00
Ian Lepore
ebe8a6e100 Add strlcat() and strlcpy() to libstand32. This should have been part of
r292234, but I forgot there was a libstand32.

Submitted by:	martymac
Pointy hat:	ian
2015-12-21 02:02:43 +00:00
Ed Maste
09e4ee9af3 loader.efi: refresh size in GetMemoryMap retry loop
If ExitBootServices fails due to a changed efi_mapkey then GetMemoryMap
must be called again. In this case it is also possible for the memory
map to grow, so repeat the initial GetMemoryMap call to fetch the new
size.

Also roll bi_add_efi_data_and_exit into bi_load_efi_data as there's no
need for it to be a separate function.

PR:		202455
Reported by:	Berislav Purgar <bpurgar@gmail.com>
Tested by:	Berislav Purgar <bpurgar@gmail.com>
Reviewed by:	kib
MFC after:	1 week
MFC with:	r292338
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4621
2015-12-20 16:07:09 +00:00
Enji Cooper
ee898967d0 Add missing smbios.h #include to mute a -Wimplicit-function-declaration warning
after r279222

Reported by: Jenkins
Sponsored by: EMC / Isilon Storage Division
2015-12-20 02:46:51 +00:00
Warner Losh
7a80f343f3 Pass the UEFI system table into the kernel from the boot loader via
the FW_HANDLE metadata item. The kernel can get the rest of what it
needs from this.
2015-12-19 19:01:42 +00:00
Ed Maste
2351669e6d loader.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-18 17:39:54 +00:00
Baptiste Daroussin
35fad84fec Use human readable representation of ip for the pxeboot.ip kenv
While here use colon as a separator for pxeboot.hwaddr kenv

Sponsored by:	Gandi.net
2015-12-16 17:45:03 +00:00
Baptiste Daroussin
4d6ab32f99 pxeboot: make the tftp loader use the option root-path directive
pxeboot in tftp loader mode (when built with LOADER_TFTP_SUPPORT) now
prefix all the path to open with the path obtained via the option 'root-path'
directive.

This allows to be able to use the traditional content /boot out of box. Meaning
it now works pretty much like all other loaders. It simplifies hosting hosting
multiple version of FreeBSD on a tftp server.

As a consequence, pxeboot does not look anymore for a pxeboot.4th (which was
never provided)

Note: that pxeboot in tftp loader mode is not built by default.

Reviewed by:	rpokala
Relnotes:	yes
Sponsored by:	Gandi.net
Differential Revision:	https://reviews.freebsd.org/D4590
2015-12-16 17:13:09 +00:00
Ed Maste
54f97d1eef UEFI: combine GetMemoryMap and ExitBootServices and retry on error
The EFI memory map may change before or during the first
ExitBootServices call. In that case ExitBootServices returns an error,
and GetMemoryMap and ExitBootServices must be retried.

Glue together calls to GetMemoryMap(), ExitBootServices() and storage of
(now up-to-date) MODINFOMD_EFI_MAP metadata within a single function.

That new function - bi_add_efi_data_and_exit() - uses space previously
allocated in bi_load_efi_data() to store the memory map (it will fail if
that space is too short). It handles re-calling GetMemoryMap() once to
update the map key if necessary. Finally, if ExitBootServices() is
successful, it stores the memory map and its header as MODINFOMD_EFI_MAP
metadata.

ExitBootServices() calls are now done earlier, from within arch-
independent bi_load() code.

PR:		202455
Submitted by:	Ganael LAPLANCHE
Reviewed by:	kib
MFC after:	2 weeks
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D4296
2015-12-16 16:19:18 +00:00
Ian Lepore
36f17e5176 Enhance the "ubenv import" command to allow importing a u-boot env var
directly into a loader (and thus kernel) env var, using the syntax

  ubenv import ldvarname=ubvarname

Without the varname= prefix it uses the historical behavior of importing
to the name uboot.ubvarname.
2015-12-14 22:00:46 +00:00
Andrey V. Elsukov
af90a87209 Make detection of GPT a bit more reliable.
When we are detecting a partition table and didn't find PMBR, try to
read backup GPT header from the last sector and if it is correct,
assume that we have GPT.

Reviewed by:	rpokala
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D4282
2015-12-10 10:35:07 +00:00
Bryan Drewery
b2fe867a0f DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2015-12-07 23:53:01 +00:00
Enji Cooper
f23ba0f0e9 Remove stray unescaped % in Booting from ... informational message
PR: 204944
MFC after: 1 week
X-MFC with: r291164
Reported by: David Binderman <dcb314@hotmail.com>
Sponsored by: EMC / Isilon Storage Division
2015-12-05 23:59:30 +00:00
Ganbold Tsagaankhuu
f4459b9645 Add glue driver for Amlogic Meson Gigabit Ethernet Controller
and enable it for Odroid C1 board.
Together with r291676 change, dwc(4) can receive packets now.
2015-12-03 09:37:20 +00:00
Nathan Whitehorn
87008d7b77 Clean up PowerPC bootloader compiler flags to fix the build with GCC 5.2
and binutils 2.25.
2015-12-03 00:08:50 +00:00
Nathan Whitehorn
b931a53849 Allow loader to load 64-bit ELFv2 PowerPC kernels. 2015-12-01 17:01:27 +00:00