aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/efi
AgeCommit message (Collapse)AuthorFilesLines
2015-09-02[efi] Implement the EFI_PXE_BASE_CODE_PROTOCOLMichael Brown1-0/+17
Many UEFI NBPs expect to find an EFI_PXE_BASE_CODE_PROTOCOL installed in addition to the EFI_SIMPLE_NETWORK_PROTOCOL. Most NBPs use the EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the cached DHCP packets. This implementation has been tested with grub.efi, shim.efi, syslinux.efi, and wdsmgfw.efi. Some methods (such as Discover() and Arp()) are not used by any known NBP and so have not (yet) been implemented. Usage notes for the tested bootstraps are: - grub.efi uses EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the cached DHCP packet, and uses no other methods. - shim.efi uses EFI_PXE_BASE_CODE_PROTOCOL to retrieve the cached DHCP packet and to retrieve the next NBP via the Mtftp() method. If shim.efi was downloaded via HTTP (or other non-TFTP protocol) then shim.efi will blindly call Mtftp() with an HTTP URI as the filename: this allows the next NBP (e.g. grubx64.efi) to also be transparently retrieved by HTTP. shim.efi can also use the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL to retrieve files previously loaded by "imgfetch" or similar commands in iPXE. The current implementation of shim.efi will use the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL only if it does not find an EFI_PXE_BASE_CODE_PROTOCOL; this patch therefore prevents this usage of our EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. This logic could be trivially reversed in shim.efi if needed. - syslinux.efi uses EFI_PXE_BASE_CODE_PROTOCOL only to retrieve the cached DHCP packet. Versions 6.03 and earlier have a bug which may cause syslinux.efi to attach to the wrong NIC if there are multiple NICs in the system (or if the UEFI firmware supports IPv6). - wdsmgfw.efi (ab)uses EFI_PXE_BASE_CODE_PROTOCOL to retrieve the cached DHCP packets, and to send and retrieve UDP packets via the UdpWrite() and UdpRead() methods. (This was presumably done in order to minimise the amount of benefit obtainable by switching to UEFI, by replicating all of the design mistakes present in the original PXE specification.) The EFI_DOWNGRADE_UX configuration option remains available for now, until this implementation has received more widespread testing. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01[efi] Allow calls to efi_snp_claim() and efi_snp_release() to be nestedMichael Brown1-3/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-01[efi] Add definitions of GUIDs observed when booting wdsmgfw.efiMichael Brown3-0/+358
Add definitions of protocols observed to be used by wdsmgfw.efi, and add a handle name type for ConIn, ConOut, and StdErr. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-27[efi] Improve efi_wrap debuggingMichael Brown1-0/+4
Add debug wrappers for more boot services functions, and print symbolic values rather than raw numbers where possible. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-27[efi] Mark EFI debug transcription functions as __attribute__ (( pure ))Michael Brown1-3/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-27[efi] Add definitions of GUIDs observed when booting shim.efi and grub.efiMichael Brown4-0/+667
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-03[efi] Hold off watchdog timer while runningMichael Brown1-0/+31
UEFI platforms may provide a watchdog timer, which will reboot the machine if an operating system takes more than five minutes to load. This can cause long-lived iPXE downloads (or interactive shell sessions) to unexpectedly reboot. Fix by resetting the watchdog timer every ten seconds while the iPXE main processing loop continues to run. Reported-by: Bradley B Williams <bradleybwilliams@swbell.net> Reported-by: John Clark <john.r.clark.3@gmail.com> Reported-by: wdriever@gmail.com Reported-by: Charlie Beima <cbeima@indiana.edu> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22[efi] Fix receive and transmit completion reportingMichael Brown1-14/+13
Fix the TxBuf value filled in by GetStatus() to report the transmit buffer address as required by the (now clarified) specification. Simplify "interrupt" handling in GetStatus() to report only that one or more packets have been transmitted or received; there is no need to report one GetStatus() "interrupt" per packet. Simplify receive handling to dequeue received packets immediately from the network device into an internal list (thereby avoiding the hacks previously used to determine when to report new packet arrivals). Originally-fixed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-14[efi] Use the EFI_RNG_PROTOCOL as an entropy source if availableMichael Brown1-0/+158
Entropy gathering via timer ticks is slow under UEFI (of the order of 20-30 seconds on some machines). Use the EFI_RNG_PROTOCOL if available, to speed up the process of entropy gathering. Note that some implementations (including EDK2) will fail if we request fewer than 32 random bytes at a time, and that the RNG protocol provides no guarantees about the amount of entropy provided by a call to GetRNG(). We take the (hopefully pessimistic) view that a 32-byte block returned by GetRNG() will contain at least the 1.3 bits of entropy claimed by min_entropy_per_sample(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-14[efi] Add EFI time sourceMichael Brown1-0/+20
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-14[efi] Add EFI entropy sourceMichael Brown1-0/+35
Originally-implemented-by: Jarrod Johnson <jbjohnso@us.ibm.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02[legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown14-14/+14
Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16[efi] Add NII / UNDI driverMichael Brown2-0/+840
Some UEFI network drivers provide a software UNDI interface which is exposed via the Network Interface Identifier Protocol (NII), rather than providing a Simple Network Protocol (SNP). The UEFI platform firmware will usually include the SnpDxe driver, which attaches to NII and provides an SNP interface. The SNP interface is usually provided on the same handle as the underlying NII device. This causes problems for our EFI driver model: when efi_driver_connect() detaches existing drivers from the handle it will cause the SNP interface to be uninstalled, and so our SNP driver will not be able to attach to the handle. The platform firmware will eventually reattach the SnpDxe driver and may attach us to the SNP handle, but we have no way to prevent other drivers from attaching first. Fix by providing a driver which can attach directly to the NII protocol, using the software UNDI interface to drive the network device. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16[efi] Update to current EDK2 headersMichael Brown5-15/+60
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-16[efi] Generalise snpnet_dev_info() to efi_device_info()Michael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-25[efi] Add definitions of GUIDs observed when chainloading from Intel driverMichael Brown10-0/+4123
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-25[efi] Centralise definitions of more protocol GUIDsMichael Brown1-0/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-09-04[efi] Avoid returning uninitialised data from PCI configuration space readsMichael Brown1-0/+3
Under UEFI, reads from PCI configuration space may fail. If this happens, we should return all-ones (which will mimic the behaviour of an absent PCI device). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-29[efi] Wrap any images loaded by our wrapped imageMichael Brown1-2/+1
Propagate our modified EFI system table to any images loaded by the image that we wrap, thereby allowing us to observe boot services calls made by all subsequent EFI images. Also show details of intercepted ExitBootServices() calls. When wrapping is used, exiting boot services will almost certainly fail, but this at least allows us to see when it happens. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-21[efi] Add definitions of GUIDs observed during Windows bootMichael Brown6-0/+3773
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06[efi] Generalise snpnet_pci_info() to efi_locate_device()Michael Brown1-0/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-06[efi] Move abstract device path and handle functions to efi_utils.cMichael Brown2-4/+19
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05[efi] Open device path protocol only at point of useMichael Brown2-8/+2
Some EFI 1.10 systems (observed on an Apple iMac) do not allow us to open the device path protocol with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER and so we cannot maintain a safe, long-lived pointer to the device path. Work around this by instead opening the device path protocol with an attribute of EFI_OPEN_PROTOCOL_GET_PROTOCOL whenever we need to use it. Debugged-by: Curtis Larsen <larsen@dixie.edu> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-08-05[efi] Provide centralised definitions of commonly-used GUIDsMichael Brown1-0/+16
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Avoid unnecessarily passing pointers to EFI_HANDLEsMichael Brown2-3/+3
efi_file_install() and efi_download_install() are both used to install onto existing handles. There is therefore no need to allow for each of their calls to InstallMultipleProtocolInterfaces() to create a new handle. By passing the handle directly (rather than a pointer to the handle), we avoid potential confusion (and erroneous debug message colours). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Allow compiler to perform type checks on EFI_HANDLEMichael Brown1-0/+10
The EFI headers define EFI_HANDLE as a void pointer, which renders type checking on anything dealing with EFI handles somewhat useless. Work around this bizarre sabotage attempt by redefining EFI_HANDLE as a pointer to an anonymous structure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Use efi_handle_name() instead of efi_handle_devpath_text()Michael Brown1-1/+0
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Add ability to dump all openers of a given protocol on a handleMichael Brown1-1/+26
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Provide efi_handle_name() for debuggingMichael Brown1-0/+1
Provide a function efi_handle_name() (as a generalisation of efi_handle_devpath_text()) which tries various methods to produce a human-readable name for an EFI handle. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-31[efi] Expand the range of well-known EFI GUIDs in debug messagesMichael Brown3-0/+292
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-30[efi] Default to releasing network devices for use via SNPMichael Brown1-2/+17
We currently treat network devices as available for use via the SNP API only if RX queue processing has been frozen. (This is similar in spirit to the way that RX queue processing is frozen for the network device currently exposed via the PXE API.) The default state of a freshly created network device is for the RX queue to not be frozen, and thus to be unavailable for use via SNP. This causes problems when devices are added through code paths other than _efidrv_start() (which explicitly releases devices for use via SNP). We don't actually need to freeze RX queue processing, since calls via the SNP API will always use netdev_poll() rather than net_poll(), and so will never trigger the RX queue processing code path anyway. We can therefore simplify the code to use a single global flag to indicate whether network devices are claimed for use by iPXE or available for use via SNP. Using a global flag allows the default state for dynamically created network devices to behave sensibly. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16[efi] Include EFI_CONSOLE_CONTROL_PROTOCOL headerMichael Brown2-1/+125
The EFI_CONSOLE_CONTROL_PROTOCOL does not exist in the current UEFI specification, but is required to enable text output on some older EFI 1.10 implementations (observed on an old iMac). The header is not present in any of the standard include directories, but can still be found in the EDK2 codebase as part of EdkCompatibilityPkg. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-16[efi] Allow for interception of boot services calls by loaded imageMichael Brown1-0/+16
When building with DEBUG=efi_wrap, print details of calls made by the loaded image to selected boot services functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-14[efi] Install our own disk I/O protocol and claim exclusive use of itMichael Brown1-0/+119
The EFI FAT filesystem driver has a bug: if a block device contains no FAT filesystem but does have an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instance, the FAT driver will assume that it must have previously installed the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. This causes the FAT driver to claim control of our device, and to refuse to stop driving it, which prevents us from later uninstalling correctly. Work around this bug by opening the disk I/O protocol ourselves, thereby preventing the FAT driver from opening it. Note that the alternative approach of opening the block I/O protocol (and thereby in theory preventing DiskIo from attaching to the block I/O protocol) causes an endless loop of calls to our DRIVER_STOP method when starting the EFI shell. I have no idea why this is. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-14[efi] Update EDK2 headersMichael Brown20-96/+533
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-08[efi] Identify autoboot device by MAC address when chainloadingMichael Brown1-0/+14
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-03[efi] Allow network devices to be created on top of arbitrary SNP devicesMichael Brown3-34/+52
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25[efi] Restructure EFI driver modelMichael Brown2-33/+38
Provide a single instance of EFI_DRIVER_BINDING_PROTOCOL (attached to our image handle); this matches the expectations scattered throughout the EFI specification. Open the underlying hardware device using EFI_OPEN_PROTOCOL_BY_DRIVER and EFI_OPEN_PROTOCOL_EXCLUSIVE, to prevent other drivers from attaching to the same device. Do not automatically connect to devices when being loaded as a driver; leave this task to the platform firmware (or to the user, if loading directly from the EFI shell). When running as an application, forcibly disconnect any existing drivers from devices that we want to control, and reconnect them on exit. Provide a meaningful driver version number (based on the build timestamp), to allow platform firmware to automatically load newer versions of iPXE drivers if multiple drivers are present. Include device paths within debug messages where possible, to aid in debugging. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25[efi] Provide a meaningful EFI SNP device nameMichael Brown1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-25[efi] Allow device paths to be easily included in debug messagesMichael Brown1-16/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-19[efi] Allow for optional protocolsMichael Brown1-0/+17
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-14[efi] Disable SNP devices when running iPXE as the applicationMichael Brown1-0/+4
Some UEFI builds will set up a timer to continuously poll any SNP devices. This can drain packets from the network device's receive queue before iPXE gets a chance to process them. Use netdev_rx_[un]freeze() to explicitly indicate when we expect our network devices to be driven via the external SNP API (as we do with the UNDI API on the standard BIOS build), and disable the SNP API except when receive queue processing is frozen. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10[efi] Allow driver to be unloadedMichael Brown1-0/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12[uaccess] Add memcmp_user()Michael Brown1-0/+7
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15[legal] Add missing FILE_LICENCE declarationsMarin Hannache2-0/+4
Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19[efi] Perform meaningful error code conversionsMichael Brown3-16/+14
Exploit the redefinition of iPXE error codes to include a "platform error code" to allow for meaningful conversion of EFI_STATUS values to iPXE errors and vice versa. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-19[efi] Remove obsolete EFI I/O implementation using EFI_CPU_IO_PROTOCOLMichael Brown3-372/+0
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-27[efi] Fetch device path for loaded image during initialisationMichael Brown1-0/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-22[efi] Add "reboot" command for EFIMichael Brown1-0/+18
Abstract out the ability to reboot the system to a separate reboot() function (with platform-specific implementations), add an EFI implementation, and make the existing "reboot" command available under EFI. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-20[efi] Provide efi_guid_ntoa() for printing EFI GUIDsMichael Brown1-14/+5
Signed-off-by: Michael Brown <mcb30@ipxe.org>