1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * EFI setup code 4 * 5 * Copyright (c) 2016-2018 Alexander Graf et al. 6 */ 7 8 #include <common.h> 9 #include <efi_loader.h> 10 11 #define OBJ_LIST_NOT_INITIALIZED 1 12 13 static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; 14 15 /* Initialize and populate EFI object list */ efi_init_obj_list(void)16efi_status_t efi_init_obj_list(void) 17 { 18 efi_status_t ret = EFI_SUCCESS; 19 20 /* 21 * On the ARM architecture gd is mapped to a fixed register (r9 or x18). 22 * As this register may be overwritten by an EFI payload we save it here 23 * and restore it on every callback entered. 24 */ 25 efi_save_gd(); 26 27 /* Initialize once only */ 28 if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) 29 return efi_obj_list_initialized; 30 31 /* Initialize system table */ 32 ret = efi_initialize_system_table(); 33 if (ret != EFI_SUCCESS) 34 goto out; 35 36 /* Initialize root node */ 37 ret = efi_root_node_register(); 38 if (ret != EFI_SUCCESS) 39 goto out; 40 41 /* Initialize EFI driver uclass */ 42 ret = efi_driver_init(); 43 if (ret != EFI_SUCCESS) 44 goto out; 45 46 ret = efi_console_register(); 47 if (ret != EFI_SUCCESS) 48 goto out; 49 #ifdef CONFIG_PARTITIONS 50 ret = efi_disk_register(); 51 if (ret != EFI_SUCCESS) 52 goto out; 53 #endif 54 #if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO) 55 ret = efi_gop_register(); 56 if (ret != EFI_SUCCESS) 57 goto out; 58 #endif 59 #ifdef CONFIG_NET 60 ret = efi_net_register(); 61 if (ret != EFI_SUCCESS) 62 goto out; 63 #endif 64 #ifdef CONFIG_GENERATE_ACPI_TABLE 65 ret = efi_acpi_register(); 66 if (ret != EFI_SUCCESS) 67 goto out; 68 #endif 69 #ifdef CONFIG_GENERATE_SMBIOS_TABLE 70 ret = efi_smbios_register(); 71 if (ret != EFI_SUCCESS) 72 goto out; 73 #endif 74 ret = efi_watchdog_register(); 75 if (ret != EFI_SUCCESS) 76 goto out; 77 78 /* Initialize EFI runtime services */ 79 ret = efi_reset_system_init(); 80 if (ret != EFI_SUCCESS) 81 goto out; 82 83 out: 84 efi_obj_list_initialized = ret; 85 return ret; 86 } 87