EFI Boot Support on Intel Platforms

Project description

The aim of this project is to complete the implementation of EFI boot support on the amd64 and i386 platforms for both UEFI compliant as well as Apple machines.

Approach to solving the problem

An EFI boot service will provide the functionality of loader(8). Since EFI provides substantially more functionality, the boot0-2 stages of booting will not be necessary.

Modifications to the kernel may be necessary in order to allow it occupy non-contiguous sections of memory. The EFI interface provides functions for allocating memory, however, if the EFI loader allocates a block for each loadable ELF segment, there is no guarantee that the kernel will be contiguous in memory. It may be possible to work around this by allocating one block for the entire kernel

Some drivers may also need modification, if they rely on BIOS code that may not be present when booting from EFI.

On UEFI-compliant machines, there is a system partition, which contains a FAT filesystem, where the EFI loader resides.

On Apple machines, the system partition is used to install firmware updates, and is usually blank. The Apple EFI boot manager searches instead for an HFS+ partition, and loads /System/Library/CoreServices/boot.efi. Therefore, on an apple machine, there will need to be an HFS+ partition to hold the loader, as well as some way of installing it to the partition. The easiest solution is to create a tool which instantiates a filesystem containing the loader.

General approach is as follows:

  1. Minimize modifications to the kernel, libstand, loader, etc.
  2. Use as much of what already exists as possible
  3. Do things in such a way that enables future development to take advantage of other EFI features.
  4. Document everything.

Current Status

Issues with getting loader.efi running were far worse than I anticipated. Fortunately, I have successfully gotten it to run on the TianoCore image.

Item

Status

Notes

Kernel modifications to support non-contiguous kernel

IN PROGRESS

Initial investigations seem promising

Build i386 loader.efi

COMPLETE

At present, only works with complete make buildworld

Run i386 loader.efi on QEMU/TianoCore

COMPLETE

Boot i386 EFI kernel on QEMU/TianoCore

IN PROGRESS

Build amd64 loader.efi

INCOMPLETE

Linking fails, due to additional symbols needed by elf64_freebsd.c

Run amd64 loader.efi on QEMU/TianoCore

INCOMPLETE

Boot amd64 EFI kernel on QEMU/TianoCore

INCOMPLETE

Implement tools to allow boot on Apple machines

IN PROGRESS

Run amd64 loader.efi on an Apple machine

INCOMPLETE

Boot amd64 EFI kernel on an Apple machine

INCOMPLETE

Issues

I ran into a number of very low-level issues trying to get loader.efi to run. As I am developing a boot loader, finding root causes can be quite difficult, due to the very limited information available. This is a list of the more serious issues:

Knowledge Base

This section has some specific points about how the EFI loader works, and is compiled.

EDK II vs Current

Currently, we use a combination of linker scripts and objcopy to produce an EFI application. I was able to get the EDK II (EFI Development Kit) tools and the Microsoft IASL compiler to build on FreeBSD with some work. There is a case for using this to build the loader instead. There are advantages and disadvantages to this approach:

Deliverables

Milestones

Test Plan

Primary testing will take place on qemu, using i386 and amd64 instances using the TianoCore EFI bios images. Once booting works and is stable, I will search for volunteers with UEFI-compliant machines to test booting on actual hardware. I will test booting on Apple using my own machines.

The Code

https://socsvn.freebsd.org/socsvn/soc2012/emc2/

SummerOfCode2012/IntelEFIBoot (last edited 2012-07-11 14:02:01 by EricMcCorkle)