aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2019-10-03dm: core: Correct low cell in ofnode_read_pci_addr()Simon Glass
This reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from. Fixes: 9e51204527 (dm: core: Add operations on device tree references) Fixes: 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT) Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-09-23efi_loader: SetVariable() deleting variablesHeinrich Schuchardt
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 Schuchardt
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 Schuchardt
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-20lib: charset: add u16_str<n>cmp()AKASHI Takahiro
u16 version of strcmp(): u16_strncmp() works like u16_strcmp() but only at most n characters (in u16) are compared. This function will be used in my UEFI secure boot patch. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20efi_loader: selftest: enable APPEND_WRITE testsAKASHI Takahiro
Now that APPEND_WRITE is supported, the result check for the only existing test case should be changed to 'todo' to 'error', while two more test cases are added. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20efi_loader: variable: support APPEND_WRITEAKASHI Takahiro
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 Schuchardt
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 Takahiro
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 Schuchardt
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 Schuchardt
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 Schuchardt
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 Schuchardt
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 Schuchardt
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 Schuchardt
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 Schuchardt
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 Schuchardt
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-05doc: UEFI API documentationHeinrich Schuchardt
Add some more files to the UEFI API documentation. Correct some Sphinx comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05efi_loader: EFI_BLOCK_IO_PROTOCOL.Reset()Heinrich Schuchardt
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-05efi_loader: use EFI_PRINT() instead of debug()Heinrich Schuchardt
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-05efi_loader: parameter checks BLOCK_IO_PROTOCOLHeinrich Schuchardt
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-05efi_loader: do not set invalid screen modeHeinrich Schuchardt
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-05efi_loader: cursor positioningHeinrich Schuchardt
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-05efi_loader: correctly render UsbClass DP nodes as textHeinrich Schuchardt
Correct the text representation of UsbClass device path nodes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05efi_loader: correctly render CD-ROM device path nodesHeinrich Schuchardt
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-05efi_loader: correctly render MAC address device path nodesHeinrich Schuchardt
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-05efi_loader: correct text conversion for vendor DPHeinrich Schuchardt
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-05efi_loader: Extract adding a conventional memory in separate routinePark, Aiden
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-05efi_loader: implement MCastIPtoMACHeinrich Schuchardt
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-05efi_loader: fix status management in network stackHeinrich Schuchardt
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-05efi_loader: EFI_SIMPLE_NETWORK.Transmit() fill headerHeinrich Schuchardt
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-05efi_selftest: check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPTHeinrich Schuchardt
Check that when the WaitForPacket event occurs EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT is set. Check the return value of Receive(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-05efi_loader: interrupts in simple network protocolHeinrich Schuchardt
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-29efi_selftest: use standalone UEFI program for exceptionHeinrich Schuchardt
To fully demonstrate crash outputs for UEFI images provide a standalone UEFI application that tries to invoke an illegal opcode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-29efi_selftest: enable Exit() unit test on x86_64Heinrich Schuchardt
Enable unit tests for StartImage() and Exit() unit tests on x86_64. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-26fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPLLukas Auer
The current preprocessor logic prevents CONFIG_OF_PRIOR_STAGE from being used in U-Boot SPL. Change the logic to also make it available in U-Boot SPL. Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2019-08-15efi_loader: do not call efi_runtime_detach twiceHeinrich Schuchardt
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 Schuchardt
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 Schuchardt
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>
2019-08-11env: Rename environment.h to env_internal.hSimon Glass
This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-08-11env: Drop environment.h header file where not neededSimon Glass
This header file is now only used by files that access internal environment features. Drop it from various places where it is not needed. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Drop the ACTION typedefSimon Glass
Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to both the enum and its members to make it clear that these are related to the environment. Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Drop _ENTRYSimon Glass
This typedef does not need to be defined in the search.h header since it is only used in one file (hashtable.c). Remove it from the header and change it to a struct. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Drop the ENTRY typedefSimon Glass
U-Boot is not supposed to use typedef for structs anymore. Also this name is the same as the ENTRY() macro used in assembler files, and 'entry' itself is widely used in U-Boot (>8k matches). Drop the typedef and rename the struct to env_entry to reduce confusion. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-08-11env: Move env_get() to env.hSimon Glass
Move env_get() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Move env_set() to env.hSimon Glass
Move env_set() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Move env_get_ulong() to env.hSimon Glass
Move env_get_ulong() over to the new header file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-08-11common: Move gzip functions into a new gzip headerSimon Glass
As part of the effort to remove things from common.h, create a new header for the gzip functions. Move the function declarations to it and add missing documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-07-30efi_selftest: sharpen ConvertPointer() testHeinrich Schuchardt
Now that ConvertPointer() is implemented throw an error if the result is incorrect. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30efi_loader: implement ConvertPointer()Heinrich Schuchardt
Implement the ConvertPointer() runtime service. Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>