summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | efi_loader: Kconfig entries for GetTime(), SetTime()Heinrich Schuchardt2019-06-014-15/+26
| | | | | | | | | | | | | | The GetTime() and the SetTime() runtime services are not obligatory. So let's make them customizable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: handling of daylight saving timeHeinrich Schuchardt2019-05-311-4/+5
| | | | | | | | | | | | | | | | | | | | If SetTime() is meant to set daylight saving time it will be called with Time.Daylight == EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT. Return 0 from GetTime() if time is not in daylight because we cannot determine if we are in a time zone with daylight saving time. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: check time in SetTime()Heinrich Schuchardt2019-05-311-1/+25
| | | | | | | | | | | | | | The UEFI spec prescribes that we check that the timestamp passed to SetTime() is checked for validity. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: correct UninstallProtocolInterface()Heinrich Schuchardt2019-05-311-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When uninstalling a protocol the following steps are needed: * request all drivers to disconnect * close protocol for all non-drivers * check if any open instance of the protocol exists on the handle and return EFI_ACCESS_DENIED in this case * remove the protocol interface By tort we tested for remaining open protocol instances already after requesting drivers to disconnect. With this correction the UEFI SCT II tests for UninstallProtocolInterface() and ReinstallProtocolInterface are passed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: avoid crash in OpenProtocol()Heinrich Schuchardt2019-05-311-9/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | When trying to open a protocol exclusively attached drivers have to be removed. This removes entries in the open protocol information linked list over which we are looping. As additionally child controllers may have been removed the only safe thing to do is to restart the loop over the linked list when a driver is removed. By observing the return code of DisconnectController() we can eliminate a loop. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: correct OpenProtocol()Heinrich Schuchardt2019-05-311-3/+11
| | | | | | | | | | | | | | If a protocol is opened BY_DRIVER it cannot be opened by another agent BY_DRIVER. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: registration key in LocateProtocol()Heinrich Schuchardt2019-05-311-10/+39
| | | | | | | | | | | | | | In LocateProtocol() implement searching by the registration key returned by RegisterNotifyProtocol(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: factor out efi_check_register_notify_event()Heinrich Schuchardt2019-05-311-8/+23
| | | | | | | | | | | | | | | | The code to check if a registration key is a valid key returned by RegisterProtocolNotify() can be reused. So let us factor it out into a new function efi_check_register_notify_event(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: bootmgr: print a message when loading from BootNext failedAKASHI Takahiro2019-05-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a user defines BootNext but not BootOrder and loading from BootNext fails, you will see only a message like this: BootOrder not defined This may confuse a user. Adding an error message will be helpful. An example output looks like this: => efidebug boot add 0001 label1 scsi 0:1 "\path1\file1.efi" "--option foo" => efidebug boot add 0002 label2 scsi 0:1 "\path2\file2.efi" "--option bar" => efidebug boot add 0003 label3 scsi 0:1 "\path3\file3.efi" "--option no" => efidebug boot order 0001 0002 => efidebug boot next 0003 => bootefi bootmgr Loading from Boot0003 'label3' failed Loading from BootNext failed, falling back to BootOrder Loading from Boot0001 'label1' failed Loading from Boot0002 'label2' failed EFI boot manager: Cannot load any image Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Adjust messages. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: correct notification of protocol installationHeinrich Schuchardt2019-05-312-21/+58
|/ | | | | | | | | | | | | | | | When a protocol is installed the handle should be queued for the registration key of each registered event. LocateHandle() should return the first handle from the queue for the registration key and delete it from the queue. Implement the queueing. Correct the selftest. With the patch the UEFI SCT tests for LocateHandle() are passed without failure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: variable: attributes may not be changed if a variable existsAKASHI Takahiro2019-05-241-2/+11
| | | | | | | | If a variable already exists, efi_set_variable() should not change the variable's attributes. This patch enforces it. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: variable: return error for APPEND_WRITEAKASHI Takahiro2019-05-241-1/+3
| | | | | | | | | | | | | The current efi_st_variable() doesn't support EFI_VARIABLE_APPEND_WRITE attiribute for now, and so should return an error. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Fix typos is commit message. Add TODO comment. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi: selftest: APPEND_WRITE is not supportedAKASHI Takahiro2019-05-241-14/+14
| | | | | | | The error here should be marked *todo*. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: DEL is an illegal file name characterHeinrich Schuchardt2019-05-241-1/+1
| | | | | | | According to the FAT32 specification 0x7f (DEL) is not a legal character for file names. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correct device path checkHeinrich Schuchardt2019-05-241-1/+4
| | | | | | | | | | | | | | | | Since commit 226cddbe32f0 ("efi_loader: check device path in InstallMultipleProtocolInterfaces") iPXE fails to access the network. LocateDevicePath() returns EFI_SUCCESS even if a shorter path is found as a partial match. It returns the remaining path. So to be sure that we found a complete match we need to check that the remaining path refers to an end node. Provide debug output if a device path has already been installed. Fixes: 226cddbe32f0 ("efi_loader: check device path in InstallMultipleProtocolInterfaces") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: return values of GetTime()Heinrich Schuchardt2019-05-241-7/+7
| | | | | | | According to the UEFI spec 2.8 the GetTime() runtime service should return EFI_UNSUPPORTED if the real time clock is not available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement SetTimeHeinrich Schuchardt2019-05-242-9/+120
| | | | | | | | Implement the SetTime() runtime service. Extend the real time clock selftest to check setting the clock. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* fdtdec: Remove fdt_{addr,size}_unpack()Thierry Reding2019-05-212-4/+12
| | | | | | | U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding <treding@nvidia.com>
* efi_loader: parameter check OutputStringHeinrich Schuchardt2019-05-191-0/+5
| | | | | | Check the parameters against NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.SetState() correct parameterHeinrich Schuchardt2019-05-191-3/+3
| | | | | | KeyToggleState is a pointer according to UEFI spec 2.8. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: GetNextMonotonicCount() check parameterHeinrich Schuchardt2019-05-191-1/+8
| | | | | | | | Do not write to address indicated by NULL pointer. UEFI SCT II 2.6 (2017), 3.6.5 GetNextMonotonicCount(), 5.1.5.5.1 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: parameter checks CalculateCrc32()Heinrich Schuchardt2019-05-191-1/+8
| | | | | | | Not checking the parameters may lead reading or writing from NULL. Implement the parameter checks prescribed in the UEFI spec. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: check device path in InstallMultipleProtocolInterfacesHeinrich Schuchardt2019-05-191-0/+12
| | | | | | | | | | | According to the UEFI spec InstallMultipleProtocolInterfaces() must check if a device path has already been installed. In this case it must return EFI_ALREADY_STARTED. Cf. UEFI SCT II 2.6 A (2017), 3.3.16 InstallMultipleProtocolInterfaces(), 5.1.3.16.1. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement deprecated Unicode collation protocolHeinrich Schuchardt2019-05-193-1/+44
| | | | | | | | | | | | | | | | | | In EFI 1.10 a version of the Unicode collation protocol using ISO 639-2 language codes existed. This protocol is not part of the UEFI specification any longer. Unfortunately it is required to run the UEFI Self Certification Test (SCT) II, version 2.6, 2017. So we implement it here for the sole purpose of running the SCT. It can be removed once a compliant SCT is available. The configuration option defaults to no. Signed-off-by: Rob Clark <robdclark@gmail.com> Most of Rob's original patch is already merged. Only the deprecated protocol is missing. Rebase it and make it configurable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: rename Unicode collation protocol 2 variablesHeinrich Schuchardt2019-05-195-10/+11
| | | | | | | Rename variables to make it clear they refer to the Unicode collation protocol identified by the EFI_UNICODE_PROTOCOL2_GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: merge adjacent sprintf()Heinrich Schuchardt2019-05-191-3/+2
| | | | | | | In the implementation of the device path to text protocol join adjacent sprintf() statements. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: parameter checks simple network protocolHeinrich Schuchardt2019-05-191-3/+3
| | | | | | | | | Check buffer pointers are not NULL as required by the UEFI 2.7 spec. Return EFI_UNSUPPORTED instead of EFI_INVALID_PARAMETER when trying to transmit with non-zero header_size. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: GetVariable set attributes for EFI_BUFFER_TOO_SMALLHeinrich Schuchardt2019-05-191-5/+10
| | | | | | | | | | | | UEFI spec 2.7 erratum A leaves it undefined if Attributes should be set if GetVariable() returns EFI_BUFFER_TOO_SMALL. UEFI spec 2.8 defines that Attributes should be set if the return value is either EFI_SUCCESS or EFI_BUFFER_TOO_SMALL. Set Attributes if the return value is EFI_BUFFER_TOO_SMALL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: ACPI device node to textHeinrich Schuchardt2019-05-121-3/+3
| | | | | | | | | | | The device path to text protocol renders ACPI device nodes incorrectly. Use capital hexadecimal numbers as shown in the UEFI spec examples. Always output the optional UID. This matches what UEFI SCT expects and saves us an `if`. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: infinite recursion notifying eventsHeinrich Schuchardt2019-05-121-1/+3
| | | | | | | | | | | | | | | | UEFI SCT uses this call sequence to determine the current TPL level inside notification functions: OldTpl = BS->RaiseTPL(TPL_HIGH_LEVEL); BS->RestoreTPL(OldTpl); In RestoreTPL() we trigger the notification function of queued events. If we do not mark the event as non-queued before calling the notification function, this results in an infinite recursive call sequence. Mark the event as non-queued before entering the notification function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: simplify efi_allocate_pages()Heinrich Schuchardt2019-05-121-28/+15
| | | | | | Replace unnecessary control structures by using return statements. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: AllocateAdress error handlingHeinrich Schuchardt2019-05-121-6/+13
| | | | | | | | | | | | | | If AllocatePages() is called with AllocateAddress, the UEFI spec requires to return EFI_NOT_FOUND in case the memory page does not exist. The UEFI SCT II 2017 spec additionally requires to return EFI_NOT_FOUND if the page is already allocated. Check that *Memory refers to an unallocated page. UEFI SCT II (2017): AllocatePages(), 5.1.2.1.9 - 5.1.2.1.10 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: out of resources in AllocatePages()Heinrich Schuchardt2019-05-121-2/+2
| | | | | | | | | | | According to the UEFI AllocatePages() has to return EFI_OUT_OF_RESOURCES if sufficient memory is not available. Change the return value. UEFI SCT II (2017): 3.2.1 AllocatePages(), 5.1.2.1.8 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: check memory address before freeingHeinrich Schuchardt2019-05-121-5/+47
| | | | | | | | | | | | | | When we call FreePages() we essentially add memory to our memory map. We shouldn't do this for memory that does not exit. Check if the memory that is to be freed via FreePages() or FreePool() is in our memory map and is not EFI_CONVENTIONAL_MEMORY. This check is mandated by the UEFI specification. Cf. UEFI SCT II (2017), 3.2.2 FreePages(), 5.1.2.1 - 5.1.2.2 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: error code in UninstallProtocolInterface()Heinrich Schuchardt2019-05-121-1/+1
| | | | | | | | | | | According to the UEFI specification UninstallProtocolInteface() has to return EFI_NOT_FOUND if the interface is not found. Correct the return value. Cf. UEFI SCT II spec (2017), 3.3.2 UninstallProtocolInterface(), 5.1.3.2.4 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: superfluous check in efi_remove_protocol()Heinrich Schuchardt2019-05-121-2/+0
| | | | | | | efi_search_protocol() already checks that the GUID matches. Don't check a second time. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: LocateDevicePath() incorrect parameter checkHeinrich Schuchardt2019-05-121-1/+5
| | | | | | | | | | | | A parameter check in LocateDevicePath() does not match the requirements of the UEFI spec. If device is NULL, only return EFI_INVALID_PARAMETER if a matching handle is found. Cf. UEFI SCT II specification (2017)3.3.7 LocateDevicePath(), 5.1.3.7.3 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix typo in efi_locate_handle() commentHeinrich Schuchardt2019-05-121-1/+1
| | | | | | %s/not buffer/no buffer/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: make device path to text protocol customizableHeinrich Schuchardt2019-05-125-3/+14
| | | | | | | The device path to text protocol is not needed for EBBR compliance. So let's make it a customizable option. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: make Unicode collation protocol customizableHeinrich Schuchardt2019-05-124-2/+16
| | | | | | | | | | The Unicode collation protocol is not needed for EBBR compliance. So let's make it a customizable option. The Unicode capitalization table is only needed by this protocol. So let it depend on the Unicode collation protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: reword the EFI_LOADER config optionHeinrich Schuchardt2019-05-121-5/+5
| | | | | | | No need to mention U-Boot in brief description. Fix several typos, mention iPXE. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: format KconfigHeinrich Schuchardt2019-05-121-21/+22
| | | | | | | | | | Use if/endif for dependencies to give structure to the configuration menu. Sort important settings to the top. Abbreviate the short description of EFI_LOADER_HII. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: observe CONFIG_EFI_LOADER_HIIHeinrich Schuchardt2019-05-121-1/+1
| | | | | | | If EFI_LOADER_HII is not set, do not unnecessarily compile files for HII protocols. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: signature of ExitBootServices()Heinrich Schuchardt2019-05-071-2/+2
| | | | | | | Consistently use efi_uintn_t as type of memory keys. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <graf@amazon.com>
* efi_loader: LoadImage() check source sizeHeinrich Schuchardt2019-05-071-0/+4
| | | | | | | If the size of the source buffer is 0, return EFI_LOAD_ERROR. (UEFI SCT II 2017: 3.4.1 LoadImage() - 5.1.4.1.6) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: LoadImage() check parent imageHeinrich Schuchardt2019-05-072-23/+32
| | | | | | | | | | | If the parent image handle does not refer to a loaded image return EFI_INVALID_PARAMETER. (UEFI SCT II 2017: 3.4.1 LoadImage() - 5.1.4.1.1) Mark our root node as a loaded image to avoid an error when using it as parent image. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: HandleProtocol parameter checksHeinrich Schuchardt2019-05-071-1/+8
| | | | | | | HandleProtocol() and OpenProtocol() have to return EFI_UNSUPPORTED if the protocol is not installed on the handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: use EFI_PRINT instead of debugHeinrich Schuchardt2019-05-071-10/+7
| | | | | | | For correct indentation of messages in the UEFI API implementation use EFI_PRINT() instead of debug(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: CloseProtocol() requires valid agent handleHeinrich Schuchardt2019-05-071-2/+5
| | | | | | | | | | | | Return EFI_INVALID_PARAMETER from CloseProtcol() if the agent handle is not valid. Return EFI_INVALID_PARAMETER if the optional controller handle is not valid. Return immediately from efi_search_obj if the handle is NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: unit test for RegisterProtocolNotify()Heinrich Schuchardt2019-05-072-0/+232
| | | | | | Provide a unit test for the RegisterProtocolNotify() boot service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>