mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-17 10:18:38 +00:00
05c4c9e21a
A following patch is cleaning up the core EFI code trying to remove sequences of efi_create_handle, efi_add_protocol. Although this works fine there's a problem with the latter since it is usually combined with efi_delete_handle() which blindly removes all protocols on a handle and deletes the handle. We should try to adhere to the EFI spec which only deletes a handle if the last instance of a protocol has been removed. Another problem is that efi_delete_handle() never checks for opened protocols, but the EFI spec defines that the caller is responsible for ensuring that there are no references to a protocol interface that is going to be removed. So let's fix this by replacing all callsites of efi_create_handle(), efi_add_protocol() , efi_delete_handle() with Install/UninstallMultipleProtocol. In order to do that redefine functions that can be used by the U-Boot proper internally and add '_ext' variants that will be used from the EFI API Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
86 lines
2.2 KiB
C
86 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Root node for system services
|
|
*
|
|
* Copyright (c) 2018 Heinrich Schuchardt
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <malloc.h>
|
|
#include <efi_dt_fixup.h>
|
|
#include <efi_loader.h>
|
|
|
|
const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
|
|
|
|
efi_handle_t efi_root = NULL;
|
|
|
|
struct efi_root_dp {
|
|
struct efi_device_path_vendor vendor;
|
|
struct efi_device_path end;
|
|
} __packed;
|
|
|
|
/**
|
|
* efi_root_node_register() - create root node
|
|
*
|
|
* Create the root node on which we install all protocols that are
|
|
* not related to a loaded image or a driver.
|
|
*
|
|
* Return: status code
|
|
*/
|
|
efi_status_t efi_root_node_register(void)
|
|
{
|
|
efi_status_t ret;
|
|
struct efi_root_dp *dp;
|
|
|
|
/* Create device path protocol */
|
|
dp = calloc(1, sizeof(*dp));
|
|
if (!dp)
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
/* Fill vendor node */
|
|
dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
|
|
dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
|
|
dp->vendor.dp.length = sizeof(struct efi_device_path_vendor);
|
|
dp->vendor.guid = efi_u_boot_guid;
|
|
|
|
/* Fill end node */
|
|
dp->end.type = DEVICE_PATH_TYPE_END;
|
|
dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
|
|
dp->end.length = sizeof(struct efi_device_path);
|
|
|
|
/* Create root node and install protocols */
|
|
ret = efi_install_multiple_protocol_interfaces
|
|
(&efi_root,
|
|
/* Device path protocol */
|
|
&efi_guid_device_path, dp,
|
|
#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
|
|
/* Device path to text protocol */
|
|
&efi_guid_device_path_to_text_protocol,
|
|
&efi_device_path_to_text,
|
|
#endif
|
|
#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_UTIL)
|
|
/* Device path utilities protocol */
|
|
&efi_guid_device_path_utilities_protocol,
|
|
&efi_device_path_utilities,
|
|
#endif
|
|
#if CONFIG_IS_ENABLED(EFI_DT_FIXUP)
|
|
/* Device-tree fix-up protocol */
|
|
&efi_guid_dt_fixup_protocol,
|
|
&efi_dt_fixup_prot,
|
|
#endif
|
|
#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2)
|
|
&efi_guid_unicode_collation_protocol2,
|
|
&efi_unicode_collation_protocol2,
|
|
#endif
|
|
#if CONFIG_IS_ENABLED(EFI_LOADER_HII)
|
|
/* HII string protocol */
|
|
&efi_guid_hii_string_protocol,
|
|
&efi_hii_string,
|
|
/* HII database protocol */
|
|
&efi_guid_hii_database_protocol,
|
|
&efi_hii_database,
|
|
#endif
|
|
NULL);
|
|
efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
|
|
return ret;
|
|
}
|