Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Root node for system services |
| 4 | * |
| 5 | * Copyright (c) 2018 Heinrich Schuchardt |
| 6 | */ |
| 7 | |
Heinrich Schuchardt | 955a321 | 2025-01-16 20:26:59 +0100 | [diff] [blame] | 8 | #define LOG_CATEGORY LOGC_EFI |
| 9 | |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 10 | #include <malloc.h> |
Heinrich Schuchardt | 2c1e224 | 2020-12-13 10:30:24 +0100 | [diff] [blame] | 11 | #include <efi_dt_fixup.h> |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 12 | #include <efi_loader.h> |
| 13 | |
| 14 | const efi_guid_t efi_u_boot_guid = U_BOOT_GUID; |
| 15 | |
AKASHI Takahiro | 0b27575 | 2019-04-16 13:24:20 +0900 | [diff] [blame] | 16 | efi_handle_t efi_root = NULL; |
| 17 | |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 18 | struct efi_root_dp { |
| 19 | struct efi_device_path_vendor vendor; |
| 20 | struct efi_device_path end; |
| 21 | } __packed; |
| 22 | |
| 23 | /** |
| 24 | * efi_root_node_register() - create root node |
| 25 | * |
| 26 | * Create the root node on which we install all protocols that are |
| 27 | * not related to a loaded image or a driver. |
| 28 | * |
| 29 | * Return: status code |
| 30 | */ |
| 31 | efi_status_t efi_root_node_register(void) |
| 32 | { |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 33 | efi_status_t ret; |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 34 | struct efi_root_dp *dp; |
| 35 | |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 36 | /* Create device path protocol */ |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 37 | dp = calloc(1, sizeof(*dp)); |
| 38 | if (!dp) |
| 39 | return EFI_OUT_OF_RESOURCES; |
| 40 | |
| 41 | /* Fill vendor node */ |
| 42 | dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; |
| 43 | dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; |
| 44 | dp->vendor.dp.length = sizeof(struct efi_device_path_vendor); |
| 45 | dp->vendor.guid = efi_u_boot_guid; |
| 46 | |
| 47 | /* Fill end node */ |
| 48 | dp->end.type = DEVICE_PATH_TYPE_END; |
| 49 | dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END; |
| 50 | dp->end.length = sizeof(struct efi_device_path); |
| 51 | |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 52 | /* Create root node and install protocols */ |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 53 | ret = efi_install_multiple_protocol_interfaces |
| 54 | (&efi_root, |
| 55 | /* Device path protocol */ |
| 56 | &efi_guid_device_path, dp, |
Heinrich Schuchardt | 3db3591 | 2019-05-11 09:53:33 +0200 | [diff] [blame] | 57 | #if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT) |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 58 | /* Device path to text protocol */ |
| 59 | &efi_guid_device_path_to_text_protocol, |
| 60 | &efi_device_path_to_text, |
Heinrich Schuchardt | 3db3591 | 2019-05-11 09:53:33 +0200 | [diff] [blame] | 61 | #endif |
Simon Glass | 3e26ee4 | 2023-02-05 15:39:41 -0700 | [diff] [blame] | 62 | #if IS_ENABLED(CONFIG_EFI_DEVICE_PATH_UTIL) |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 63 | /* Device path utilities protocol */ |
| 64 | &efi_guid_device_path_utilities_protocol, |
| 65 | &efi_device_path_utilities, |
Heinrich Schuchardt | 1cb1a9d | 2021-01-16 09:44:25 +0100 | [diff] [blame] | 66 | #endif |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 67 | #if CONFIG_IS_ENABLED(EFI_DT_FIXUP) |
| 68 | /* Device-tree fix-up protocol */ |
| 69 | &efi_guid_dt_fixup_protocol, |
| 70 | &efi_dt_fixup_prot, |
Heinrich Schuchardt | 2c1e224 | 2020-12-13 10:30:24 +0100 | [diff] [blame] | 71 | #endif |
Simon Glass | 8f43811 | 2023-02-05 15:39:47 -0700 | [diff] [blame] | 72 | #if IS_ENABLED(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 73 | &efi_guid_unicode_collation_protocol2, |
| 74 | &efi_unicode_collation_protocol2, |
Heinrich Schuchardt | 532fec7 | 2019-05-08 23:24:26 +0200 | [diff] [blame] | 75 | #endif |
Simon Glass | 6b52ab5 | 2023-02-05 15:39:43 -0700 | [diff] [blame] | 76 | #if IS_ENABLED(CONFIG_EFI_LOADER_HII) |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 77 | /* HII string protocol */ |
| 78 | &efi_guid_hii_string_protocol, |
| 79 | &efi_hii_string, |
| 80 | /* HII database protocol */ |
| 81 | &efi_guid_hii_database_protocol, |
| 82 | &efi_hii_database, |
Heinrich Schuchardt | 926e696 | 2019-04-07 23:53:53 +0200 | [diff] [blame] | 83 | #endif |
Ilias Apalodimas | 8ac0ebe | 2022-10-06 16:08:46 +0300 | [diff] [blame] | 84 | NULL); |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 85 | efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE; |
| 86 | return ret; |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 87 | } |