summaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)AuthorFilesLines
2019-12-03common: Move board_get_usable_ram_top() out of common.hSimon Glass1-0/+1
Move this function into init.h which seems to be designed for this sort of thing. Also update the header to declare struct global_data so that it can be included without global_data.h being needed. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03common: Move enable/disable_interrupts out of common.hSimon Glass1-0/+1
Move these two functions into the irq_funcs.h header file. Also move interrupt_handler_t as this is used by the irq_install_handler() function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03common: Move ARM cache operations out of common.hSimon Glass2-0/+2
These functions are CPU-related and do not use driver model. Move them to cpu_func.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03common: Move get_ticks() function out of common.hSimon Glass2-0/+2
This function belongs in time.h so move it over and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-03crc32: Use the crc.h header for crc functionsSimon Glass3-0/+3
Drop inclusion of crc.h in common.h and use the correct header directly instead. With this we can drop the conflicting definition in fw_env.h and rely on the crc.h header, which is already included. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-11-23efi_loader: default EFI_LOADER=n on ARM11Heinrich Schuchardt1-1/+1
Some of the ARM11 boards have tight limits on the size of U-Boots. Hence use EFI_LOADER=n as default on ARM11. Set EFI_LOADER=y for the Raspberry Pi and Raspberry Pi Zero as these boards have sufficient storage on the SD card. Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19efi_loader: enable EFI_LOADER on arm1136 and arm1176Heinrich Schuchardt1-2/+4
With an implementation for allow_unaligned() available for arm1136 and arm1176 UEFI can be supported on these architectures. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19efi_loader: restrict EFI_LOADER to armv7 and armv8 on ARMHeinrich Schuchardt1-1/+4
fatload USB was reported to fail on the Sheevaplug. Debugging showed that this was caused by an incorrect unaligned write to memory in path_to_uefi(). UEFI on ARM requires that unaligned memory access is enabled. * ARMv5 does not support unaligned access at all. * ARMv6 supports unaligned access when we clear the A flag and set the U flag. * On ARMv7 unaligned access is possible when clearing the aligned flag, which we do in function allow_unaligned() (arch/arm/cpu/armv7/sctlr.S). For none of the other cpus in arch/arm/cpu/ we have implemented a similar function. * ARMv8 allows unaligned access. Let EFI_LOADER on ARM depend on SYS_CPU=armv7 or SYS_CPU=armv8. Once we have implemented allow_unaligned() for other ARM CPUs we can add these to Kconfig. Reported-by: Gray Remlin <gryrmln@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-19efi_loader: remove unused function efi_dp_from_dev()Heinrich Schuchardt1-16/+2
Function efi_dp_from_dev() is not used anywhere. Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-13efi_loader: support building UEFI binaries on sandboxHeinrich Schuchardt1-0/+3
On the sandbox the UEFI binaries must match the host architectures. Adjust the Makefiles. Provide the PE/COFF header and relocation files. Allow building helloworld.efi on the sandbox. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-13efi_loader: call add_u_boot_and_runtime() on sandboxHeinrich Schuchardt1-4/+5
On the sandbox we should mark the stack area as EFI runtime memory like we do on any other architecture. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-13efi_loader: disk: install file system protocol to a whole diskAKASHI Takahiro1-1/+3
Currently, a whole disk without any partitions is not associated with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some file system, there is a chance that we may not be able to access it, particularly, when accesses are to be attempted after searching that protocol against a device handle. With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed to such a disk if part_get_info() shows there is no partition table installed on it. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Only if no partition table exists, check for a file system on disk level. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-13efi_loader: fix efi_dp_from_name()Heinrich Schuchardt1-3/+12
Correctly check the return value of efi_dp_from_file(). If we can determine device path for the file, should not depend on the device path for the device being requested. Provide a function description for efi_dp_from_name(). Reported-by: Coverity CID 273159, CID 273158 Fixes: 08c51fff30cc ("efi_loader: device_path: check against file path length") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-30efi_loader: correct includes in efi_variable.cHeinrich Schuchardt1-5/+3
'make tests' on an 32bit ARM system leads to In file included from ../lib/efi_loader/efi_variable.c:9: ../include/malloc.h:364:7: error: conflicting types for ‘memset’ void* memset(void*, int, size_t); ^~~~~~ In file included from ../include/compiler.h:126, from ../include/env.h:12, from ../lib/efi_loader/efi_variable.c:8: ../include/linux/string.h:103:15: note: previous declaration of ‘memset’ was here extern void * memset(void *,int,__kernel_size_t); ^~~~~~ In file included from ../lib/efi_loader/efi_variable.c:9: ../include/malloc.h:365:7: error: conflicting types for ‘memcpy’ void* memcpy(void*, const void*, size_t); ^~~~~~ In file included from ../include/compiler.h:126, from ../include/env.h:12, from ../lib/efi_loader/efi_variable.c:8: ../include/linux/string.h:106:15: note: previous declaration of ‘memcpy’ was here extern void * memcpy(void *,const void *,__kernel_size_t); ^~~~~~ Use common.h as first include as recommended by the U-Boot coding style guide. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-17efi_loader: disk: install FILE_SYSTEM_PROTOCOL only if availableAKASHI Takahiro1-1/+23
In the current implementation, EFI_SIMPLEFILE_SYSTEM_PROTOCOL is always installed to all the partitions even if some of them may house no file system. With this patch, that protocol will be installed only if any file system exists. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-17efi_loader: device_path: check against file path lengthAKASHI Takahiro1-2/+9
device_path strcuture has 2 bytes of "length" field, and so file path length should not exceed this limit, 65535. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06efi: device path for nvmePatrick Wildt2-0/+35
This allows our EFI API to create a device path node for NVMe devices. It adds the necessary device path struct, uses the nvme namespace accessor to retrieve the id and eui64, and also provides support for the device path text protocol. Signed-off-by: Patrick Wildt <patrick@blueri.se> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06efi_loader: appending to non-existent variableHeinrich Schuchardt1-4/+6
Appending to a non-existent variable must result in an error of type EFI_NOT_FOUND. Fixes: 09c76b79a9db ("efi_loader: SetVariable() deleting variables") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23efi_loader: SetVariable() deleting variablesHeinrich Schuchardt1-5/+6
APPEND_WRITE with data length zero is allowable according to the UEFI specification. The EDK2 interpretation of no access attributes is attributes = 0. As the UEFI specification is vague in this respect let's stick to EDK2 here. Fixes: commit 6d2f27c5fd60 ("efi_loader: variable: support APPEND_WRITE") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23efi_loader: SetVariable() fix illegal returnHeinrich Schuchardt1-1/+1
We always have to return via EFI_EXIT() from EFIAPI functions. Coverity reported an unreachable line and a resource leak. Fixes: commit 6d2f27c5fd60 ("efi_loader: variable: support APPEND_WRITE") Reported-by: Coverity Scan CID 253575, CID 184095 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-23efi_loader: description efi_stri_coll()Heinrich Schuchardt1-5/+0
Remove outdated TODO for efi_stri_coll(). efi_stri_coll() is already using the Unicode capitalization table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20efi_loader: variable: support APPEND_WRITEAKASHI Takahiro1-26/+44
If EFI_VARIABLE_APPEND_WRITE is specified in attributes at efi_set_variable(), specified data will be appended to the variable's original value. Attributes other than APPEND_WRITE should not be modified. With this patch, APPEND_WRITE test in 'variables' selftest will pass. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2019-09-20efi_loader: incorrect return value form DisconnectControllerHeinrich Schuchardt1-12/+14
DisconnectController() should never return EFI_NOT_FOUND. If EFI_DRIVER_BINDING_PROTOCOL.Stop() fails, return EFI_DEVICE_ERROR. If the driver handle does not expose the EFI_DRIVER_BINDING_PROTOCOL return EFI_INVALID_PARAMETER. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20efi_loader: device_path: support Sandbox's "host" devicesAKASHI Takahiro1-0/+33
Sandbox's "host" devices are currently described as UCLASS_ROOT udevice with DEV_IF_HOST block device. As the current implementation of efi_device_path doesn't support such a type, any "host" device on sandbox cannot be seen as a distinct object. For example, => host bind 0 /foo/disk.img => efi devices Scanning disk host0... Found 1 disks Device Device Path ================ ==================== 0000000015c19970 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) 0000000015c19d70 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) => efi dh Handle Protocols ================ ==================== 0000000015c19970 Device Path, Device Path To Text, Device Path Utilities, Unicode Collation 2, HII String, HII Database, HII Config Routing 0000000015c19ba0 Driver Binding 0000000015c19c10 Simple Text Output 0000000015c19c80 Simple Text Input, Simple Text Input Ex 0000000015c19d70 Block IO, Device Path, Simple File System As you can see here, efi_root (0x0000000015c19970) and host0 device (0x0000000015c19d70) have the same representation of device path. This is not only inconvenient, but also confusing since two different efi objects are associated with the same device path and efi_dp_find_obj() will possibly return a wrong result. Solution: Each "host" device should be given an additional device path node of "vendor device path" to make it distinguishable. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-11efi_loader: parameter checks EFI_FILE_PROTOCOL.SetInfo()Heinrich Schuchardt1-6/+4
We do not support volume label changes. No parameter checks are needed here. When the info for as file is changed the buffer must always contain a file name. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()Heinrich Schuchardt1-0/+6
Check the parameters of EFI_FILE_PROTOCOL.GetInfo() to avoid possible NULL dereference. Check the buffer size for EFI_FILE_SYSTEM_INFO. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: volume name in EFI_FILE_PROTOCOL.GetInfo()Heinrich Schuchardt1-6/+12
We cannot determine the volume name in U-Boot. Instead of providing a dummy volume name in case of EFI_FILE_SYSTEM_INFO and EFI_UNSUPPORTED in case of EFI_FILE_SYSTEM_VOLUME_LABEL consistently return an empty string. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: EFI_FILE_PROTOCOL rev 2 stubHeinrich Schuchardt1-5/+31
The UEFI specification requires to implement version 2 of the EFI_FILE_PROTOCOL. Provide the missing functions as stubs. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: file size checksHeinrich Schuchardt1-29/+40
The file size has to be determined in multiple places. Factor out a common function. If on entry into EFI_FILE_PROTOCOL.Read() the current position is beyond the end of the file, return EFI_DEVICE_ERROR. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: correct reading of directoriesHeinrich Schuchardt1-18/+5
EFI_FILE_PROTOCOL.Read() is used both to read files and directories. When reaching the end of a directory we always have to return buffer size zero irrespective of the incoming buffer size. (The described scenario for a Shim quirk cannot arise because every directory has at least '.' and '..' as entries.) Even when the buffer_size is too small multiple times we have to keep a reference to our last read directory entry. When we return to the start of the directory via SetPosition() we must remove the reference to a previously kept directory entry. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: eliminate inline function ascii2unicode()Heinrich Schuchardt2-13/+20
ascii2unicode() can only convert characters 0x00-0x7f from UTF-8 to UTF-16. Use utf8_utf16_strcpy() instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-09efi_loader: EFI_FILE_PROTOCOL.Write() check argsHeinrich Schuchardt1-10/+41
Check the parameters passed to Write(): * cannot write to directories (UEFI SCT 2017, 5.7.3.5.15) * cannot write to file opened read only (UEFI SCT 2017, 5.7.3.5.16) Add missing comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06doc: UEFI API documentationHeinrich Schuchardt3-9/+13
Add some more files to the UEFI API documentation. Correct some Sphinx comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: EFI_BLOCK_IO_PROTOCOL.Reset()Heinrich Schuchardt1-1/+16
We cannot do anything in EFI_BLOCK_IO_PROTOCOL.Reset() but this does not justify to return an error. Let EFI_BLOCK_IO_PROTOCOL.Reset() return EFI_SUCCESS. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: use EFI_PRINT() instead of debug()Heinrich Schuchardt1-3/+3
EFI_PRINT() offers indention of debug messages. Adjust the debug messages of the BLOCK_IO_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: parameter checks BLOCK_IO_PROTOCOLHeinrich Schuchardt1-1/+36
Check parameters of ReadBlocks() and WriteBlocks(). If the buffer size is not a multiple of the block size, we have to return EFI_BAD_BUFFER_SIZE. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: do not set invalid screen modeHeinrich Schuchardt1-0/+4
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetMode() should return EFI_UNDEFINED if a screen mode is not available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@csgraf.de>
2019-09-06efi_loader: cursor positioningHeinrich Schuchardt1-5/+13
When backspacing in column 0 do no set the column index to ULONG_MAX. Ensure that the row number is not set to ULONG_MAX even if the row count is advertised as 0. Ignore control characters other the 0x08, 0x0a, 0x0d when updating the column. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: correctly render UsbClass DP nodes as textHeinrich Schuchardt1-1/+1
Correct the text representation of UsbClass device path nodes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: correctly render CD-ROM device path nodesHeinrich Schuchardt2-2/+3
Correct the name of the partition size component in struct efi_device_path_cdrom_path. Render entry, start, and size when converting a CD-ROM device path node to text. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: correctly render MAC address device path nodesHeinrich Schuchardt1-8/+7
If the interface type is greater 1 render all 32 bytes of the MAC address. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: correct text conversion for vendor DPHeinrich Schuchardt1-1/+10
Vendor device paths may contain data. When converting vendor device paths to text this binary data has to be rendered. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: Extract adding a conventional memory in separate routinePark, Aiden1-32/+50
Adding a conventional memory region to the memory map may require ram_top limitation and it can be also commonly used. Extract adding a conventional memory to the memory map in a separate routine for generic use. Signed-off-by: Aiden Park <aiden.park@intel.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: implement MCastIPtoMACHeinrich Schuchardt1-2/+42
Implement the MCastIPtoMAC service of the simple network protocol. It converts an multicast IPv4 (or IPv6) address to a multicast Ethernet address. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: fix status management in network stackHeinrich Schuchardt1-7/+62
The network should start in status EfiSimpleNetworkStopped. Add and correct status checks in the simple network protocol. Correct the unit test: * Shutdown() and Stop() during setup if needed * invoke Shutdown() before Stop() when tearing down Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: EFI_SIMPLE_NETWORK.Transmit() fill headerHeinrich Schuchardt1-6/+25
Fill the media header in EFI_SIMPLE_NETWORK.Transmit(). Check that the buffer size is large enough for the header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: interrupts in simple network protocolHeinrich Schuchardt1-15/+25
GetStatus() must clear the interrupt status. Transmit() should set the TX interrupt. Receive() should clear the RX interrupt. Initialize() and Start() should clear the interrupt status. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15efi_loader: do not call efi_runtime_detach twiceHeinrich Schuchardt1-9/+4
Commit 7f95104d91cc ("efi_loader: detach runtime in ExitBootServices()") added a call to efi_runtime_detach() to ExitBootServices() but did not remove the call in SetVirtualAddressMap(). Remove the superfluous function call. Correct a comment referring to efi_runtime_detach(). Fixes: 7f95104d91cc ("efi_loader: detach runtime in ExitBootServices()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15efi_loader: parameter check in SetVirtualAddressMapHeinrich Schuchardt1-3/+10
Check the parameters DescriptorSize and DescriptiorVersion of SetVirtualAddressMap() as prescribed by the UEFI specification. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-15efi_loader: EFI_PXE_BASE_CODE_PROTOCOL stubHeinrich Schuchardt1-3/+129
U-Boot implements the EFI_PXE_BASE_CODE_PROTOCOL because GRUB uses the mode information for booting via PXE. All function pointers in the protocol were NULL up to now which will cause immediate crashes when the services of the protocol are called. Create function stubs for all services of the protocol returning EFI_UNSUPPORTED. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>