freebsd-skq/sys/boot/i386
emaste c72005d63b 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
..
boot0 Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to 2012-02-28 18:30:18 +00:00
boot0ext
boot0sio
boot2 Split the last gcc-specific flags off into CFLAGS.gcc. This also 2014-01-05 21:03:49 +00:00
btx Sanitize the %eflags returned by BIOS routines. Some BIOS routines enter 2013-10-10 19:51:38 +00:00
cdboot Drop the 3rd clause from all 3 clause BSD licenses where I am the sole 2014-02-05 18:13:27 +00:00
common boot: use packed attribute for edd_params* structures and their substructures 2012-11-14 11:05:16 +00:00
efi Support UEFI booting on amd64 via loader.efi 2014-04-04 00:16:46 +00:00
gptboot Build a 32-bit libstand under sys/boot/ 2014-02-06 21:54:21 +00:00
gptzfsboot Build a 32-bit libstand under sys/boot/ 2014-02-06 21:54:21 +00:00
kgzldr
libfirewire Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this 2013-11-30 22:17:27 +00:00
libi386 howto_names: unify declaration 2014-03-11 10:13:06 +00:00
loader Build boot/ficl as 64-bit library on amd64 2014-04-03 21:18:03 +00:00
mbr Use -Wl,-N instead of the undocumented -N option for GCC. 2010-06-03 17:42:32 +00:00
pmbr When GPT signature is invalid in the primary GPT header, then try to 2012-08-05 12:57:38 +00:00
pxeldr Similar to r130943 for cdboot.S, update the license on this file to a 2014-02-05 17:22:54 +00:00
zfsboot Build a 32-bit libstand under sys/boot/ 2014-02-06 21:54:21 +00:00
zfsloader For consistency, change all 'i386' and MACHINE_ARCH to x86. 2010-08-31 19:01:12 +00:00
Makefile Don't build zfsboot, gptzfsboot, and zfsloader if WITHOUT_ZFS is enabled. 2009-12-22 20:56:33 +00:00
Makefile.inc For sys/boot/i386 and sys/boot/pc98, separate flags to be passed 2013-12-30 19:05:50 +00:00