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 | |
| 14 | struct efi_root_dp { |
| 15 | struct efi_device_path_vendor vendor; |
| 16 | struct efi_device_path end; |
| 17 | } __packed; |
| 18 | |
| 19 | /** |
| 20 | * efi_root_node_register() - create root node |
| 21 | * |
| 22 | * Create the root node on which we install all protocols that are |
| 23 | * not related to a loaded image or a driver. |
| 24 | * |
| 25 | * Return: status code |
| 26 | */ |
| 27 | efi_status_t efi_root_node_register(void) |
| 28 | { |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 29 | efi_handle_t root = NULL; |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 30 | struct efi_root_dp *dp; |
| 31 | |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 32 | /* Create device path protocol */ |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 33 | dp = calloc(1, sizeof(*dp)); |
| 34 | if (!dp) |
| 35 | return EFI_OUT_OF_RESOURCES; |
| 36 | |
| 37 | /* Fill vendor node */ |
| 38 | dp->vendor.dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; |
| 39 | dp->vendor.dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; |
| 40 | dp->vendor.dp.length = sizeof(struct efi_device_path_vendor); |
| 41 | dp->vendor.guid = efi_u_boot_guid; |
| 42 | |
| 43 | /* Fill end node */ |
| 44 | dp->end.type = DEVICE_PATH_TYPE_END; |
| 45 | dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END; |
| 46 | dp->end.length = sizeof(struct efi_device_path); |
| 47 | |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 48 | /* Create root node and install protocols */ |
| 49 | return EFI_CALL(efi_install_multiple_protocol_interfaces(&root, |
| 50 | /* Device path protocol */ |
| 51 | &efi_guid_device_path, dp, |
| 52 | /* Device path to text protocol */ |
| 53 | &efi_guid_device_path_to_text_protocol, |
| 54 | (void *)&efi_device_path_to_text, |
| 55 | /* Device path utilities protocol */ |
| 56 | &efi_guid_device_path_utilities_protocol, |
| 57 | (void *)&efi_device_path_utilities, |
| 58 | /* Unicode collation protocol */ |
| 59 | &efi_guid_unicode_collation_protocol, |
| 60 | (void *)&efi_unicode_collation_protocol, |
Heinrich Schuchardt | 926e696 | 2019-04-07 23:53:53 +0200 | [diff] [blame] | 61 | #if CONFIG_IS_ENABLED(EFI_LOADER_HII) |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 62 | /* HII string protocol */ |
| 63 | &efi_guid_hii_string_protocol, |
| 64 | (void *)&efi_hii_string, |
| 65 | /* HII database protocol */ |
| 66 | &efi_guid_hii_database_protocol, |
| 67 | (void *)&efi_hii_database, |
| 68 | /* HII configuration routing protocol */ |
| 69 | &efi_guid_hii_config_routing_protocol, |
| 70 | (void *)&efi_hii_config_routing, |
Heinrich Schuchardt | 926e696 | 2019-04-07 23:53:53 +0200 | [diff] [blame] | 71 | #endif |
Heinrich Schuchardt | 22b9fb9 | 2019-04-12 07:14:43 +0200 | [diff] [blame] | 72 | NULL)); |
Heinrich Schuchardt | 79d7202 | 2018-09-20 21:58:23 +0200 | [diff] [blame] | 73 | } |