blob: b411a12cf660a80f88a48727beb12b3a09433eba [file] [log] [blame]
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Root node for system services
4 *
5 * Copyright (c) 2018 Heinrich Schuchardt
6 */
7
8#include <common.h>
9#include <malloc.h>
Heinrich Schuchardt94686f62020-12-13 10:30:24 +010010#include <efi_dt_fixup.h>
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020011#include <efi_loader.h>
12
13const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
14
AKASHI Takahiroa2a4bc32019-04-16 13:24:20 +090015efi_handle_t efi_root = NULL;
16
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020017struct efi_root_dp {
18 struct efi_device_path_vendor vendor;
19 struct efi_device_path end;
20} __packed;
21
22/**
23 * efi_root_node_register() - create root node
24 *
25 * Create the root node on which we install all protocols that are
26 * not related to a loaded image or a driver.
27 *
28 * Return: status code
29 */
30efi_status_t efi_root_node_register(void)
31{
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020032 efi_status_t ret;
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020033 struct efi_root_dp *dp;
34
Heinrich Schuchardtf1465c12019-04-12 07:14:43 +020035 /* Create device path protocol */
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020036 dp = calloc(1, sizeof(*dp));
37 if (!dp)
38 return EFI_OUT_OF_RESOURCES;
39
40 /* Fill vendor node */
41 dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
42 dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
43 dp->vendor.dp.length = sizeof(struct efi_device_path_vendor);
44 dp->vendor.guid = efi_u_boot_guid;
45
46 /* Fill end node */
47 dp->end.type = DEVICE_PATH_TYPE_END;
48 dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
49 dp->end.length = sizeof(struct efi_device_path);
50
Heinrich Schuchardtf1465c12019-04-12 07:14:43 +020051 /* Create root node and install protocols */
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020052 ret = EFI_CALL(efi_install_multiple_protocol_interfaces
53 (&efi_root,
54 /* Device path protocol */
55 &efi_guid_device_path, dp,
Heinrich Schuchardt64b5ba42019-05-11 09:53:33 +020056#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020057 /* Device path to text protocol */
58 &efi_guid_device_path_to_text_protocol,
59 (void *)&efi_device_path_to_text,
Heinrich Schuchardt64b5ba42019-05-11 09:53:33 +020060#endif
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020061 /* Device path utilities protocol */
62 &efi_guid_device_path_utilities_protocol,
63 (void *)&efi_device_path_utilities,
Heinrich Schuchardt94686f62020-12-13 10:30:24 +010064#if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
65 /* Device-tree fix-up protocol */
66 &efi_guid_dt_fixup_protocol,
67 (void *)&efi_dt_fixup_prot,
68#endif
Heinrich Schuchardt95ab3812019-05-16 07:52:58 +020069#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2)
Heinrich Schuchardtb1b782d2019-05-16 18:19:00 +020070#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
71 /* Deprecated Unicode collation protocol */
72 &efi_guid_unicode_collation_protocol,
73 (void *)&efi_unicode_collation_protocol,
74#endif
75 /* Current Unicode collation protocol */
Heinrich Schuchardt95ab3812019-05-16 07:52:58 +020076 &efi_guid_unicode_collation_protocol2,
77 (void *)&efi_unicode_collation_protocol2,
Heinrich Schuchardt33499732019-05-08 23:24:26 +020078#endif
Heinrich Schuchardt8ec7d5d2019-04-07 23:53:53 +020079#if CONFIG_IS_ENABLED(EFI_LOADER_HII)
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020080 /* HII string protocol */
81 &efi_guid_hii_string_protocol,
82 (void *)&efi_hii_string,
83 /* HII database protocol */
84 &efi_guid_hii_database_protocol,
85 (void *)&efi_hii_database,
Heinrich Schuchardt8ec7d5d2019-04-07 23:53:53 +020086#endif
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020087 NULL));
88 efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
89 return ret;
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020090}