"Das U-Boot" Source Tree
at master 87 lines 2.3 kB view raw
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Root node for system services 4 * 5 * Copyright (c) 2018 Heinrich Schuchardt 6 */ 7 8#define LOG_CATEGORY LOGC_EFI 9 10#include <malloc.h> 11#include <efi_dt_fixup.h> 12#include <efi_loader.h> 13 14const efi_guid_t efi_u_boot_guid = U_BOOT_GUID; 15 16efi_handle_t efi_root = NULL; 17 18struct 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 */ 31efi_status_t efi_root_node_register(void) 32{ 33 efi_status_t ret; 34 struct efi_root_dp *dp; 35 36 /* Create device path protocol */ 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 52 /* Create root node and install protocols */ 53 ret = efi_install_multiple_protocol_interfaces 54 (&efi_root, 55 /* Device path protocol */ 56 &efi_guid_device_path, dp, 57#if CONFIG_IS_ENABLED(EFI_DEVICE_PATH_TO_TEXT) 58 /* Device path to text protocol */ 59 &efi_guid_device_path_to_text_protocol, 60 &efi_device_path_to_text, 61#endif 62#if IS_ENABLED(CONFIG_EFI_DEVICE_PATH_UTIL) 63 /* Device path utilities protocol */ 64 &efi_guid_device_path_utilities_protocol, 65 &efi_device_path_utilities, 66#endif 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, 71#endif 72#if IS_ENABLED(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) 73 &efi_guid_unicode_collation_protocol2, 74 &efi_unicode_collation_protocol2, 75#endif 76#if IS_ENABLED(CONFIG_EFI_LOADER_HII) 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, 83#endif 84 NULL); 85 efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE; 86 return ret; 87}