2018-09-20 19:58:23 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Root node for system services
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 Heinrich Schuchardt
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <malloc.h>
|
2020-12-13 09:30:24 +00:00
|
|
|
#include <efi_dt_fixup.h>
|
2018-09-20 19:58:23 +00:00
|
|
|
#include <efi_loader.h>
|
|
|
|
|
|
|
|
const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
|
|
|
|
|
2019-04-16 04:24:20 +00:00
|
|
|
efi_handle_t efi_root = NULL;
|
|
|
|
|
2018-09-20 19:58:23 +00:00
|
|
|
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)
|
|
|
|
{
|
2019-05-05 14:55:06 +00:00
|
|
|
efi_status_t ret;
|
2018-09-20 19:58:23 +00:00
|
|
|
struct efi_root_dp *dp;
|
|
|
|
|
2019-04-12 05:14:43 +00:00
|
|
|
/* Create device path protocol */
|
2018-09-20 19:58:23 +00:00
|
|
|
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);
|
|
|
|
|
2019-04-12 05:14:43 +00:00
|
|
|
/* Create root node and install protocols */
|
2022-10-06 13:08:46 +00:00
|
|
|
ret = efi_install_multiple_protocol_interfaces
|
|
|
|
(&efi_root,
|
|
|
|
/* Device path protocol */
|
|
|
|
&efi_guid_device_path, dp,
|
2019-05-11 07:53:33 +00:00
|
|
|
#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
|
2022-10-06 13:08:46 +00:00
|
|
|
/* Device path to text protocol */
|
|
|
|
&efi_guid_device_path_to_text_protocol,
|
|
|
|
&efi_device_path_to_text,
|
2019-05-11 07:53:33 +00:00
|
|
|
#endif
|
2023-02-05 22:39:41 +00:00
|
|
|
#if IS_ENABLED(CONFIG_EFI_DEVICE_PATH_UTIL)
|
2022-10-06 13:08:46 +00:00
|
|
|
/* Device path utilities protocol */
|
|
|
|
&efi_guid_device_path_utilities_protocol,
|
|
|
|
&efi_device_path_utilities,
|
2021-01-16 08:44:25 +00:00
|
|
|
#endif
|
2022-10-06 13:08:46 +00:00
|
|
|
#if CONFIG_IS_ENABLED(EFI_DT_FIXUP)
|
|
|
|
/* Device-tree fix-up protocol */
|
|
|
|
&efi_guid_dt_fixup_protocol,
|
|
|
|
&efi_dt_fixup_prot,
|
2020-12-13 09:30:24 +00:00
|
|
|
#endif
|
2023-02-05 22:39:47 +00:00
|
|
|
#if IS_ENABLED(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2)
|
2022-10-06 13:08:46 +00:00
|
|
|
&efi_guid_unicode_collation_protocol2,
|
|
|
|
&efi_unicode_collation_protocol2,
|
2019-05-08 21:24:26 +00:00
|
|
|
#endif
|
2023-02-05 22:39:43 +00:00
|
|
|
#if IS_ENABLED(CONFIG_EFI_LOADER_HII)
|
2022-10-06 13:08:46 +00:00
|
|
|
/* HII string protocol */
|
|
|
|
&efi_guid_hii_string_protocol,
|
|
|
|
&efi_hii_string,
|
|
|
|
/* HII database protocol */
|
|
|
|
&efi_guid_hii_database_protocol,
|
|
|
|
&efi_hii_database,
|
2019-04-07 21:53:53 +00:00
|
|
|
#endif
|
2022-10-06 13:08:46 +00:00
|
|
|
NULL);
|
2019-05-05 14:55:06 +00:00
|
|
|
efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
|
|
|
|
return ret;
|
2018-09-20 19:58:23 +00:00
|
|
|
}
|