1 /** @file 2 3 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR> 4 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #ifndef __FDT_PLATFORM_DXE_H__ 16 #define __FDT_PLATFORM_DXE_H__ 17 18 #include <Uefi.h> 19 20 #include <Protocol/DevicePathToText.h> 21 #include <Protocol/DevicePathFromText.h> 22 #include <Protocol/Shell.h> 23 #include <Protocol/ShellDynamicCommand.h> 24 25 #include <Library/DebugLib.h> 26 #include <Library/HiiLib.h> 27 #include <Library/MemoryAllocationLib.h> 28 #include <Library/UefiBootServicesTableLib.h> 29 #include <Library/UefiLib.h> 30 #include <Library/ShellLib.h> 31 #include <Library/UefiRuntimeServicesTableLib.h> 32 33 #include <Guid/Fdt.h> 34 35 #include <libfdt.h> 36 37 extern EFI_HANDLE mFdtPlatformDxeHiiHandle; 38 39 /** 40 Transcode one of the EFI return code used by the model into an EFI Shell return code. 41 42 @param[in] Status EFI return code. 43 44 @return Transcoded EFI Shell return code. 45 46 **/ 47 SHELL_STATUS 48 EfiCodeToShellCode ( 49 IN EFI_STATUS Status 50 ); 51 52 /** 53 Run the FDT installation process. 54 55 Loop in priority order over the device paths from which the FDT has 56 been asked to be retrieved for. For each device path, try to install 57 the FDT. Stop as soon as an installation succeeds. 58 59 @param[in] SuccessfullDevicePath If not NULL, address where to store the 60 pointer to the text device path from 61 which the FDT was successfully retrieved. 62 Not used if the FDT installation failed. 63 The returned address is the address of 64 an allocated buffer that has to be 65 freed by the caller. 66 67 @retval EFI_SUCCESS The FDT was installed. 68 @retval EFI_NOT_FOUND Failed to locate a protocol or a file. 69 @retval EFI_INVALID_PARAMETER Invalid device path. 70 @retval EFI_UNSUPPORTED Device path not supported. 71 @retval EFI_OUT_OF_RESOURCES An allocation failed. 72 73 **/ 74 EFI_STATUS 75 RunFdtInstallation ( 76 OUT CHAR16 **SuccessfullDevicePath 77 ); 78 79 /** 80 This is the shell command "setfdt" handler function. This function handles 81 the command when it is invoked in the shell. 82 83 @param[in] This The instance of the 84 EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. 85 @param[in] SystemTable The pointer to the UEFI system table. 86 @param[in] ShellParameters The parameters associated with the command. 87 @param[in] Shell The instance of the shell protocol used in the 88 context of processing this command. 89 90 @return SHELL_SUCCESS The operation was successful. 91 @return SHELL_ABORTED Operation aborted due to internal error. 92 @return SHELL_INVALID_PARAMETER The parameters of the command are not valid. 93 @return SHELL_INVALID_PARAMETER The EFI Shell file path is not valid. 94 @return SHELL_NOT_FOUND Failed to locate a protocol or a file. 95 @return SHELL_UNSUPPORTED Device path not supported. 96 @return SHELL_OUT_OF_RESOURCES A memory allocation failed. 97 @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure. 98 @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only. 99 @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted. 100 @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation. 101 102 **/ 103 SHELL_STATUS 104 EFIAPI 105 ShellDynCmdSetFdtHandler ( 106 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, 107 IN EFI_SYSTEM_TABLE *SystemTable, 108 IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, 109 IN EFI_SHELL_PROTOCOL *Shell 110 ); 111 112 /** 113 This is the shell command "setfdt" help handler function. This 114 function returns the formatted help for the "setfdt" command. 115 The format matchs that in Appendix B of the revision 2.1 of the 116 UEFI Shell Specification. 117 118 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. 119 @param[in] Language The pointer to the language string to use. 120 121 @return CHAR16* Pool allocated help string, must be freed by caller. 122 **/ 123 CHAR16* 124 EFIAPI 125 ShellDynCmdSetFdtGetHelp ( 126 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, 127 IN CONST CHAR8 *Language 128 ); 129 130 /** 131 This is the shell command "dumpfdt" handler function. This function handles 132 the command when it is invoked in the shell. 133 134 @param[in] This The instance of the 135 EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. 136 @param[in] SystemTable The pointer to the UEFI system table. 137 @param[in] ShellParameters The parameters associated with the command. 138 @param[in] Shell The instance of the shell protocol used in the 139 context of processing this command. 140 141 @return SHELL_SUCCESS The operation was successful. 142 @return SHELL_ABORTED Operation aborted due to internal error. 143 @return SHELL_NOT_FOUND Failed to locate the Device Tree into the EFI Configuration Table 144 @return SHELL_OUT_OF_RESOURCES A memory allocation failed. 145 146 **/ 147 SHELL_STATUS 148 EFIAPI 149 ShellDynCmdDumpFdtHandler ( 150 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, 151 IN EFI_SYSTEM_TABLE *SystemTable, 152 IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, 153 IN EFI_SHELL_PROTOCOL *Shell 154 ); 155 156 /** 157 This is the shell command "dumpfdt" help handler function. This 158 function returns the formatted help for the "dumpfdt" command. 159 The format matchs that in Appendix B of the revision 2.1 of the 160 UEFI Shell Specification. 161 162 @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. 163 @param[in] Language The pointer to the language string to use. 164 165 @return CHAR16* Pool allocated help string, must be freed by caller. 166 **/ 167 CHAR16* 168 EFIAPI 169 ShellDynCmdDumpFdtGetHelp ( 170 IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, 171 IN CONST CHAR8 *Language 172 ); 173 174 #endif /* __FDT_PLATFORM_DXE_H__ */ 175