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 | |
| 8 | #include <common.h> |
| 9 | #include <malloc.h> |
| 10 | #include <efi_loader.h> |
| 11 | |
| 12 | const efi_guid_t efi_u_boot_guid = U_BOOT_GUID; |
| 13 | |
AKASHI Takahiro | 0b27575 | 2019-04-16 13:24:20 +0900 | [diff] [blame] | 14 | efi_handle_t efi_root = NULL; |
| 15 | |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 16 | struct 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 | */ |
| 29 | efi_status_t efi_root_node_register(void) |
| 30 | { |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 31 | efi_status_t ret; |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 32 | struct efi_root_dp *dp; |
| 33 | |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 34 | /* Create device path protocol */ |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 35 | 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 Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 50 | /* Create root node and install protocols */ |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 51 | ret = EFI_CALL(efi_install_multiple_protocol_interfaces |
| 52 | (&efi_root, |
| 53 | /* Device path protocol */ |
| 54 | &efi_guid_device_path, dp, |
Heinrich Schuchardt | 3db3591 | 2019-05-11 09:53:33 +0200 | [diff] [blame] | 55 | #if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT) |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 56 | /* Device path to text protocol */ |
| 57 | &efi_guid_device_path_to_text_protocol, |
| 58 | (void *)&efi_device_path_to_text, |
Heinrich Schuchardt | 3db3591 | 2019-05-11 09:53:33 +0200 | [diff] [blame] | 59 | #endif |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 60 | /* Device path utilities protocol */ |
| 61 | &efi_guid_device_path_utilities_protocol, |
| 62 | (void *)&efi_device_path_utilities, |
Heinrich Schuchardt | b325884 | 2019-05-16 07:52:58 +0200 | [diff] [blame] | 63 | #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2) |
Heinrich Schuchardt | 18ed8cf | 2019-05-16 18:19:00 +0200 | [diff] [blame] | 64 | #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL) |
| 65 | /* Deprecated Unicode collation protocol */ |
| 66 | &efi_guid_unicode_collation_protocol, |
| 67 | (void *)&efi_unicode_collation_protocol, |
| 68 | #endif |
| 69 | /* Current Unicode collation protocol */ |
Heinrich Schuchardt | b325884 | 2019-05-16 07:52:58 +0200 | [diff] [blame] | 70 | &efi_guid_unicode_collation_protocol2, |
| 71 | (void *)&efi_unicode_collation_protocol2, |
Heinrich Schuchardt | 532fec7 | 2019-05-08 23:24:26 +0200 | [diff] [blame] | 72 | #endif |
Heinrich Schuchardt | 926e696 | 2019-04-07 23:53:53 +0200 | [diff] [blame] | 73 | #if CONFIG_IS_ENABLED(EFI_LOADER_HII) |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 74 | /* HII string protocol */ |
| 75 | &efi_guid_hii_string_protocol, |
| 76 | (void *)&efi_hii_string, |
| 77 | /* HII database protocol */ |
| 78 | &efi_guid_hii_database_protocol, |
| 79 | (void *)&efi_hii_database, |
| 80 | /* HII configuration routing protocol */ |
| 81 | &efi_guid_hii_config_routing_protocol, |
| 82 | (void *)&efi_hii_config_routing, |
Heinrich Schuchardt | 926e696 | 2019-04-07 23:53:53 +0200 | [diff] [blame] | 83 | #endif |
Sughosh Ganu | 693a4f4 | 2019-12-29 00:01:06 +0530 | [diff] [blame] | 84 | #if CONFIG_IS_ENABLED(EFI_RNG_PROTOCOL) |
| 85 | &efi_guid_rng_protocol, |
| 86 | (void *)&efi_rng_protocol, |
| 87 | #endif |
Heinrich Schuchardt | 2e0a790 | 2019-05-05 16:55:06 +0200 | [diff] [blame] | 88 | NULL)); |
| 89 | efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE; |
| 90 | return ret; |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 91 | } |