Commit Graph

183 Commits

Author SHA1 Message Date
Toomas Soome
2c55d0903d Add SHA512, skein, large blocks support for loader zfs.
Updated sha512 from illumos.
Using skein from freebsd crypto tree.
Since loader itself is using 64MB memory for heap, updated zfsboot to
use same, and this also allows to support zfs large blocks.

Note, adding additional features does increate zfsboot code, therefore
this update does increase zfsboot code to 128k, also I have ported gptldr.S
update to zfsldr.S to support 64k+ code.

With this update, boot1.efi has almost reached the current limit of the size
set for it, so one of the future patches for boot1.efi will need to
increase the limit.

Currently known missing zfs features in boot loader are edonr and gzip support.

Reviewed by:	delphij, imp
Approved by:	imp (mentor)
Obtained from:	sha256.c update and skein_zfs.c stub from illumos.
Differential Revision:	https://reviews.freebsd.org/D7418
2016-08-18 00:37:07 +00:00
John Baldwin
0e4c843ab4 Add defines needed to export SMBIOS serial numbers
Some defines needed for exporting serial numbers from the SMBIOS were
missed during integration of SMBIOS support in the EFI boot loader (r281138).
This is needed for getting the hostid set from the system hardware UUID.

PR:		206031
Submitted by:	Thomas Eberhardt <sneakywumpus@gmail.com>
MFC after:	1 week
2016-08-12 19:47:20 +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
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
b4f9242404 Remove second copy of the -Wno-format band-aid for printf %S. 2016-05-26 23:06:36 +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
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
Pedro F. Giffuni
416970ad85 Minor spelling fixes. 2016-05-18 15:18:18 +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
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
Pedro F. Giffuni
5d708ee940 sys/boot: spelling fixes in comments.
No functional change.
2016-04-30 00:26:38 +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
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
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
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
Bryan Drewery
a09f4b4d12 Add more .NOMETA missed in r291320
Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:45:51 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Andrew Turner
f4cd39e3b2 Add a missing call to dev_cleanup from the arm64 loader.efi.
Sponsored by:	ABT Systems Ltd
2016-02-20 17:29:04 +00:00
Andrew Turner
aeffd7b7ea Ensure the bss is aligned to a 4-byte address as we use 4-byte aligned
stores to clear it.

While here reduce the alignment of the data from 4k to 16 byte aligned.
This should be more than enough, without wasting too much space.

Sponsored by:	ABT Systems Ltd
2016-02-09 00:01:43 +00:00
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
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
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
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
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
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
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
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
2dfc9e2cd4 loader.efi: strip trailing whitespace
Sponsored by:	The FreeBSD Foundation
2015-12-21 19:56:11 +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
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
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
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
3e10dd1049 Use EFI page size constants instead of hardcoding 4096.
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D3692
2015-09-29 15:49:53 +00:00
John Baldwin
b2e38974e2 The EFI boot loader allocates a single chunk of contiguous memory to
hold the kernel, modules, and any other loaded data.  This memory block
is relocated to the kernel's expected location during the transfer of
control from the loader to the kernel.

The GENERIC kernel on amd64 has recently grown such that a kernel + zfs.ko
no longer fits in the default staging size.  Bump the default size from
32MB to 48MB to provide more breathing room.

PR:		201679
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D3666
2015-09-17 20:36:46 +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
Marcel Moolenaar
40ea8e710e As expected, things aren't as simple as hoped. Consequently, we have
no option but to use the smbios information to fill in the blanks.
It's a good thing UGA is a protocol of the past and GOP has all the
info we need.

Anyway, the logic has been tweaked a little to get the easier bits
of information up front. This includes the resolution and the frame
buffer address. Then we look at the smbios information and define
expected values as well as the missing bits (frame buffer offset and
stride). If the values obtained match the expect values, we fill in
the blanks and return. Otherwise we use the existing detection logic
to figure it out.

Rename the environment variables from uga_framebuffer abd uga_stride
to hw.efifb.address and hw.efifb.stride. The latter names are more
in line with other variable names.

We currently have hardcoded settings for:
1.  Mid-2007 iMac (iMac7,1)
2.  Late-2007 MacBook (MacBook3,1)
2015-09-07 17:56:49 +00:00
Marcel Moolenaar
1f8577e633 Auto-detect the UGA frame buffer and stride on a MacBook. We're
striking a delicate balance between exhaustive searching and
banking on assumptions. The environment variables can be used
as a fall-back anyway. With this change, all known and tested
Macs with only UGA should have a working console out of the
box... for now...
2015-09-05 18:24:51 +00:00
Marcel Moolenaar
39993974aa My MacBook has UGA only, but we fail to detect any changes
in the frame buffer when we flip pixels. Allow the detection
to be bypassed by setting the uga_framebuffer and uga_stride
variables. The kernel console works fine even when we can't
detect pixel changes in the frame buffer, which indicates
that the problem could be with reading from the frame buffer
and not writing to it.
2015-09-05 03:27:23 +00:00
Marcel Moolenaar
504ca52575 For UGA, the frame buffer address obtained by scanning the
PCI BARs does not necessarily correspond to the upper-left
most pixel. Scan the frame buffer for which byte changed
when changing the pixel at (0,0).

Use the same technique to determine the stride. Except for
changing the pixel at (0,0), we change the pixel at (0,1).

PR:		202730
Tested by:	hartzell (at) alerce.com
2015-09-03 04:35:17 +00:00
Andrew Turner
2c63960222 Install the forth bits on arm64. For now limit it to just arm64 as on x86
these should have been installed as part of the regular loader.
2015-09-01 13:51:07 +00:00
Marcel Moolenaar
7aefa262d6 Add support for the UGA draw protocol. This includes adding a
command called 'uga' to show whether UGA is implemented by the
firmware and what the settings are. It also includes filling
the efi_fb structure from the UGA information when GOP isn't
implemented by the firmware.

Since UGA does not provide information about the stride, we
set the stride to the horizontal resolution. This is likely
not correct and we should determine the stride by trial and
error. For now, this should show something on the console
rather than nothing.

Refactor this file to maximize code reuse.

PR:		202730
2015-08-30 23:58:53 +00:00
Marcel Moolenaar
d81907ecbf Add a gop command to help diagnose VT efifb problems. The gop
command has the following sub-commands:
  list		- list all possible modes (paged)
  get		- return the current mode
  set <mode>	- set the current mode to <mode>
2015-08-30 01:39:59 +00:00
Andrew Turner
86f5f2ed31 Pass the ACPI table pointer to the arm64 kernel from loader.efi.
Sponsored by:	The FreeBSD Foundation
2015-06-11 14:02:23 +00:00
Andrew Turner
ebbeae2083 Remove OUTPUT_FORMAT from theARM EFI linker script, it breaks building
for big-endian arm.
2015-05-14 12:43:39 +00:00
Ian Lepore
16bf8dd6dc Don't check the return value from self_reloc(), it can't fail and doesn't
return a value.

Despite what I said in my prior commit, it turns out this one platform
was checking the return value from the old self-reloc code (which returned
a hard-coded 0).
2015-05-10 13:30:21 +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
3bbcb38d72 Add FDT to the list of known GUIDs. 2015-05-05 11:07:43 +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
9e460d0453 When cross-building ${LIBSTAND} may be set to the host copy. Point to the
version built with the toolchain.

Differential Revision:	https://reviews.freebsd.org/D2312
Submitted by:	jhb
2015-05-05 10:32:59 +00:00
Andrew Turner
3f06facc8a * Remove the wfi when the efi loader returns, it's unneeded and is not
available on older designs.
* Enable the efi loader on arm
2015-04-14 14:15:14 +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
3d08016fc4 Add fdt support to the arm loader.efi 2015-04-11 11:00:53 +00:00
Andrew Turner
cc0ab6997e Only add -fPIC to CFLAGS and -Wl,-znocombreloc to LDFLAGS on x86, they
shouldn't be used on arm.
2015-04-11 10:36:48 +00:00
Andrew Turner
d4926f83a8 Move reloc.c to the top level Makefile as it has become generic. 2015-04-11 10:21:26 +00:00
Andrew Turner
43e9209c57 Update the arm efi ldscript to generate a valid efi binary 2015-04-11 10:07:58 +00:00
Ed Maste
5ec8fa0ee4 Add build support for i386 loader.efi
Kernel changes are required for this to be useful but this will allow
others to experiment.

Differential Revision:	https://reviews.freebsd.org/D2276
2015-04-10 18:49:43 +00:00
Ed Maste
dea6bf66ea Limit EFI framebuffer metadata to amd64 for now
The i386 loader.efi does not yet exist. Avoid dealing with vt and
framebuffer issues there until the initial bootstrapping is done.
2015-04-10 18:08:09 +00:00
Andrew Turner
b6e1ffd447 Port the EFI reloc codeto work on arm64. This used the rela relocation
table so wiill need the addend included in the relocation calculation.

Sponsored by:	The FreeBSD Foundation
2015-04-10 09:15:35 +00:00
Ed Maste
b291974d25 Remove EOL whitespace from i386 EFI loader source 2015-04-09 19:48:42 +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
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
Rui Paulo
bb09480677 SMBIOS support for EFI.
MFC after:	1 week
2015-04-06 06:55:47 +00:00
Andrew Turner
60ac534440 Add FDT support to loader.efi. This will be used on arm and arm64.
Differential Revision:	https://reviews.freebsd.org/D2219
2015-04-05 18:37:39 +00:00
Rui Paulo
a620035cf4 loader/EFI: improve the help of the 'mode' command. 2015-04-04 04:30:37 +00:00
Andrew Turner
36725fc471 Only enable the efi framebuffer on x86 for now 2015-04-03 12:54:38 +00:00
Andrew Turner
5da820b611 Only include machine/specialreg.h on x86 2015-04-03 12:30:18 +00:00
Andrew Turner
cf5d3022f9 Only enable comconsole and nullconsole on x86. 2015-04-03 12:08:08 +00:00
Ed Maste
db117b94d3 Move i386/efi files to new home in efi/loader/arch/i386
This was not (and still is not) connected to the build, but the EFI
loader is in the process of being built for other than amd64 so these
files ought to live in their eventual MD location.
2015-04-02 18:57:35 +00:00
Andrew Turner
9e62ed8ff9 Move the efi loaders to be under sys/boot/efi. This will help us add
support for booting arm and arm64 from UEFI.

Differential Revision:	https://reviews.freebsd.org/D2164
Reviewed by:	emaste, imp (previous version)
Sponsored by:	The FreeBSD Foundation
2015-04-01 08:30:40 +00:00
Marcel Moolenaar
21321a3432 This file was repocopied to src/sys/boot/ia64/efi. 2004-11-23 18:55:24 +00:00
Marcel Moolenaar
2ba0042660 Remove struct ia64_itir and use a plain old uint64_t instead. 2004-11-21 21:40:08 +00:00
Marcel Moolenaar
f3a21ad7c6 Redefine a PTE as a 64-bit integral type instead of a struct of
bit-fields. Unify the PTE defines accordingly and update all
uses.
2004-09-23 18:37:36 +00:00
Marcel Moolenaar
0797d69c78 Catch up with change to <machine/pte.h>. 2004-08-10 02:08:57 +00:00
Marcel Moolenaar
8af8df6452 Fix the creation of EFI images that got broken by the import of
binutils 2.15. The linker now creates a .rela.dyn section for
dynamic relocations, while our script created a .rela section.
Likewise, we copied the .rela section to the EFI image, but not
the .rela.dyn section. The fix is to rename .rela to .rela.dyn
in the linker script so that all relocations end up in the same
section again. This we copy into the EFI image.
2004-07-20 07:01:02 +00:00
Marcel Moolenaar
317872f26c Don't create a mapfile during link. It's not needed for the build. 2004-02-13 04:45:41 +00:00
Ruslan Ermilov
5c8f32a869 Tidy up makefiles.
Tested by:	marcel
2004-02-12 08:10:34 +00:00
Marcel Moolenaar
e4ec6fb518 Don't hardcode unit 0 for the current device if we're loaded from an
EFI file system. When booting from a CD and there's already an EFI
system partition on the disk, setting the current device to unit 0
will select the harddisk. This invariably breaks installing FreeBSD
when other operating systems have been installed before.

We obviously want to do the same when we're booting over the network.
Maybe later.

Based on a patch (from memory) from: arun
2003-08-02 08:22:03 +00:00
David E. O'Brien
8368cf8f75 Use __FBSDID rather than rcsid[]. 2003-04-03 21:36:33 +00:00
Marcel Moolenaar
59c9bb54ee Speed up debugging in the context of unexpected traps by printing
the address of the image base of the loader. Given cr.iip, we can
use the symbol table to figure out what function caused the trap.
2003-03-01 05:18:28 +00:00
David E. O'Brien
a8896ec82d Consistently use NOFORTH to control the usage of ficl. 2003-02-26 06:18:52 +00:00
Jake Burkholder
7c6c018c0c Renamed the loader's zipfs to gzipfs. zipfs.c was repo-copied to gzipfs.c. 2002-12-19 19:34:59 +00:00
Marcel Moolenaar
414c998fba Add command `hcdp'. This command dumps the DIG64 HCDP table if one
exists.
2002-12-18 08:13:03 +00:00
Marcel Moolenaar
6257165c74 Pass the HCDP table address to the kernel. If no such table exists,
NULL is passed. The address of the HCDP table can be found by
iterating over the configuration tables in the EFI system table.
To avoid more duplication, a function can be called with the GUID
of interest. The function will do the scanning. Use the function
in all places where we iterate over the configuration tables in
an attempt to find a specific one.

Bump the loader version number as the result of this.

Approved by: re (blanket)
2002-12-10 20:11:20 +00:00
Marcel Moolenaar
155dbcacfb Change the startup code to fix a memory leak and to allow us to
accept load options (=command line options).

The call graph changes from *entry*->efi_main->efi_init, where
efi_main is the EFI equivalent of main to *entry*->efi_main->main,
where main is what you'd expect. efi_main now is what efi_init was.
The prototype of main follows that of C. The first argument is argc
and the second is argv. There is no third argument.
Allocation of heap pages is now handled by the EFI library and it
now deallocates the pages when main() returns or when exit() is
called. This allows us to safely return to the boot manager (or
EFI shell) without leaks. EFI applications are responsible to free
all memory themselves.

Handling of the load options is a bit tricky. There are either no
load options, load options in ASCII or load options in Unicode.
The EFI library will translate the ASCII options to Unicode options
as to simplify user code. Since the load options are passed as a
single string (if present) and main() accepts argc and argv, the
startup code also has to split the string into words and build the
argv vector. Here the trickiness starts. When the loader is started
from the EFI shell, argv[0] will automaticly load the program name.
In all other cases (ie through the boot manager), this is not the
case. Unfortunately, there's no trivial way to check. Hence, a
set of conditions is checked to determine if we need to fill in
argv[0] ourselves or not. This checking is not perfect. There are
known cases where it fails to do the right thing. The logic works
for most expected cases, though. This includes the case where no
options are given.

Approved by: re (blanket)
2002-12-10 06:22:25 +00:00
Marcel Moolenaar
4ee2f7cb16 o Make all GUID variables global to maximize reuse.
o  Recognize the HCDP configuration table.
o  Dump the GUID of tables we don't recognize.

Approved by: re (carte blanche)
2002-12-10 04:55:25 +00:00
Marcel Moolenaar
ea16741fc0 The boot manager sets the watchdog timer to 5 minutes before invoking
a boot option. When the timer expires the machine is rebooted.
Disable the watchdog timer for 2 reasons:
o  We're an interactive program. We cannot guarantee that we've
   booted the kernel in the time available to us. There have been
   situations where netbooting the right kernel took 2 tries and
   more time than given. Not to speak of the normal behaviour to
   have the loader sitting at the prompt while the user is off
   doing other things (such as figuring out what to type next ;-)
o  We may not boot a kernel at all. We may exit as the result of
   the user typing quit (assuming it took less than 5 minutes to
   type it :-). It is documented that loaders should have disabled
   the watchdog timer if they return to the boot manager. Not doing
   so would cause a reboot while in the boot manager. This appears
   to be harmless, besides of course the actual reboot.

Approved by: re (weisse karte)
2002-12-08 20:04:00 +00:00
Marcel Moolenaar
aef78848af Remove a left-over virtual mapping of uncached I/O port space.
Previous kernels unwantingly depended on this mapping, but as
of version 1.123 of src/sys/ia64/ia64/machdep.c this dependency
has been removed. Consequently, one has to update the kernel
before updating the loader. The documented/recommended upgrade
will suffice in this case.

Due to a visible (from the kernels point of view) change in
behaviour, bump the loader version number from 0.3 to 1.0.

Approved by: re (carte blanc)
2002-11-28 03:25:51 +00:00
Marcel Moolenaar
689f36d7f9 MFp4:
o  Show the contents of the AP wakeup descriptor when dumping SAL
   information.
o  Increase S/N ratio when listing the itr and dtr. Only show valid
   mappings and give the total number of TRs.

Approved by: re (blanket)
2002-11-24 19:45:05 +00:00