blob: 4d7fb74b5d6fba184070ff216bad01ac779fe138 [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
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +02008#include <malloc.h>
Heinrich Schuchardt94686f62020-12-13 10:30:24 +01009#include <efi_dt_fixup.h>
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020010#include <efi_loader.h>
11
12const efi_guid_t efi_u_boot_guid = U_BOOT_GUID;
13
AKASHI Takahiroa2a4bc32019-04-16 13:24:20 +090014efi_handle_t efi_root = NULL;
15
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020016struct efi_root_dp {
17 struct efi_device_path_vendor vendor;
18 struct efi_device_path end;
19} __packed;
20
21/**
22 * efi_root_node_register() - create root node
23 *
24 * Create the root node on which we install all protocols that are
25 * not related to a loaded image or a driver.
26 *
27 * Return: status code
28 */
29efi_status_t efi_root_node_register(void)
30{
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020031 efi_status_t ret;
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020032 struct efi_root_dp *dp;
33
Heinrich Schuchardtf1465c12019-04-12 07:14:43 +020034 /* Create device path protocol */
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020035 dp = calloc(1, sizeof(*dp));
36 if (!dp)
37 return EFI_OUT_OF_RESOURCES;
38
39 /* Fill vendor node */
40 dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
41 dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
42 dp->vendor.dp.length = sizeof(struct efi_device_path_vendor);
43 dp->vendor.guid = efi_u_boot_guid;
44
45 /* Fill end node */
46 dp->end.type = DEVICE_PATH_TYPE_END;
47 dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
48 dp->end.length = sizeof(struct efi_device_path);
49
Heinrich Schuchardtf1465c12019-04-12 07:14:43 +020050 /* Create root node and install protocols */
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030051 ret = efi_install_multiple_protocol_interfaces
52 (&efi_root,
53 /* Device path protocol */
54 &efi_guid_device_path, dp,
Heinrich Schuchardt64b5ba42019-05-11 09:53:33 +020055#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT)
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030056 /* Device path to text protocol */
57 &efi_guid_device_path_to_text_protocol,
58 &efi_device_path_to_text,
Heinrich Schuchardt64b5ba42019-05-11 09:53:33 +020059#endif
Simon Glass5cf99522023-02-05 15:39:41 -070060#if IS_ENABLED(CONFIG_EFI_DEVICE_PATH_UTIL)
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030061 /* Device path utilities protocol */
62 &efi_guid_device_path_utilities_protocol,
63 &efi_device_path_utilities,
Heinrich Schuchardt59593a52021-01-16 09:44:25 +010064#endif
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030065#if CONFIG_IS_ENABLED(EFI_DT_FIXUP)
66 /* Device-tree fix-up protocol */
67 &efi_guid_dt_fixup_protocol,
68 &efi_dt_fixup_prot,
Heinrich Schuchardt94686f62020-12-13 10:30:24 +010069#endif
Simon Glassbed72232023-02-05 15:39:47 -070070#if IS_ENABLED(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2)
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030071 &efi_guid_unicode_collation_protocol2,
72 &efi_unicode_collation_protocol2,
Heinrich Schuchardt33499732019-05-08 23:24:26 +020073#endif
Simon Glassda841532023-02-05 15:39:43 -070074#if IS_ENABLED(CONFIG_EFI_LOADER_HII)
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030075 /* HII string protocol */
76 &efi_guid_hii_string_protocol,
77 &efi_hii_string,
78 /* HII database protocol */
79 &efi_guid_hii_database_protocol,
80 &efi_hii_database,
Heinrich Schuchardt8ec7d5d2019-04-07 23:53:53 +020081#endif
Ilias Apalodimas05c4c9e2022-10-06 16:08:46 +030082 NULL);
Heinrich Schuchardt84a918e2019-05-05 16:55:06 +020083 efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
84 return ret;
Heinrich Schuchardt4e6b5d62018-09-20 21:58:23 +020085}