Commit Graph

3519 Commits

Author SHA1 Message Date
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
Ruslan Bukin
98f50c44e3 Update RISC-V port to Privileged Architecture Version 1.9.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-08-02 14:50:14 +00:00
Allan Jude
4deb8929ea Make boot code and loader check for unsupported ZFS feature flags
OpenZFS uses feature flags instead of a zpool version number to track
features since the split from Oracle. In addition to avoiding confusion
on ZFS vs OpenZFS version numbers, this also allows features to be added
to different operating systems that use OpenZFS in different order.

The previous zfs boot code (gptzfsboot) and loader (zfsloader) blindly
tries to read the pool, and if failed provided only a vague error message.

With this change, both the boot code and loader check the MOS features
list in the ZFS label and compare it against the list of features that
the loader supports. If any unsupported feature is active, the pool is
not considered as a candidate for booting, and a helpful diagnostic
message is printed to the screen. Features that are merely enabled via
zpool upgrade, but not in use, do not block booting from the pool.

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	delphij, mav
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6857
2016-08-01 19:37:43 +00:00
Allan Jude
aafbb33897 Improve boot loader quote parsing
parse() is the boot loader's interp_parse.c is too naive about quotes

both single and double quotes were allowed to be mixed, and single
quotes did not follow the usual semantics (re variable expansion).

The old code did not check for terminating quotes

This update implements:
 * distinguishing single and double quote
 * variable expansion will not be done inside single quote protected area
 * will preserve inner quote for values like "value 'some list'"
 * ending quote check.

this diff does not implement ending quote order check, it shouldn't
be too hard, needs some improvements on parser state machine.

PR:		204602
Submitted by:	Toomas Soome <tsoome@me.com>
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6000
2016-07-30 17:53:37 +00:00
Allan Jude
6bf8d16009 bcache should support reads shorter than sector size
dosfs (fat file systems) can perform reads of partial sectors
bcache should support such reads.

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D6475
2016-07-30 17:45:56 +00:00
Emmanuel Vadot
ddda1a9c2f Do not use TERM_EMU on arm and arm64 as it doesn't behave well with serial console.
Reviewed by:	andrew, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6783
2016-07-19 19:00:22 +00:00
Mark Murray
a1acc06f4f Random bit generator (RBG) driver for RPi and RPi2.
Summary:
This driver supports the following methods to trigger gathering random bits from the hardware:
1. interrupt when the FIFO is full (default) fed into the harvest queue
2. callout (when BCM2835_RNG_USE_CALLOUT is defined) every second if hz is less than 100, otherwise hz / 100, feeding the random bits into the harvest queue

If the kernel is booted with verbose enabled, the contents of the registers will be dumped after the RBG is started during the attach routine.

Author: hackagadget_gmail.com (Stephen J. Kiernan)

Test Plan: Built RPI2 kernel and booted on board. Tested the different methods to feed the harvest queue (callout, interrupt) and the interrupt driven approach seems best. However, keeping the other method for people to be able to experiment with.

Reviewed By: adrian, delphij, markm

Differential Revision: https://reviews.freebsd.org/D6888
2016-07-19 18:07:47 +00:00
Oleksandr Tymoshenko
3fd8559331 Remove extra 0x before %p format strings introduced by r296182 2016-07-08 22:32:03 +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
Nathan Whitehorn
5ecf8e3852 Clean up some FDT-related code in the PowerPC bootloader, improving error
checking and robustness. Prevents errors and crashes in FDT commands on
PowerMac G5 systems.

Approved by:	re (gjb)
2016-07-01 21:09:30 +00:00
Emmanuel Vadot
e40bf91460 Print a message when disks are found but no logical partition are
reported by EFI implementation. This address comment on r301714.

Approved by:	re (gjb), andrew (mentor)
Differential Revision:	https://reviews.freebsd.org/D6787
2016-06-17 17:09:22 +00:00
Andriy Gapon
dc87c22a61 fix a zfs boot regression introduced in r300117 by accident
There is no reason to return non-zero value from zfs_probe_partition()
as that causes following partitions to not be probed for ZFS vdevs.
A particular scenario that I encountered is a GPT partitioned disk
where several partitions have freebsd-zfs type.  A partition with a lower
index is used as a cache (l2arc) vdev and in that case case zfs_probe()
returned a non-zero status.  That status was returned to ptable_iterate()
and caused it to abort the iteration.  Because of that the subsequent
partitions were not probed and a root pool was not discovered resulting
in a boot failure.

While there fix the style for nearby return statements.

Approved by:	re (kib)
2016-06-16 07:45:57 +00:00
Emmanuel Vadot
e5aa06364f Add PCDuino3b dts. It uses the pcduino3 dts from upstream and adds the hdmi node, axp gpio and changes the phy mode to rgmii.
Approved by:	andrew (mentor)
Differential Revision:	https://reviews.freebsd.org/D6775
2016-06-09 17:10:19 +00:00
Emmanuel Vadot
e644b7c5a5 Print a message when the efi disk isn't a logical partition.
Approved by:	andrew (mentor)
Differential Revision:	https://reviews.freebsd.org/D6782
2016-06-09 02:02:50 +00:00
Andrew Turner
103dce1405 Also set -fshort-wchar on arm64, this fixes parsing strings from UEFI,
e.g. on the command line.

Sponsored by:	ABT Systems Ltd
2016-06-08 23:23:16 +00:00
Andrew Turner
aaad73f447 Print the newline character along with the carriage return when TERM_EMU is
disabled. Without this we print all lines over top of each other.

Sponsored by:	ABT Systems Ltd
2016-06-08 23:13:20 +00:00
Andrew Turner
9706d6ad89 Allow libefi to be built with TERM_EMU undefined. There were a few places
where we assumed TERM_EMU was defined but didn't check. Fix these by also
including them under the ifdefs.

As HO is called from loader we need a null implementation so loader.efi
doesn't need to know which version of libefi it is building against.

Sponsored by:	ABT Systems Ltd
2016-06-08 22:36:55 +00:00
Andrew Turner
d15667174d Use the UEFI event timer to update the time on arm and arm64. The current
code uses the GetTime function from the Runtime Service, however this has
been shown to not return a useable time on many arm64 UEFI implementations.

Reviewed by:	jhb, smh
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D6709
2016-06-04 08:47:45 +00:00
Zbigniew Bodek
c247b3ca67 Add support for CESA on Armada38x
Changes:
- added new SoC ID in CESA attach
- allowed crypto driver IDs other than 0
- added CESA nodes to Armada38x .dts files
- enabled required devices in kernconf

Submitted by:	Michal Stanek <mst@semihalf.com>
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6220
2016-06-02 18:41:33 +00:00
Zbigniew Bodek
22c7a03178 Split CESA memory resource into TDMA and CESA regs
TDMA and CESA registers are placed in different ranges of memory. Split
memory resource in DTS to reflect that. This change is needed to support
multiple CESA nodes as otherwise the ranges of different nodes would
overlap.

In consequence, CESA_WRITE and CESA_READ macros have been split depending
on which range of registers is accessed. Offsets for CESA registers have
been modified as the base address has changed.

Submitted by:	Michal Stanek <mst@semihalf.com>
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6217
2016-06-02 18:35:35 +00:00
Zbigniew Bodek
eb69f795f1 Revert part of r294418 ("Correct ranges...")
Commit was temporary fix due to rman_res_t defined as 32-bit u_long.
After redefining it as 64-bit variable workaround is not needed and
was removed.

Submitted by:	Bartosz Szczepanek <bsz@semihalf.com>
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6214
2016-06-02 18:24:00 +00:00
Enji Cooper
224a4bba59 Add missing libc includes to fix -Wimplicit-function-declaration warnings
MFC after: 2 weeks
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-31 06:24:09 +00:00
Doug Ambrisko
9c8f0619db If the I/O offset and length is multiple of the media size then
directly pass the request otherwise use a buffer that is a
multiple of the media size.  This speeds up I/O quite a bit
when using large transfer sizes on 4Kn disks etc.

MFC after:	1 week
2016-05-27 19:23:15 +00:00
John Baldwin
4e865d9eb0 Fix unit number of EFI net interfaces and ignore psuedo network interfaces.
In r277943, the efinet_match() routine was changed to use an off by one
when matching network interfaces.  The effect was that using "net1"
actually used the device attached to "net0".

Digging into the hardware that needed this workaround more, I found that
UEFI was creating two simple network protocol devices for each physical
NIC.  The first device was a "raw" Ethernet device and the second device
was a "IP" device that used the IP protocol on top of the underlying
"raw" device.  The PXE code in the firmware used the "IP" device to pull
across the loader.efi, so currdev was set to "net1" when booting from the
physical interface "net0".  (The loaded image's device handle referenced
the "IP" device that "net1" claimed.)

However, the IP device isn't suitable for doing raw packet I/O (and the
current code to open devices exclusively actually turns the "IP" devices
off on these systems).

To fix, change the efinet driver to only attach to "raw" devices.  This
is determined by fetching the DEVICE_PATH for each handle which supports
the simple network protocol and examining the last node in the path.  If
the last node in the path is a MAC address, the device is assumed to be
a "raw" device and is added as a 'netX' device.  If the last node is not
a MAC address, the device is ignored.

However, this causes a new problem as the device handle associated with
the loaded image no longer matches any of the handles enumerated by
efinet for systems that load the image via the "IP" device.  To handle
this case, expand the logic that resolves currdev from the loaded image
in main().  First, the existing logic of looking for a handle that
matches the loaded image's handle is tried.  If that fails, the device
path of the handle that loaded the loaded image is fetched via
efi_lookup_image_devpath().  This device path is then walked from the
end up to the beginning using efi_handle_lookup() to fetch the handle
associated with a path.  If the handle is found and is a known handle,
then that is used as currdev.  The effect for machines that load the
image via the "IP" device is that the first lookup fails (the handle
for the "IP" device isn't claimed by efinet), but walking up the
image's device path finds the handle of the raw MAC device which is used
as currdev.

With these fixes in place, the hack to subtract 1 from the unit can now
be removed, so that setting currdev to 'net0' actually uses 'net0'.

PR:		202097
Tested by:	ambrisko
Sponsored by:	Cisco Systems
2016-05-26 23:32:28 +00:00
John Baldwin
8f7ada2196 Use a unique error message if we fail to find the simple network protocol.
While here, fix the various net driver callbacks to return early instead
of crashing if this fails.  (The 'init' callback from the netif interface
doesn't return an error if the protocol lookup fails.)

Sponsored by:	Cisco Systems
2016-05-26 23:08:57 +00:00
John Baldwin
72bc6425a9 Apply the printf %S band-aid for efinet.c to fix the arm64 build. 2016-05-26 23:07:20 +00:00
John Baldwin
b4f9242404 Remove second copy of the -Wno-format band-aid for printf %S. 2016-05-26 23:06:36 +00:00
John Baldwin
e06f8144fb Use routines from the recently added devpath.c.
These efipart layer did several devpath related operations inline.  This
just switches it over to using shared code for working with device paths.

Sponsored by:	Cisco Systems
2016-05-26 22:13:40 +00:00
John Baldwin
79ad8397ea Output the device path description for EFI network devices.
Lookup the DEVICE_PATH for each EFI network device handle and output the
string description using printf with '%S'.  To honor the pager, the newline
at the end of each line is still output with pager_output().

Sponsored by:	Cisco Systems
2016-05-26 21:48:39 +00:00
John Baldwin
3e5a19be71 Add some routines for working with EFI DEVICE_PATH objects.
- efi_lookup_devpath() uses the DEVICE_PATH_PROTOCOL to obtain the
  DEVICE_PATH for a given EFI handle.
- efi_lookup_image_devpath() uses the LOADED_IMAGE_DEVICE_PATH_PROTOCOL
  to lookup the device path of the device used to load a loaded image.
- efi_devpath_name() uses the DEVICE_PATH_TO_TEXT_PROTOCOL to generate
  a string description of a device path.  The returned string is a CHAR16
  string that can be printed via the recently added '%S' format in
  libstand's printf().  Note that the returned string is returned in
  allocated storage that should be freed by calling
  efi_free_devpath_name().
- efi_devpath_last_node() walks a DEVICE_PATH returning a pointer to the
  final node in the path (not counting the terminating node).  That is,
  it returns a pointer to the last meaninful node in a DEVICE_PATH.
- efi_devpath_trim() generates a new DEVICE_PATH from an existing
  DEVICE_PATH.  The new DEVICE_PATH does not include the last
  non-terminating node in the original path.  If the original DEVICE_PATH
  only contains the terminating node, this function returns NULL.
  The caller is responsible for freeing the returned DEVICE_PATH via
  free().
- efi_devpath_handle() attempts to find a handle that corresponds to a
  given device path.  However, if nodes at the end of the device path do
  not have valid handles associated with them, this function will return
  a handle that matches a node earlier in the device path.  In particular,
  this function returns a handle for the node closest to the end of the
  device path which has a valid handle.

Sponsored by:	Cisco Systems
2016-05-26 21:43:22 +00:00
Emmanuel Vadot
30068a1de9 Add support for interrupts, sensors and GPIO for AXP209 PMIC.
Pressing the PEK (power enable key) will shutdown the board.
Some events are reported to devd via system "PMU" and subsystem
"Battery", "AC" and "USB" such as connected/disconnected.
Some sensors values (power source voltage/current) are reported via
sysctl (dev.axp209_pmu.X.)
It also expose a gpioc node usable in kernel and userland. Only 3 of
the 4 GPIO are exposed (The GPIO3 is different and mostly unused on
boards). Most popular boards uses GPIO1 as a sense pin for OTG power.
Add a dtsi file that adds gpio-controller capability to the device as
upstream doesn't defined it and include it in our custom DTS.

Reviewed by:	jmcneill
Approved by:	cognet (mentor)
Differential Revision:	https://reviews.freebsd.org/D6135
2016-05-26 21:09:07 +00:00
Conrad Meyer
241adf4455 efi loader: Match format string to EFI_ERROR_CODE()
Silence a format specifier warning.

Sponsored by:	EMC / Isilon Storage Division
2016-05-25 00:13:01 +00:00
Warner Losh
a00ef24037 Large improvements to efi-show (though some weird problems
linger). We now print only printable characters for the
values and we print ascii strings as strings.
2016-05-20 19:38:01 +00:00
Warner Losh
d52a88fe7c Implement efi-set and efi-unset 2016-05-20 19:37:54 +00:00
Warner Losh
8f190a8c0e Cleanup to use %S. 2016-05-20 19:37:46 +00:00
Allan Jude
02fd555670 Fixup the geliboot sector rounding code
Replace all rounding with the round{up,down}2 macros
a missing set of braces caused the previous code to be incorrect

replace alloca() with malloc() because alloca() can return an allocation
that is actually invalid, causing boot to fail

Reviewed by:	emaste, ed
Thanks To:	peter
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D6213
2016-05-20 01:41:47 +00:00
Oleksandr Tymoshenko
05eb95f283 Fixed memory leak in FDT overlay handling code
Free both overlay and new fdt before returning after fdt_open_into error
PR:		209634
Submitted by:	David Binderman
2016-05-19 20:51:47 +00:00
Warner Losh
da5d9ec2ac Fix logic error so UEFI variables are reported correctly
without error at the end.
2016-05-19 16:36:06 +00:00
Warner Losh
19831537a9 Fix typo.
Spotted by: Matteo Riondato
2016-05-18 15:57:13 +00:00
Pedro F. Giffuni
416970ad85 Minor spelling fixes. 2016-05-18 15:18:18 +00:00
Warner Losh
e530e62312 Also add comment about the bug I comments in the forth. 2016-05-18 14:09:56 +00:00
Warner Losh
9a0b26ec6f Fix several instances where the boot loader ignored pager_output
return value when it could return 1 (indicating we should stop).
Fix a few instances of pager_open() / pager_close() not being called.
Actually use these routines for the environment variable printing code
I just committed.
2016-05-18 05:59:05 +00:00
Warner Losh
4a619be4bb Fix build breakage on arm64 by papering over the problem. We implement
a slightly non-standard %S that's more useful in the UEFI environment,
so ignore printf errors. There's no good cast to use. We'll need to
revisit this in the future.
2016-05-18 05:58:58 +00:00
Warner Losh
0f897f87b9 Explain why extra sutff always outputs even when it shouldn't for the
'?' command. Wasted a bunch of time tracking it down tonight.
2016-05-18 05:58:57 +00:00
Warner Losh
53ff4bbc05 Implement UEFI set environment variable, as well as exporting the EFI
version. This is also scriptable, though additional scripting will be
needed.

Differential Review: https://reviews.freebsd.org/D4494
MFC After: 3 days
2016-05-17 21:25:20 +00:00
Warner Losh
d437521495 Implement uuid-to-string and uuid-from-string. uuid-from-string takes
a string, interprets it as a standard UUID, and returns a binary from
of the UUID. uuid-to-string does the reverse. The binary UUID is in
allocated memory, so you'll need to free it with 'free' after you are
done using it. It won't be automatically garbage collected. Likewise
with the string...

MFC After: 3 days
2016-05-17 21:25:18 +00:00
John Baldwin
23f765d0c8 Remove the reiserfs(5) manpage and an example of loading the kernel module. 2016-05-17 18:42:38 +00:00
Warner Losh
d4d32e5899 It sure would be nice to use printf with wide strings. Implement %S to
do that. The C_WIDEOUT flag indicates that the console supports
it. Mark the EFI console as supporting this.

MFC After: 3 days
2016-05-17 14:10:45 +00:00
Warner Losh
c205f958b4 Minor space tweak to make things consistent.
MFC After: 3 days
2016-05-17 14:10:44 +00:00
Stanislav Galabov
32f8bbf8cd Add proper PCIe init for MT7628/MT7688 SoCs
PCIe PHY needs different initialization on MT7628/MT7688 SoCs than it does
on MT7620.
However, LEDE (and OpenWRT) dts files have the PCIe node for MT7628/MT7688
as compatible with mt7620-pci.
We already can handle this properly in our driver, so we just need to add
compat strings to fbsd-mt7628an.dtsi and the PCIe driver.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6395
2016-05-17 06:45:25 +00:00
Stanislav Galabov
179f14534e Import LEDE dts files for Ralink/Mediatek
This is an import of the reworked LEDE dts files. Besides other things
they make it easier for us to reuse.

The only diffs left are for the following SoCs:
MT7620A (fbsd-mt7620a.dtsi)
MT7621 (fbsd-mt7621.dtsi)
MT7628 (fbsd-mt7628an.dtsi)
RT3883 (fbsd-rt3883.dtsi)

So we include the fbsd-*.dtsi files at the end of the original LEDE dtsi
files, using '#include "fbsd-xxxx.dtsi"'.
For example, for MT7621, the LEDE dtsi file is mt7621.dtsi. At the end of
it we add:
#include "fbsd-mt7621.dtsi"

Approved by:	adrian (mentor)
Obtained from:	LEDE project
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6394
2016-05-17 06:42:24 +00:00
Peter Wemm
40f58305bb Attempt to fix r299660:
slba is used only for the GPT case.
elba is used if either GPT or LOADER_GELI_SUPPORT is enabled.
2016-05-17 00:24:53 +00:00
Pedro F. Giffuni
98b6ade62d libefi: Tag an unreachable switch default.
Coverity reports an uninitialized "len" in case the switch defaults
without hitting any case. Respect the original intent and quell the
false positive with the relatively new __unreachable() builtin.

CID:	1347796
2016-05-16 20:00:09 +00:00
Jared McNeill
343044c43b Add Allwinner A83T thermal sensor controller support.
The A83T thermal sensor controller has three sensors. Sensor 0 corresponds
to CPU cluster 0, sensor 1 to CPU cluster 1, and sensor 2 to the GPU. This
driver exports the temperature sensor readings via sysctl.

Calibration data is obtained from SRAM found in the Secure ID module.

Reviewed by:		manu
Differential Revision:	https://reviews.freebsd.org/D6378
2016-05-15 22:36:55 +00:00
Jared McNeill
792492eee3 Enable SATA power regulator at boot on Sinovoip BananaPi BPI-M3. 2016-05-15 17:25:31 +00:00
Jared McNeill
4e760f013d Add gpio-leds for Sinovoip BananaPi BPI-M3.
The green LED on the board is wired to AXP813 GPIO0 and the blue
LED is wired to AXP813 GPIO1.
2016-05-15 15:56:48 +00:00
Jared McNeill
292e26ba55 Add pmic (AXP813) child node to r_rsb for Sinovoip BananaPi BPI-M3. 2016-05-14 23:36:00 +00:00
Jared McNeill
472c6f0685 Add node for A83T NMI interrupt controller. 2016-05-14 23:22:52 +00:00
Jared McNeill
f4f53c0a5a Add DTS files for the Allwinner A83T SoC and the Sinovoip BananaPi BPI-M3
development board.
2016-05-14 18:47:36 +00:00
Enji Cooper
e20f435517 Fix a -Wformat warning by using %d, not %ld for md_iterations
md_iterations is int32_t, not long.

Reported by: clang
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-13 11:27:49 +00:00
Enji Cooper
e108b91da7 Add geliboot_crypt(..) definition to geliboot.h to mute a -Wimplicit-function-declaration
warning

Reported by: clang
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-13 11:24:55 +00:00
Enji Cooper
3f9bee9c5a Put slba and elba under LOADER_GELI_SUPPORT ifdef to mute warning about them being
unused in the non-GELI case

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-13 11:20:21 +00:00
Enji Cooper
6af558669b Remove unused const variable
MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-13 11:18:29 +00:00
Enji Cooper
6743ceefaa Add missing prototype for getchar(..)
MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-13 10:59:46 +00:00
Pedro F. Giffuni
3e17f981b0 sys/boot/common: use of spaces vs. TAB.
No functional change.
2016-05-12 01:19:11 +00:00
Conrad Meyer
3d5b6ffbf8 efipart: Support an arbitrary number of partitions
Don't crash if the user has more than 31 of them.  A follow-up to
r298230.

Reviewed by:	allanjude
Relnotes:	maybe
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6212
2016-05-05 00:07:08 +00:00
Peter Wemm
d8818fce69 Change a rounding operation that had missing braces into a roundup2()
macro.  Adjust the buffer clipping code to work as expected.

This prevented a number of machines in the FreeBSD.org cluster from
booting due to "ZFS: i/o error - all block copies unavailable"
after an unclean shutdown.
2016-05-03 00:09:13 +00:00
Allan Jude
ffd50bca7e bcache read ahead may attempt to read past end of disk
The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache.

This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	jhb, np
Differential Revision:	https://reviews.freebsd.org/D6109
2016-05-01 21:06:59 +00:00
Pedro F. Giffuni
88ebc8558f boot/forth: spelling fixes.
Reviewed by: dteske
MFC after: 2 weeks
2016-04-30 02:47:41 +00:00
Pedro F. Giffuni
5d708ee940 sys/boot: spelling fixes in comments.
No functional change.
2016-04-30 00:26:38 +00:00
Oleksandr Tymoshenko
26f47fdd8f Add FDT overlays support to ubldr
FDT overlays is de-facto standard for describing expansion boards like
Beaglebone capes or Raspberry Pi shields. The ides is to have basic
DTB for base board and overlays DTB for shields/capes and to construct
final DTB either using human-readable configuration or some
self-discovery mechanism. I believe this approach can also be expanded
to support dynamically loadable FPGA bitstreams on systems like
Zedboard/Zybo.

Overlaying process is simmilar to executable link process for
binaries: each DTB has "exported" symbols and "undefined" symbols, the
latter are resolved using information for the former obtained from
base DTB or one of the overlays applied earlier (more rare case).

This symbols information is not generated by standard dtc that FreeBSD
has in base system, patched[1] version required to produces
overlay-compatible blobs. So although DTB files generated by
buildkernel do not support overlays there are enough
vendor/community-provided DTB blobs ciruclating around to justify
committing this change to ubldr.

This commit introduces handler for "fdt_overlays" variable that can be
defined either as a loader env variable or U-Boot env variable.
fdt_overlays is comma-separated list of .dtbo files located in
/boot/dtb/ directory along with base .dtb. ubldr loads files and
applies them one-by-one to base .dtb and then passes result blob to
the kernel.

[1] dd6a0533e8

Differential Revision:	https://reviews.freebsd.org/D3180
2016-04-29 22:42:59 +00:00
Oleksandr Tymoshenko
349ef43de4 Refactor DTS files for Zynq-based SoCs
- Factor out common part to zynq-7000.dtsi
- Fix problem with Zynq interrupts by using interrupt "triples"
    in .dtsi file to differentiate between edge-triggered and
    level-triggered interrupts
- cgem driver now recognizes "status" property

Submitted by:	Thomas Skibo <thomasskibo@yahoo.com>
Differential Revision:	https://reviews.freebsd.org/D6095
2016-04-26 23:09:47 +00:00
Hans Petter Selasky
cc165fbf19 Build fix. Add howmany() and nitems() macros to bootloader kernel shim. 2016-04-26 15:41:31 +00:00
Hans Petter Selasky
b1660d8774 Add function needed for linking USB test application. 2016-04-26 15:33:53 +00:00
Pedro F. Giffuni
768f89e078 sys/boot: make use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 14:51:58 +00:00
Ruslan Bukin
3f8f5599a3 o Add device tree files and kernel configuration files
for RISC-V cpus synthesized on FPGA hardware.
o Include new files to the build.
2016-04-26 13:22:08 +00:00
Stanislav Galabov
90f24ff8df Reduce the FreeBSD specific DTS files for Mediatek/Ralink
The introduction of palmbus and previous work allows us to cut the
differences between FreeBSD and OpenWRT DTS files a bit further.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6043
2016-04-23 04:24:30 +00:00
Allan Jude
e495d6b3db Fix more pc98 build issues re: bcache change
Reported by:	bz, emaste
2016-04-22 16:20:58 +00:00
Pedro F. Giffuni
d9c9c81c08 sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code
and when the code has a high indentation level it was not really
advantageous to do the replacement.

This tries to strike a balance between readability using the macros
and flexibility of having the expressions, so not everything is
converted.
2016-04-21 19:57:40 +00:00
Jared McNeill
473bbf691b Replace the A20 kernel config with a generic ALLWINNER kernel config that
supports A20, A31, and A31S. Adds support for the BananaPi M2 (A31S) board.

Submitted by:		Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:		jmcneill
Differential Revision:	https://reviews.freebsd.org/D5580
2016-04-21 16:49:04 +00:00
Allan Jude
892bfb4bb2 Add more guards to disable GELIBOOT by defining LOADER_NO_GELI_SUPPORT
Reviewed by:	cem
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D6049
2016-04-21 16:32:48 +00:00
Stanislav Galabov
e3a1a618a3 Include resets and clocks properties for PCI in FreeBSD RT3883 dtsi file
This change is required so that RT3662/RT3883 PCI can function correctly

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6028
2016-04-20 14:31:01 +00:00
Pedro F. Giffuni
2464bbf05a sys/boot: use our nitems() macro when it is available through param.h.
No functional change, only trivial cases are done in this sweep,

Discussed in:	freebsd-current
2016-04-19 23:44:33 +00:00
Allan Jude
3db33b0a8c Link bcache into userboot.so, was not added in r298230
This should help speed up bhyve boots too

Reviewed by:	olivier
2016-04-19 20:56:45 +00:00
Allan Jude
cad5a2e468 Fix pc98 build error introduced in r298230
Submitted by:	Toomas Soome <tsoome@me.com>
Spotted by:	bz
Differential Revision:	https://reviews.freebsd.org/D6002
2016-04-19 15:46:21 +00:00
Allan Jude
87ed2b7f5a A new implementation of the loader block cache
The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy.
Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks.
Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device.
The cache also implements limited read-ahead to increase performance.
To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache.

Booting from a virtual CD over IPMI:
0ms latency, before: 27 second, after: 7 seconds
60ms latency, before: over 12 minutes, after: under 5 minutes.

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	delphij (previous version), emaste (previous version)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D4713
2016-04-18 23:09:22 +00:00
Stanislav Galabov
89f8f24077 Import Mediatek/Ralink dtsi patches against OpenWRT dtsi files
This revision suggests dtsi patches to be used with the original OpenWRT
dtsi files so we can re-use what has already been done in OpenWRT for the
Mediatek/Ralink SoCs.

The only thing that is required after importing this revision should be
the following:
1. Import OpenWRT dts/dtsi files into sys/gnu/dts/mips
2. Run the following script in sys/gnu/dts/mips:
for f in `ls [mr]t*.dtsi`; do
printf "\n#include <fbsd-$f>\n" > $f
done

This will apply our dtsi patches to OpenWRT's dtsi files and will allow us
to re-use dts/dtsi files for ~170 Mediatek/Ralink boards.

Currently our drivers are not 100% compatible with OpenWRT's dts files, but
they're compatible enough.
We can add more functionality in the future that would better leverage the
OpenWRT work as well.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5965
2016-04-15 15:36:09 +00:00
Warner Losh
bd3bce41db Deprecate using hints.acpi.0.rsdp to communicate the RSDP to the
system. This uses the hints mechnanism. This mostly works today
because when there's no static hints (the default), this value can be
fetched from the hint. When there is a static hints file, the hint
passed from the boot loader to the kernel is ignored, but for the BIOS
case we're able to find it anyway. However, with UEFI, the fallback
doesn't work, so we get a panic instead.

Switch to acpi.rsdp and use TUNABLE_ULONG_FETCH instead. Continue to
generate the old values to allow for transitions. In addition, fall
back to the old method if the new method isn't present.

Add comments about all this.

Differential Revision: https://reviews.freebsd.org/D5866
2016-04-14 04:59:51 +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
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Ian Lepore
62b10973b1 Align the start of the text segment to an 8-byte boundary. This fixes
alignment aborts in ubldr.bin for RPi that started happening with clang 3.8
(earlier clang apparently didn't generate strd instructions that trigger
the alignment fault).  The abort happened in ubldr.bin and not ubldr (elf
version) because the elf headers are 0xf4 bytes long, and stripping them
off left everything 4-byte aligned.

While here, also stop aligning the data segment to a page boundary, align
it to 8 bytes instead (aligning to a page just needlessly makes the file
bigger); pointed out by andrew@.
2016-04-09 19:09:06 +00:00
Konstantin Belousov
b715d9af68 Use the ABI-prescribed name for SHT_X86_64_UNWIND in the loader and
kernel linker, after the r297686.

Sponsored by:	The FreeBSD Foundation
2016-04-08 10:23:48 +00:00
Allan Jude
4b90244c21 GELIBoot should only prompt for the GELI passphrase if the provider has the G_ELI_FLAG_GELIBOOT set
PR:		208251
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D5870
2016-04-08 01:27:40 +00:00
Maxim Sobolev
88a8e56bbc Document vfs.root.mountfrom.
Reviewed by:	imp, wblock
Differential Revision:	https://reviews.freebsd.org/D5332
2016-04-08 00:24:21 +00:00
Allan Jude
f33ff2af70 Fix GELIBoot support for GELI sector size is > 512
Add support for 4k sector GELI encrypted partitions to the bootloader
This is the default created by the installer

Because the IV is different for each sector, and the XTS tweak carries forward you can not decrypt a partial sector if the starting offset is not 0

Make boot2 and the loader read in 4k aligned chunks

Reviewed by:	ed, oshogbo
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D5820
2016-04-06 23:21:44 +00:00
Jared McNeill
6a05f063ed Convert Allwinner port to extres clk/hwreset/regulator APIs.
Reviewed by:		andrew, gonzo, Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5752
2016-04-06 23:11:03 +00:00
Svatopluk Kraus
89de2fb6d4 Rework BCM283x gpio interrupt controller for INTRNG. It's used on RPI-B
and RPI2 where INTRNG is already enabled by default.

Differential Revision:	https://reviews.freebsd.org/D5810
2016-04-05 13:45:23 +00:00
Svatopluk Kraus
fa64321bba Define local-intc for BCM2836 platform (RPI2) and make BCM2835 intc
a child of it. This is done in conformity with Linux dts files and
as preparation for rework of BCM2836 interrupt controller for INTRNG.

Reviewed by:	gonzo
Differential Revision:	https://reviews.freebsd.org/D5807
2016-04-04 09:41:22 +00:00
Luiz Otavio O Souza
191004d586 Enable SPI1 on Beaglebone Black.
SPI1 was chosen because SPI0 shares the gpio pins with I2C1.

Sponsored by:	Rubicon Communications (Netgate)
2016-03-30 17:32:14 +00:00