Commit Graph

21 Commits

Author SHA1 Message Date
Ed Maste
3bcd280e3b Switch to text mode in UEFI boot
The loader previously failed to display on MacBooks and other systems
where the UEFI firmware remained in graphics mode.

Submitted by:	Rafael Espíndola
2014-09-18 13:59:36 +00:00
Ed Maste
7f4b01c1fa Wrap long lines introduced in r268227 2014-09-18 13:00:03 +00:00
Doug Ambrisko
cb8a626055 Add support for serial and null console to UEFI boot loader. 2014-09-12 17:32:28 +00:00
Marcel Moolenaar
7fe0b4f160 Give loaders more control over the Forth initialization process. In
particular, allow loaders to define the name of the RC script the
interpreter needs to use. Use this new-found control to have the
PXE loader (when compiled with TFTP support and not NFS support)
read from ${bootfile}.4th, where ${bootfile} is the name of the
file fetched by the PXE firmware.

The normal startup process involves reading the following files:
1.  /boot/boot.4th
2.  /boot/loader.rc or alternatively /boot/boot.conf

When these come from a FreeBSD-defined file system, this is all
good. But when we boot over the network, subdirectories and fixed
file names are often painful to administrators and there's really
no way for them to change the behaviour of the loader.

Obtained from:	Juniper Networks, Inc.
2014-07-27 16:12:51 +00:00
Sean Bruno
67bff9b155 Remove boot1.efi during clean target. 2014-07-22 04:38:28 +00:00
Ed Maste
b560f3ffa1 Display efi framebuffer dimensions on boot
The EFI framebuffer produces corrupted output on certain systems.  For
now display the framebuffer parameters (address, dimensions, etc.) on
boot to aid in tracking down these issues.

Sponsored by:	The FreeBSD Foundation
2014-07-03 17:53:28 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Nathan Whitehorn
4424e30878 Turn off various fancy instruction sets, as well as deduplicate some options.
This makes the EFI loader build work with CPUTYPE=native in make.conf on
my Core i5.
2014-04-28 18:25:21 +00:00
Nathan Whitehorn
1c6c63fc6a Revert to FAT12. This file system is apparently too small for FAT32, even
if the old (pre r264889) newfs_msdos allowed it. And FAT12 seems to work
perfectly well.
2014-04-27 00:45:08 +00:00
Nathan Whitehorn
8f6580d808 Apparently this is supposed to be FAT32, not FAT12. 2014-04-26 17:51:41 +00:00
Nathan Whitehorn
e9bee2c689 Add generation of an EFI filesystem to hold boot1.efi. This is a near-exact
copy of the code from boot1.chrp again.

The resulting image is installed to /boot/boot1.efifat. If dd'ed to an 800K
"efi" partition, it should result in a bootable system.
2014-04-26 16:34:22 +00:00
Warner Losh
a58f61bf3a Eliminate last vestigies of NO_MAN= in the tree. Also, remove
ineffectual NOMAN= lines. These don't change the build at all.
2014-04-25 19:25:05 +00:00
Nathan Whitehorn
5e1254e13b Apparently some of the i386 boot blocks are so close to full that adding
single lines to ufsread.c spills them over. Duplicate a whole bunch of
code to get file sizes into boot1.efi/boot1.c rather than modifying
ufsread.c.
2014-04-13 14:50:52 +00:00
Nathan Whitehorn
2a11027fd3 Add my copyright here. Most of this is unmodified from the original sparc64
version, but at least some indication of changes that postdate the actual
invention of EFI is probably a good idea.
2014-04-13 06:30:02 +00:00
Nathan Whitehorn
40adc3db02 Fix buildworld. I had some local bits in my build tree that caused this
to work by accident.
2014-04-13 06:24:01 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Nathan Whitehorn
337bb26472 Add a simple EFI stub loader. This is a quick and dirty of boot1.chrp from
the PowerPC port with all the Open Firmware bits removed and replaced by
their EFI counterparts. On the whole, I think I prefer Open Firmware.

This code is supposed to be an immutable shim that sits on the EFI system
partition, loads /boot/loader.efi from UFS and tells the real loader what
disk/partition to look at. It finds the UFS root partition by the somewhat
braindead approach of picking the first UFS partition it can find. Better
approaches are called for, but this works for now. This shim loader will
also be useful for secure boot in the future, which will require some
rearchitecture.
2014-04-13 01:14:25 +00:00
Ed Maste
7a5f5e3794 Fix EFI loader object tree creation on 9.x build hosts
Previously ${COMPILER_TYPE} was checked in sys/boot/amd64, and the efi
subdirectory was skipped altogether for gcc (since GCC does not support
a required attribute).  However, during the early buildworld stages
${COMPILER_TYPE} is the existing system compiler (i.e., gcc on 9.x build
hosts), not the compiler that will eventually be used.  This caused
"make obj" to skip the efi subdirectory.  In later build stages
${COMPILER_TYPE} is "clang", and then the efi loader would attempt to
build in the source directory.

Sponsored by:	The FreeBSD Foundation
2014-04-10 16:53:21 +00:00
Ed Maste
731d7808a3 Do not build the amd64 UEFI loader with GCC
The UEFI loader causes buildworld to fail when building with (in-tree)
GCC, due to a typedef redefinition.  As it happens the in-tree GCC
cannot successfully build the UEFI loader anyhow, as it does not support
__attribute__((ms_abi)).  Thus, just avoid trying to build it with GCC,         rather than disconnecting it from the build until the underlying issue
is fixed.

Sponsored by:	The FreeBSD Foundation
2014-04-07 00:49:15 +00:00
Ed Maste
7de2785827 Fix printf format mismatches
Sponsored by:	The FreeBSD Foundation
2014-04-04 13:35:36 +00:00
Ed Maste
8c00aba8c4 Support UEFI booting on amd64 via loader.efi
This is largely the work from the projects/uefi branch, with some
additional refinements.  This is derived from (and replaces) the
original i386 efi implementation; i386 support will be restored later.

Specific revisions of note from projects/uefi:

r247380:

  Adjust our load device when we boot from CD under UEFI.

  The process for booting from a CD under UEFI involves adding a FAT
  filesystem containing your loader code as an El Torito boot image.
  When UEFI detects this, it provides a block IO instance that points at
  the FAT filesystem as a child of the device that represents the CD
  itself. The problem being that the CD device is flagged as a "raw
  device" while the boot image is flagged as a "logical partition". The
  existing EFI partition code only looks for logical partitions and so
  the CD filesystem was rendered invisible.

  To fix this, check the type of each block IO device. If it's found to
  be a CD, and thus an El Torito boot image, look up its parent device
  and add that instead so that the loader will then load the kernel from
  the CD filesystem.  This is done by using the handle for the boot
  filesystem as an alias.

  Something similar to this will be required for booting from other
  media as well as the loader will live in the EFI system partition, not
  on the partition containing the kernel.

r246231:

  Add necessary code to hand off from loader to an amd64 kernel.

r246335:

  Grab the EFI memory map and store it as module metadata on the kernel.

  This is the same approach used to provide the BIOS SMAP to the kernel.

r246336:

  Pass the ACPI table metadata via hints so the kernel ACPI code can
  find them.

r246608:

  Rework copy routines to ensure we always use memory allocated via EFI.

  The previous code assumed it could copy wherever it liked. This is not
  the case. The approach taken by this code is pretty ham-fisted in that
  it simply allocates a large (32MB) buffer area and stages into that,
  then copies the whole area into place when it's time to execute. A more
  elegant solution could be used but this works for now.

r247214:

  Fix a number of problems preventing proper handover to the kernel.

  There were two issues at play here. Firstly, there was nothing
  preventing UEFI from placing the loader code above 1GB in RAM. This
  meant that when we switched in the page tables the kernel expects to
  be running on, we are suddenly unmapped and things no longer work. We
  solve this by making our trampoline code not dependent on being at any
  given position and simply copying it to a "safe" location before
  calling it.

  Secondly, UEFI could allocate our stack wherever it wants. As it
  happened on my PC, that was right where I was copying the kernel to.
  This did not cause happiness. The solution to this was to also switch
  to a temporary stack in a safe location before performing the final
  copy of the loaded kernel.

r246231:

  Add necessary code to hand off from loader to an amd64 kernel.

r246335:

  Grab the EFI memory map and store it as module metadata on the kernel.

  This is the same approach used to provide the BIOS SMAP to the kernel.

r246336:

  Pass the ACPI table metadata via hints so the kernel ACPI code can
  find them.

r246608:

  Rework copy routines to ensure we always use memory allocated via EFI.

  The previous code assumed it could copy wherever it liked. This is not
  the case. The approach taken by this code is pretty ham-fisted in that
  it simply allocates a large (32MB) buffer area and stages into that,
  then copies the whole area into place when it's time to execute. A more
  elegant solution could be used but this works for now.

r247214:

  Fix a number of problems preventing proper handover to the kernel.

  There were two issues at play here. Firstly, there was nothing
  preventing UEFI from placing the loader code above 1GB in RAM. This
  meant that when we switched in the page tables the kernel expects to
  be running on, we are suddenly unmapped and things no longer work. We
  solve this by making our trampoline code not dependent on being at any
  given position and simply copying it to a "safe" location before
  calling it.

  Secondly, UEFI could allocate our stack wherever it wants. As it
  happened on my PC, that was right where I was copying the kernel to.
  This did not cause happiness. The solution to this was to also switch
  to a temporary stack in a safe location before performing the final
  copy of the loaded kernel.

r247216:

  Use the UEFI Graphics Output Protocol to get the parameters of the
  framebuffer.

Sponsored by:	The FreeBSD Foundation
2014-04-04 00:16:46 +00:00