+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "FdtPlatform.h"\r
-\r
-#include <Library/PcdLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BdsLib.h>\r
-\r
-#include <Protocol/DevicePath.h>\r
-\r
-//\r
-// Internal variables\r
-//\r
-\r
-STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolSetFdt = {\r
- L"setfdt", // Name of the command\r
- ShellDynCmdSetFdtHandler, // Handler\r
- ShellDynCmdSetFdtGetHelp // GetHelp\r
-};\r
-\r
-STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolDumpFdt = {\r
- L"dumpfdt", // Name of the command\r
- ShellDynCmdDumpFdtHandler, // Handler\r
- ShellDynCmdDumpFdtGetHelp // GetHelp\r
-};\r
-\r
-STATIC CONST EFI_GUID mFdtPlatformDxeHiiGuid = {\r
- 0x8afa7610, 0x62b1, 0x46aa,\r
- {0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}\r
- };\r
-\r
-EFI_HANDLE mFdtPlatformDxeHiiHandle;\r
-\r
-/**\r
- Install the FDT specified by its device path in text form.\r
-\r
- @param[in] TextDevicePath Device path of the FDT to install in text form\r
-\r
- @retval EFI_SUCCESS The FDT was installed.\r
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.\r
- @retval EFI_INVALID_PARAMETER Invalid device path.\r
- @retval EFI_UNSUPPORTED Device path not supported.\r
- @retval EFI_OUT_OF_RESOURCES An allocation failed.\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-InstallFdt (\r
- IN CONST CHAR16* TextDevicePath\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;\r
- EFI_DEVICE_PATH *DevicePath;\r
- EFI_PHYSICAL_ADDRESS FdtBlobBase;\r
- UINTN FdtBlobSize;\r
- UINTN NumPages;\r
- EFI_PHYSICAL_ADDRESS FdtConfigurationTableBase;\r
-\r
- Status = gBS->LocateProtocol (\r
- &gEfiDevicePathFromTextProtocolGuid,\r
- NULL,\r
- (VOID **)&EfiDevicePathFromTextProtocol\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "InstallFdt() - Failed to locate EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol\n"));\r
- return Status;\r
- }\r
-\r
- DevicePath = (EFI_DEVICE_PATH*)EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (TextDevicePath);\r
- if (DevicePath == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Load the FDT given its device path.\r
- // This operation may fail if the device path is not supported.\r
- //\r
- FdtBlobBase = 0;\r
- NumPages = 0;\r
- Status = BdsLoadImage (DevicePath, AllocateAnyPages, &FdtBlobBase, &FdtBlobSize);\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- //\r
- // Ensure that the FDT header is valid and that the Size of the Device Tree\r
- // is smaller than the size of the read file\r
- //\r
- if (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) != 0 ||\r
- (UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) > FdtBlobSize) {\r
- DEBUG ((EFI_D_ERROR, "InstallFdt() - loaded FDT binary image seems corrupt\n"));\r
- Status = EFI_LOAD_ERROR;\r
- goto Error;\r
- }\r
-\r
- //\r
- // Store the FDT as Runtime Service Data to prevent the Kernel from\r
- // overwritting its data.\r
- //\r
- NumPages = EFI_SIZE_TO_PAGES (FdtBlobSize);\r
- Status = gBS->AllocatePages (\r
- AllocateAnyPages, EfiRuntimeServicesData,\r
- NumPages, &FdtConfigurationTableBase\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
- CopyMem (\r
- (VOID*)(UINTN)FdtConfigurationTableBase,\r
- (VOID*)(UINTN)FdtBlobBase,\r
- FdtBlobSize\r
- );\r
-\r
- //\r
- // Install the FDT into the Configuration Table\r
- //\r
- Status = gBS->InstallConfigurationTable (\r
- &gFdtTableGuid,\r
- (VOID*)(UINTN)FdtConfigurationTableBase\r
- );\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePages (FdtConfigurationTableBase, NumPages);\r
- }\r
-\r
-Error:\r
- if (FdtBlobBase != 0) {\r
- gBS->FreePages (FdtBlobBase, NumPages);\r
- }\r
- FreePool (DevicePath);\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Main entry point of the FDT platform driver.\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the present driver\r
- UEFI image.\r
- @param[in] *SystemTable A pointer to the EFI System table.\r
-\r
- @retval EFI_SUCCESS The driver was initialized.\r
- @retval EFI_OUT_OF_RESOURCES The "End of DXE" event could not be allocated or\r
- there was not enough memory in pool to install\r
- the Shell Dynamic Command protocol.\r
- @retval EFI_LOAD_ERROR Unable to add the HII package.\r
-\r
-**/\r
-EFI_STATUS\r
-FdtPlatformEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_HANDLE Handle;\r
-\r
- //\r
- // Install the Device Tree from its expected location\r
- //\r
- Status = RunFdtInstallation (NULL);\r
-\r
- if (FeaturePcdGet (PcdOverridePlatformFdt) || FeaturePcdGet (PcdDumpFdtShellCommand)) {\r
- //\r
- // Register the strings for the user interface in the HII Database.\r
- // This shows the way to the multi-language support, even if\r
- // only the English language is actually supported. The strings to register\r
- // are stored in the "ShellSetFdtStrings[]" array. This array is\r
- // built by the building process from the "*.uni" file associated to\r
- // the present driver (cf. FdtPlatfromDxe.inf). Examine your Build\r
- // folder under your package's DEBUG folder and you will find the array\r
- // defined in a xxxStrDefs.h file.\r
- //\r
- mFdtPlatformDxeHiiHandle = HiiAddPackages (\r
- &mFdtPlatformDxeHiiGuid,\r
- ImageHandle,\r
- FdtPlatformDxeStrings,\r
- NULL\r
- );\r
- }\r
-\r
- //\r
- // If the development features are enabled, install the dynamic shell\r
- // command "setfdt" to be able to define a device path for the FDT\r
- // that has precedence over the device paths defined by\r
- // "PcdFdtDevicePaths".\r
- //\r
-\r
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
- if (mFdtPlatformDxeHiiHandle != NULL) {\r
- // We install dynamic EFI command on separate handles as we cannot register\r
- // more than one protocol of the same protocol interface on the same handle.\r
- Handle = NULL;\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &Handle,\r
- &gEfiShellDynamicCommandProtocolGuid,\r
- &mShellDynCmdProtocolSetFdt,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- HiiRemovePackages (mFdtPlatformDxeHiiHandle);\r
- }\r
- } else {\r
- Status = EFI_LOAD_ERROR;\r
- }\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((\r
- EFI_D_WARN,\r
- "Unable to install \"setfdt\" EFI Shell command - %r \n",\r
- Status\r
- ));\r
- }\r
- }\r
-\r
- if (FeaturePcdGet (PcdDumpFdtShellCommand)) {\r
- if (mFdtPlatformDxeHiiHandle != NULL) {\r
- // We install dynamic EFI command on separate handles as we cannot register\r
- // more than one protocol of the same protocol interface on the same handle.\r
- Handle = NULL;\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &Handle,\r
- &gEfiShellDynamicCommandProtocolGuid,\r
- &mShellDynCmdProtocolDumpFdt,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- HiiRemovePackages (mFdtPlatformDxeHiiHandle);\r
- }\r
- } else {\r
- Status = EFI_LOAD_ERROR;\r
- }\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((\r
- EFI_D_WARN,\r
- "Unable to install \"dumpfdt\" EFI Shell command - %r \n",\r
- Status\r
- ));\r
- }\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Run the FDT installation process.\r
-\r
- Loop in priority order over the device paths from which the FDT has\r
- been asked to be retrieved for. For each device path, try to install\r
- the FDT. Stop as soon as an installation succeeds.\r
-\r
- @param[in] SuccessfullDevicePath If not NULL, address where to store the\r
- pointer to the text device path from\r
- which the FDT was successfully retrieved.\r
- Not used if the FDT installation failed.\r
- The returned address is the address of\r
- an allocated buffer that has to be\r
- freed by the caller.\r
-\r
- @retval EFI_SUCCESS The FDT was installed.\r
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.\r
- @retval EFI_INVALID_PARAMETER Invalid device path.\r
- @retval EFI_UNSUPPORTED Device path not supported.\r
- @retval EFI_OUT_OF_RESOURCES An allocation failed.\r
-\r
-**/\r
-EFI_STATUS\r
-RunFdtInstallation (\r
- OUT CHAR16 **SuccessfullDevicePath\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN DataSize;\r
- CHAR16 *TextDevicePath;\r
- CHAR16 *TextDevicePathStart;\r
- CHAR16 *TextDevicePathSeparator;\r
- UINTN TextDevicePathLen;\r
-\r
- TextDevicePath = NULL;\r
- //\r
- // For development purpose, if enabled through the "PcdOverridePlatformFdt"\r
- // feature PCD, try first to install the FDT specified by the device path in\r
- // text form stored in the "Fdt" UEFI variable.\r
- //\r
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
- DataSize = 0;\r
- Status = gRT->GetVariable (\r
- L"Fdt",\r
- &gFdtVariableGuid,\r
- NULL,\r
- &DataSize,\r
- NULL\r
- );\r
-\r
- //\r
- // Keep going only if the "Fdt" variable is defined.\r
- //\r
-\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- TextDevicePath = AllocatePool (DataSize);\r
- if (TextDevicePath == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
-\r
- Status = gRT->GetVariable (\r
- L"Fdt",\r
- &gFdtVariableGuid,\r
- NULL,\r
- &DataSize,\r
- TextDevicePath\r
- );\r
- if (EFI_ERROR (Status)) {\r
- FreePool (TextDevicePath);\r
- goto Error;\r
- }\r
-\r
- Status = InstallFdt (TextDevicePath);\r
- if (!EFI_ERROR (Status)) {\r
- DEBUG ((\r
- EFI_D_WARN,\r
- "Installation of the FDT using the device path <%s> completed.\n",\r
- TextDevicePath\r
- ));\r
- goto Done;\r
- }\r
- DEBUG ((\r
- EFI_D_ERROR,\r
- "Installation of the FDT specified by the \"Fdt\" UEFI variable failed - %r\n",\r
- Status\r
- ));\r
- FreePool (TextDevicePath);\r
- }\r
- }\r
-\r
- //\r
- // Loop over the device path list provided by "PcdFdtDevicePaths". The device\r
- // paths are in text form and separated by a semi-colon.\r
- //\r
-\r
- Status = EFI_NOT_FOUND;\r
- for (TextDevicePathStart = (CHAR16*)PcdGetPtr (PcdFdtDevicePaths);\r
- *TextDevicePathStart != L'\0' ; ) {\r
- TextDevicePathSeparator = StrStr (TextDevicePathStart, L";");\r
-\r
- //\r
- // Last device path of the list\r
- //\r
- if (TextDevicePathSeparator == NULL) {\r
- TextDevicePathLen = StrLen (TextDevicePathStart);\r
- } else {\r
- TextDevicePathLen = (UINTN)(TextDevicePathSeparator - TextDevicePathStart);\r
- }\r
-\r
- TextDevicePath = AllocateCopyPool (\r
- (TextDevicePathLen + 1) * sizeof (CHAR16),\r
- TextDevicePathStart\r
- );\r
- if (TextDevicePath == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
- TextDevicePath[TextDevicePathLen] = L'\0';\r
-\r
- Status = InstallFdt (TextDevicePath);\r
- if (!EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "Installation of the FDT using the device path <%s> completed.\n",\r
- TextDevicePath\r
- ));\r
- goto Done;\r
- }\r
-\r
- DEBUG ((EFI_D_WARN, "Installation of the FDT using the device path <%s> failed - %r.\n",\r
- TextDevicePath, Status\r
- ));\r
- FreePool (TextDevicePath);\r
-\r
- if (TextDevicePathSeparator == NULL) {\r
- goto Error;\r
- }\r
- TextDevicePathStart = TextDevicePathSeparator + 1;\r
- }\r
-\r
-Error:\r
-Done:\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "Failed to install the FDT - %r.\n", Status));\r
- return Status;\r
- }\r
-\r
- if (SuccessfullDevicePath != NULL) {\r
- *SuccessfullDevicePath = TextDevicePath;\r
- } else {\r
- FreePool (TextDevicePath);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Transcode one of the EFI return code used by the model into an EFI Shell return code.\r
-\r
- @param[in] Status EFI return code.\r
-\r
- @return Transcoded EFI Shell return code.\r
-\r
-**/\r
-SHELL_STATUS\r
-EfiCodeToShellCode (\r
- IN EFI_STATUS Status\r
- )\r
-{\r
- SHELL_STATUS ShellStatus;\r
-\r
- switch (Status) {\r
- case EFI_SUCCESS :\r
- ShellStatus = SHELL_SUCCESS;\r
- break;\r
-\r
- case EFI_INVALID_PARAMETER :\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- break;\r
-\r
- case EFI_UNSUPPORTED :\r
- ShellStatus = SHELL_UNSUPPORTED;\r
- break;\r
-\r
- case EFI_DEVICE_ERROR :\r
- ShellStatus = SHELL_DEVICE_ERROR;\r
- break;\r
-\r
- case EFI_WRITE_PROTECTED :\r
- case EFI_SECURITY_VIOLATION :\r
- ShellStatus = SHELL_ACCESS_DENIED;\r
- break;\r
-\r
- case EFI_OUT_OF_RESOURCES :\r
- ShellStatus = SHELL_OUT_OF_RESOURCES;\r
- break;\r
-\r
- case EFI_NOT_FOUND :\r
- ShellStatus = SHELL_NOT_FOUND;\r
- break;\r
-\r
- default :\r
- ShellStatus = SHELL_ABORTED;\r
- }\r
-\r
- return ShellStatus;\r
-}\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __FDT_PLATFORM_DXE_H__\r
-#define __FDT_PLATFORM_DXE_H__\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/DevicePathToText.h>\r
-#include <Protocol/DevicePathFromText.h>\r
-#include <Protocol/Shell.h>\r
-#include <Protocol/ShellDynamicCommand.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/ShellLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-\r
-#include <Guid/Fdt.h>\r
-\r
-#include <libfdt.h>\r
-\r
-extern EFI_HANDLE mFdtPlatformDxeHiiHandle;\r
-\r
-/**\r
- Transcode one of the EFI return code used by the model into an EFI Shell return code.\r
-\r
- @param[in] Status EFI return code.\r
-\r
- @return Transcoded EFI Shell return code.\r
-\r
-**/\r
-SHELL_STATUS\r
-EfiCodeToShellCode (\r
- IN EFI_STATUS Status\r
- );\r
-\r
-/**\r
- Run the FDT installation process.\r
-\r
- Loop in priority order over the device paths from which the FDT has\r
- been asked to be retrieved for. For each device path, try to install\r
- the FDT. Stop as soon as an installation succeeds.\r
-\r
- @param[in] SuccessfullDevicePath If not NULL, address where to store the\r
- pointer to the text device path from\r
- which the FDT was successfully retrieved.\r
- Not used if the FDT installation failed.\r
- The returned address is the address of\r
- an allocated buffer that has to be\r
- freed by the caller.\r
-\r
- @retval EFI_SUCCESS The FDT was installed.\r
- @retval EFI_NOT_FOUND Failed to locate a protocol or a file.\r
- @retval EFI_INVALID_PARAMETER Invalid device path.\r
- @retval EFI_UNSUPPORTED Device path not supported.\r
- @retval EFI_OUT_OF_RESOURCES An allocation failed.\r
-\r
-**/\r
-EFI_STATUS\r
-RunFdtInstallation (\r
- OUT CHAR16 **SuccessfullDevicePath\r
- );\r
-\r
-/**\r
- This is the shell command "setfdt" handler function. This function handles\r
- the command when it is invoked in the shell.\r
-\r
- @param[in] This The instance of the\r
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] SystemTable The pointer to the UEFI system table.\r
- @param[in] ShellParameters The parameters associated with the command.\r
- @param[in] Shell The instance of the shell protocol used in the\r
- context of processing this command.\r
-\r
- @return SHELL_SUCCESS The operation was successful.\r
- @return SHELL_ABORTED Operation aborted due to internal error.\r
- @return SHELL_INVALID_PARAMETER The parameters of the command are not valid.\r
- @return SHELL_INVALID_PARAMETER The EFI Shell file path is not valid.\r
- @return SHELL_NOT_FOUND Failed to locate a protocol or a file.\r
- @return SHELL_UNSUPPORTED Device path not supported.\r
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.\r
-\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellDynCmdSetFdtHandler (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
- IN EFI_SHELL_PROTOCOL *Shell\r
- );\r
-\r
-/**\r
- This is the shell command "setfdt" help handler function. This\r
- function returns the formatted help for the "setfdt" command.\r
- The format matchs that in Appendix B of the revision 2.1 of the\r
- UEFI Shell Specification.\r
-\r
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] Language The pointer to the language string to use.\r
-\r
- @return CHAR16* Pool allocated help string, must be freed by caller.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellDynCmdSetFdtGetHelp (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN CONST CHAR8 *Language\r
- );\r
-\r
-/**\r
- This is the shell command "dumpfdt" handler function. This function handles\r
- the command when it is invoked in the shell.\r
-\r
- @param[in] This The instance of the\r
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] SystemTable The pointer to the UEFI system table.\r
- @param[in] ShellParameters The parameters associated with the command.\r
- @param[in] Shell The instance of the shell protocol used in the\r
- context of processing this command.\r
-\r
- @return SHELL_SUCCESS The operation was successful.\r
- @return SHELL_ABORTED Operation aborted due to internal error.\r
- @return SHELL_NOT_FOUND Failed to locate the Device Tree into the EFI Configuration Table\r
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
-\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellDynCmdDumpFdtHandler (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
- IN EFI_SHELL_PROTOCOL *Shell\r
- );\r
-\r
-/**\r
- This is the shell command "dumpfdt" help handler function. This\r
- function returns the formatted help for the "dumpfdt" command.\r
- The format matchs that in Appendix B of the revision 2.1 of the\r
- UEFI Shell Specification.\r
-\r
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] Language The pointer to the language string to use.\r
-\r
- @return CHAR16* Pool allocated help string, must be freed by caller.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellDynCmdDumpFdtGetHelp (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN CONST CHAR8 *Language\r
- );\r
-\r
-#endif /* __FDT_PLATFORM_DXE_H__ */\r
+++ /dev/null
-#/** @file\r
-#\r
-# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010006\r
- BASE_NAME = FdtPlatformDxe\r
- MODULE_UNI_FILE = FdtPlatformDxe.uni\r
- FILE_GUID = 6e9a4c69-57c6-4fcd-b083-4f2c3bdb6051\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 0.1\r
- ENTRY_POINT = FdtPlatformEntryPoint\r
-\r
-[Sources.common]\r
- FdtPlatform.c\r
- FdtPlatformDxe.uni\r
- ShellDumpFdt.c\r
- ShellSetFdt.c\r
-\r
-[Packages]\r
- EmbeddedPkg/EmbeddedPkg.dec\r
- ArmPkg/ArmPkg.dec\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- ShellPkg/ShellPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiDriverEntryPoint\r
- BdsLib\r
- DxeServicesTableLib\r
- BaseMemoryLib\r
- DebugLib\r
- FdtLib\r
- UefiBootServicesTableLib\r
- UefiRuntimeServicesTableLib\r
- HiiLib\r
- ShellLib\r
-\r
-[Protocols]\r
- gEfiDevicePathToTextProtocolGuid\r
- gEfiDevicePathFromTextProtocolGuid\r
- gEfiShellDynamicCommandProtocolGuid\r
-\r
-[Guids]\r
- gEfiEndOfDxeEventGroupGuid\r
- gFdtTableGuid\r
- gFdtVariableGuid\r
-\r
-[FeaturePcd]\r
- gEmbeddedTokenSpaceGuid.PcdOverridePlatformFdt\r
- gEmbeddedTokenSpaceGuid.PcdDumpFdtShellCommand\r
-\r
-[Pcd]\r
- gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths\r
+++ /dev/null
-// *++\r
-//\r
-// Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials are licensed and made available\r
-// under the terms and conditions of the BSD License which accompanies this\r
-// distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-//\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-//\r
-// Module Name:\r
-//\r
-// FdtPlatformDxe\r
-//\r
-// Abstract:\r
-//\r
-// String definitions for the EFI Shell 'setfdt' command\r
-//\r
-// Revision History:\r
-//\r
-// --*/\r
-\r
-/=#\r
-\r
-#langdef en-US "English"\r
-\r
-#string STR_SETFDT_INSTALLING #language en-US "Installing the FDT ...\r\n"\r
-#string STR_SETFDT_INSTALL_SUCCEEDED #language en-US "Installation of\r\n'%s'\r\ncompleted.\r\n"\r
-\r
-#string STR_SETFDT_UPDATING #language en-US "Updating the FDT device path ...\r\n"\r
-#string STR_SETFDT_UPDATE_SUCCEEDED #language en-US "Update of the FDT device path '%s' completed.\r\n"\r
-#string STR_SETFDT_UPDATE_DELETED #language en-US "The UEFI variable "Fdt" was deleted.\r\n"\r
-\r
-#string STR_SETFDT_INVALID_DEVICE_PATH #language en-US "Invalid device path.\r\n"\r
-#string STR_SETFDT_INVALID_PATH #language en-US "The EFI Shell or device file path '%s' is invalid.\r\n"\r
-#string STR_SETFDT_ERROR #language en-US "Error - %r.\r\n"\r
-#string STR_SETFDT_DEVICE_PATH_LIST #language en-US "FDT device paths :\r\n"\r
-#string STR_SETFDT_DEVICE_PATH #language en-US "'%s'\r\n"\r
-\r
-#string STR_GET_HELP_SETFDT #language en-US ""\r
-".TH setfdt 0 "Define and/or install a new Flat Device Tree (FDT) for the platform."\r\n"\r
-".SH NAME\r\n"\r
-"Define and/or re-install a Flat Device Tree (FDT)\r\n"\r
-".SH SYNOPSIS\r\n"\r
-"setfdt [-i] [fdt_path]\r\n"\r
-".SH OPTIONS\r\n"\r
-"-i run the FDT installation process\r\n"\r
-"file_path EFI Shell file path or device path to a FDT\r\n"\r
-"\r\n"\r
-".SH DESCRIPTION\r\n"\r
-"NOTES:\r\n"\r
-"1. If a valid EFI Shell file path is passed to the command, then the\r\n"\r
-" command translates the EFI Shell file path into a device path in the\r\n"\r
-" text form and saves it in the non volatile UEFI variable "Fdt". If\r\n"\r
-" the path to the FDT is a device path in the text form, it is saved as\r\n"\r
-" it is in the non volatile UEFI variable "Fdt". The next time the FDT\r\n"\r
-" installation process is run, it will first try to install the FDT from\r\n"\r
-" the device path specified by the UEFI variable "Fdt".\r\n"\r
-" \r\n\r
-"2. If the option -i is passed to the command, then the FDT installation\r\n"\r
-" process is run. If a path to the FDT is passed to the command as well,\r\n"\r
-" the update of the "Fdt" UEFI variable is done first before to launch\r\n"\r
-" the FDT installation process.\r\n"\r
-" \r\n\r
-".SH RETURNVALUES\r\n"\r
-"SHELL_SUCCESS Operation(s) completed.\r\n"\r
-"SHELL_ABORTED Operation aborted.\r\n"\r
-"SHELL_INVALID_PARAMETER Invalid argument(s).\r\n"\r
-"SHELL_NOT_FOUND Failed to locate a protocol or a file.\r\n"\r
-"SHELL_UNSUPPORTED Device path not supported.\r\n"\r
-"SHELL_OUT_OF_RESOURCES A memory allocation failed.\r\n"\r
-"SHELL_DEVICE ERROR Hardware failure.\r\n"\r
-"SHELL_ACCESS_DENIED Access to the Fdt UEFI variable for modification denied.\r\n"\r
-".SH EXAMPLES\r\n"\r
-"EXAMPLES:\r\n"\r
-"1. Relaunch the FDT installation process :\r\n"\r
-" Shell> setfdt -i\r\n"\r
-" \r\n"\r
-"2. Set the EFI Shell file path 'fs0:\>fdt.dtb' to be the default path\r\n"\r
-" to the FDT :\r\n"\r
-" Shell> setfdt fs0:fdt.dtb\r\n"\r
-" \r\n"\r
-"3. Set a TFTP device path to be the default path to the FDT :\r\n"\r
-" Shell> setfdt MAC(0002f700570b,0x1)/IPv4(192.168.1.1)/fdt.dtb\r\n"\r
-" where . 00:02:f7:00:57:0b is the MAC address of the network\r\n"\r
-" interface card to be used. The 'ifconfig -l' EFI Shell\r\n"\r
-" command allows to get the MAC address of the network\r\n"\r
-" interface cards.\r\n"\r
-" . 192.168.1.1 is the address of the TFTP server.\r\n"\r
-" . fdt.dtb is the file path to the FDT file on the server.\r\n"\r
-"4. Display the FDT device paths from the highest to the lowest\r\n"\r
-" priority :\r\n"\r
-" Shell> setfdt\r\n"\r
-"5. Delete the "Fdt" UEFI variable :\r\n"\r
-" Shell> setfdt ""\r\n"\r
-"\r\n"\r
-\r
-#string STR_GET_HELP_DUMPFDT #language en-US ""\r
-".TH dumpfdt 0 "Dump installed Flat Device Tree (FDT) of the platform."\r\n"\r
-".SH NAME\r\n"\r
-"Dump current Flat Device Tree (FDT)\r\n"\r
-".SH SYNOPSIS\r\n"\r
-"dumpfdt\r\n"\r
-"\r\n"\r
-".SH DESCRIPTION\r\n"\r
-"\r\n"\r
+++ /dev/null
-/** @file
-
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-The purpose of the FdtPlatformDxe UEFI driver is to install the Flat Device
-Tree (FDT) of the platform the UEFI frimware is running on into the UEFI
-Configuration Table. The FDT is identified within the UEFI Configuration
-Table by the "gFdtTableGuid" GUID defined in "EmbeddedPkg.dec".
-
-Once installed, an UEFI application or OS boot loader can get from the UEFI
-Configuration Table the FDT of the platform from the "gFdtTableGuid" GUID.
-
-The installation is done after each boot at the end of the DXE phase,
-just before the BDS phase. It is done at the end of the DXE phase to be sure
-that all drivers have been dispatched. That way, all UEFI protocols that may
-be needed to retrieve the FDT can be made available. It is done before the BDS
-phase to be able to provide the FDT during that phase.
-
-The present driver tries to retrieve the FDT from the device paths defined in the
-"gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths" PCD. The "PcdFdtDevicePaths" PCD
-contains a list a device paths. The device paths are in the text form and
-separated by semi-colons. The present driver tries the device paths in the order
-it finds them in the "PcdFdtDevicePaths" PCD as long as he did not install
-succesfully a FDT.
-
-The "PcdFdtDevicePaths" PCD is a dynamic PCD that can be modified during the
-DXE phase. This allows for exemple to select the right FDT when a binary is
-intended to run on several platforms and/or variants of a platform.
-
-If the driver manages to download a FDT from one of the device paths mentioned
-above then it installs it in the UEFI Configuration table and the run over the
-device paths is stopped.
-
-For development purposes only, if the feature PCD "gEmbeddedTokenSpaceGuid.
-PcdOverridePlatformFdt" is equal to TRUE, then before to try to install the
-FDT from the device paths listed in the "PcdFdtDevicePaths" PCD, the present
-driver tries to install it using the device path defined by the UEFI variable
-"Fdt". If the variable does not exist or the installation using the device path
-defined by the UEFI variable fails then the installation proceeds as described
-above.
-
-Furthermore and again for development purposes only, if the feature PCD
-"PcdOverridePlatformFdt" is equal to TRUE, the current driver provides the EFI
-Shell command "setfdt" to define the location of the FDT by the mean of an EFI
-Shell file path (like "fs2:\boot\fdt.dtb") or a device path.
-
-If the path passed in to the command is a valid EFI Shell file path, the
-command translates it into the corresponding device path and stores that
-device path in the "Fdt" UEFI variable asking for the variable to be non
-volatile.
-
-If the path passed in to the command is not recognised as a valid EFI
-Shell device path, the command handles it as device path and stored
-in the "Fdt" UEFI variable as it is.
-
-Finally, the "-i" option of the "setfdt" command allows to trigger the FDT
-installation process. The installation process is completed when the command
-returns. The command can be invoked with the "-i" option only and in that
-case the "Fdt" UEFI variable is not updated and the command just runs the
-FDT installation process. If the command is invoked with the "-i" option and
-an EFI Shell file path then first the "Fdt" UEFI variable is updated accordingly
-and then the FDT installation process is run.
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "FdtPlatform.h"\r
-\r
-#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))\r
-#define PALIGN(p, a) ((void *)(ALIGN ((unsigned long)(p), (a))))\r
-#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4)))\r
-\r
-STATIC\r
-UINTN\r
-IsPrintableString (\r
- IN CONST VOID* data,\r
- IN UINTN len\r
- )\r
-{\r
- CONST CHAR8 *s = data;\r
- CONST CHAR8 *ss;\r
-\r
- // Zero length is not\r
- if (len == 0) {\r
- return 0;\r
- }\r
-\r
- // Must terminate with zero\r
- if (s[len - 1] != '\0') {\r
- return 0;\r
- }\r
-\r
- ss = s;\r
- while (*s/* && isprint (*s)*/) {\r
- s++;\r
- }\r
-\r
- // Not zero, or not done yet\r
- if (*s != '\0' || (s + 1 - ss) < len) {\r
- return 0;\r
- }\r
-\r
- return 1;\r
-}\r
-\r
-STATIC\r
-VOID\r
-PrintData (\r
- IN CONST CHAR8* data,\r
- IN UINTN len\r
- )\r
-{\r
- UINTN i;\r
- CONST CHAR8 *p = data;\r
-\r
- // No data, don't print\r
- if (len == 0)\r
- return;\r
-\r
- if (IsPrintableString (data, len)) {\r
- Print (L" = \"%a\"", (const char *)data);\r
- } else if ((len % 4) == 0) {\r
- Print (L" = <");\r
- for (i = 0; i < len; i += 4) {\r
- Print (L"0x%08x%a", fdt32_to_cpu (GET_CELL (p)), i < (len - 4) ? " " : "");\r
- }\r
- Print (L">");\r
- } else {\r
- Print (L" = [");\r
- for (i = 0; i < len; i++)\r
- Print (L"%02x%a", *p++, i < len - 1 ? " " : "");\r
- Print (L"]");\r
- }\r
-}\r
-\r
-STATIC\r
-VOID\r
-DumpFdt (\r
- IN VOID* FdtBlob\r
- )\r
-{\r
- struct fdt_header *bph;\r
- UINT32 off_dt;\r
- UINT32 off_str;\r
- CONST CHAR8* p_struct;\r
- CONST CHAR8* p_strings;\r
- CONST CHAR8* p;\r
- CONST CHAR8* s;\r
- CONST CHAR8* t;\r
- UINT32 tag;\r
- UINTN sz;\r
- UINTN depth;\r
- UINTN shift;\r
- UINT32 version;\r
-\r
- {\r
- // Can 'memreserve' be printed by below code?\r
- INTN num = fdt_num_mem_rsv (FdtBlob);\r
- INTN i, err;\r
- UINT64 addr = 0, size = 0;\r
-\r
- for (i = 0; i < num; i++) {\r
- err = fdt_get_mem_rsv (FdtBlob, i, &addr, &size);\r
- if (err) {\r
- DEBUG ((EFI_D_ERROR, "Error (%d) : Cannot get memreserve section (%d)\n", err, i));\r
- }\r
- else {\r
- Print (L"/memreserve/ \t0x%lx \t0x%lx;\n", addr, size);\r
- }\r
- }\r
- }\r
-\r
- depth = 0;\r
- shift = 4;\r
-\r
- bph = FdtBlob;\r
- off_dt = fdt32_to_cpu (bph->off_dt_struct);\r
- off_str = fdt32_to_cpu (bph->off_dt_strings);\r
- p_struct = (CONST CHAR8*)FdtBlob + off_dt;\r
- p_strings = (CONST CHAR8*)FdtBlob + off_str;\r
- version = fdt32_to_cpu (bph->version);\r
-\r
- p = p_struct;\r
- while ((tag = fdt32_to_cpu (GET_CELL (p))) != FDT_END) {\r
- if (tag == FDT_BEGIN_NODE) {\r
- s = p;\r
- p = PALIGN (p + AsciiStrLen (s) + 1, 4);\r
-\r
- if (*s == '\0')\r
- s = "/";\r
-\r
- Print (L"%*s%a {\n", depth * shift, L" ", s);\r
-\r
- depth++;\r
- continue;\r
- }\r
-\r
- if (tag == FDT_END_NODE) {\r
- depth--;\r
-\r
- Print (L"%*s};\n", depth * shift, L" ");\r
- continue;\r
- }\r
-\r
- if (tag == FDT_NOP) {\r
- Print (L"%*s// [NOP]\n", depth * shift, L" ");\r
- continue;\r
- }\r
-\r
- if (tag != FDT_PROP) {\r
- Print (L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);\r
- break;\r
- }\r
- sz = fdt32_to_cpu (GET_CELL (p));\r
- s = p_strings + fdt32_to_cpu (GET_CELL (p));\r
- if (version < 16 && sz >= 8)\r
- p = PALIGN (p, 8);\r
- t = p;\r
-\r
- p = PALIGN (p + sz, 4);\r
-\r
- Print (L"%*s%a", depth * shift, L" ", s);\r
- PrintData (t, sz);\r
- Print (L";\n");\r
- }\r
-}\r
-\r
-/**\r
- This is the shell command "dumpfdt" handler function. This function handles\r
- the command when it is invoked in the shell.\r
-\r
- @param[in] This The instance of the\r
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] SystemTable The pointer to the UEFI system table.\r
- @param[in] ShellParameters The parameters associated with the command.\r
- @param[in] Shell The instance of the shell protocol used in the\r
- context of processing this command.\r
-\r
- @return SHELL_SUCCESS The operation was successful.\r
- @return SHELL_ABORTED Operation aborted due to internal error.\r
- @return SHELL_NOT_FOUND Failed to locate the Device Tree into the EFI Configuration Table\r
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
-\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellDynCmdDumpFdtHandler (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
- IN EFI_SHELL_PROTOCOL *Shell\r
- )\r
-{\r
- SHELL_STATUS ShellStatus;\r
- EFI_STATUS Status;\r
- VOID *FdtBlob;\r
-\r
- ShellStatus = SHELL_SUCCESS;\r
-\r
- //\r
- // Install the Shell and Shell Parameters Protocols on the driver\r
- // image. This is necessary for the initialisation of the Shell\r
- // Library to succeed in the next step.\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &gImageHandle,\r
- &gEfiShellProtocolGuid, Shell,\r
- &gEfiShellParametersProtocolGuid, ShellParameters,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return SHELL_ABORTED;\r
- }\r
-\r
- //\r
- // Initialise the Shell Library as we are going to use it.\r
- // Assert that the return code is EFI_SUCCESS as it should.\r
- // To anticipate any change is the codes returned by\r
- // ShellInitialize(), leave in case of error.\r
- //\r
- Status = ShellInitialize ();\r
- if (EFI_ERROR (Status)) {\r
- ASSERT_EFI_ERROR (Status);\r
- return SHELL_ABORTED;\r
- }\r
-\r
- Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &FdtBlob);\r
- if (EFI_ERROR (Status)) {\r
- Print (L"ERROR: Did not find the Fdt Blob.\n");\r
- return EfiCodeToShellCode (Status);\r
- }\r
-\r
- DumpFdt (FdtBlob);\r
-\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- gImageHandle,\r
- &gEfiShellProtocolGuid, Shell,\r
- &gEfiShellParametersProtocolGuid, ShellParameters,\r
- NULL\r
- );\r
-\r
- return ShellStatus;\r
-}\r
-\r
-/**\r
- This is the shell command "dumpfdt" help handler function. This\r
- function returns the formatted help for the "dumpfdt" command.\r
- The format matchs that in Appendix B of the revision 2.1 of the\r
- UEFI Shell Specification.\r
-\r
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] Language The pointer to the language string to use.\r
-\r
- @return CHAR16* Pool allocated help string, must be freed by caller.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellDynCmdDumpFdtGetHelp (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN CONST CHAR8 *Language\r
- )\r
-{\r
- //\r
- // This allocates memory. The caller has to free the allocated memory.\r
- //\r
- return HiiGetString (\r
- mFdtPlatformDxeHiiHandle,\r
- STRING_TOKEN (STR_GET_HELP_DUMPFDT),\r
- Language\r
- );\r
-}\r
+++ /dev/null
-/** @file\r
-\r
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
-\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "FdtPlatform.h"\r
-\r
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
- {L"-i", TypeFlag },\r
- {NULL , TypeMax }\r
-};\r
-\r
-/**\r
- Display FDT device paths.\r
-\r
- Display in text form the device paths used to install the FDT from the\r
- highest to the lowest priority.\r
-\r
-**/\r
-STATIC\r
-VOID\r
-DisplayFdtDevicePaths (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN DataSize;\r
- CHAR16 *TextDevicePath;\r
- CHAR16 *TextDevicePaths;\r
- CHAR16 *TextDevicePathSeparator;\r
-\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH_LIST),\r
- mFdtPlatformDxeHiiHandle\r
- );\r
-\r
- if (FeaturePcdGet (PcdOverridePlatformFdt)) {\r
- DataSize = 0;\r
- Status = gRT->GetVariable (\r
- L"Fdt",\r
- &gFdtVariableGuid,\r
- NULL,\r
- &DataSize,\r
- NULL\r
- );\r
-\r
- //\r
- // Keep going only if the "Fdt" variable is defined.\r
- //\r
-\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- TextDevicePath = AllocatePool (DataSize);\r
- if (TextDevicePath == NULL) {\r
- return;\r
- }\r
-\r
- Status = gRT->GetVariable (\r
- L"Fdt",\r
- &gFdtVariableGuid,\r
- NULL,\r
- &DataSize,\r
- TextDevicePath\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
- mFdtPlatformDxeHiiHandle,\r
- TextDevicePath\r
- );\r
- }\r
-\r
- FreePool (TextDevicePath);\r
- }\r
- }\r
-\r
- //\r
- // Loop over the device path list provided by "PcdFdtDevicePaths". The device\r
- // paths are in text form and separated by a semi-colon.\r
- //\r
-\r
- TextDevicePaths = AllocateCopyPool (\r
- StrSize ((CHAR16*)PcdGetPtr (PcdFdtDevicePaths)),\r
- (CHAR16*)PcdGetPtr (PcdFdtDevicePaths)\r
- );\r
- if (TextDevicePaths == NULL) {\r
- return;\r
- }\r
-\r
- for (TextDevicePath = TextDevicePaths;\r
- *TextDevicePath != L'\0' ; ) {\r
- TextDevicePathSeparator = StrStr (TextDevicePath, L";");\r
-\r
- if (TextDevicePathSeparator != NULL) {\r
- *TextDevicePathSeparator = L'\0';\r
- }\r
-\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_DEVICE_PATH),\r
- mFdtPlatformDxeHiiHandle,\r
- TextDevicePath\r
- );\r
-\r
- if (TextDevicePathSeparator == NULL) {\r
- break;\r
- }\r
- TextDevicePath = TextDevicePathSeparator + 1;\r
- }\r
-\r
- FreePool (TextDevicePaths);\r
-}\r
-\r
-/**\r
- Update the text device path stored in the "Fdt" UEFI variable given\r
- an EFI Shell file path or a text device path.\r
-\r
- This function is a subroutine of the ShellDynCmdSetFdtHandler() function\r
- to make its code easier to read.\r
-\r
- @param[in] Shell The instance of the shell protocol used in the\r
- context of processing the "setfdt" command.\r
- @param[in] FilePath EFI Shell path or the device path to the FDT file.\r
-\r
- @return SHELL_SUCCESS The text device path was succesfully updated.\r
- @return SHELL_INVALID_PARAMETER The Shell file path is not valid.\r
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.\r
- @return SHELL_NOT_FOUND Device path to text protocol not found.\r
- @return SHELL_ABORTED Operation aborted.\r
-\r
-**/\r
-STATIC\r
-SHELL_STATUS\r
-UpdateFdtTextDevicePath (\r
- IN EFI_SHELL_PROTOCOL *Shell,\r
- IN CONST CHAR16 *FilePath\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH *DevicePath;\r
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *EfiDevicePathToTextProtocol;\r
- CHAR16 *TextDevicePath;\r
- CHAR16 *FdtVariableValue;\r
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;\r
- SHELL_STATUS ShellStatus;\r
-\r
- ASSERT (FilePath != NULL);\r
- DevicePath = NULL;\r
- TextDevicePath = NULL;\r
- FdtVariableValue = NULL;\r
-\r
- if (*FilePath != L'\0') {\r
- DevicePath = Shell->GetDevicePathFromFilePath (FilePath);\r
- if (DevicePath != NULL) {\r
- Status = gBS->LocateProtocol (\r
- &gEfiDevicePathToTextProtocolGuid,\r
- NULL,\r
- (VOID **)&EfiDevicePathToTextProtocol\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- TextDevicePath = EfiDevicePathToTextProtocol->ConvertDevicePathToText (\r
- DevicePath,\r
- FALSE,\r
- FALSE\r
- );\r
- if (TextDevicePath == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
- FdtVariableValue = TextDevicePath;\r
- } else {\r
- //\r
- // Try to convert back the EFI Device Path String into a EFI device Path\r
- // to ensure the format is valid\r
- //\r
- Status = gBS->LocateProtocol (\r
- &gEfiDevicePathFromTextProtocolGuid,\r
- NULL,\r
- (VOID **)&EfiDevicePathFromTextProtocol\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- DevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (\r
- FilePath\r
- );\r
- if (DevicePath == NULL) {\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Error;\r
- }\r
- FdtVariableValue = (CHAR16*)FilePath;\r
- }\r
- }\r
-\r
- Status = gRT->SetVariable (\r
- (CHAR16*)L"Fdt",\r
- &gFdtVariableGuid,\r
- EFI_VARIABLE_RUNTIME_ACCESS |\r
- EFI_VARIABLE_NON_VOLATILE |\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS ,\r
- (FdtVariableValue != NULL) ?\r
- StrSize (FdtVariableValue) : 0,\r
- FdtVariableValue\r
- );\r
-\r
-Error:\r
- ShellStatus = EfiCodeToShellCode (Status);\r
- if (!EFI_ERROR (Status)) {\r
- if (FdtVariableValue != NULL) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_UPDATE_SUCCEEDED),\r
- mFdtPlatformDxeHiiHandle,\r
- FdtVariableValue\r
- );\r
- } else {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),\r
- mFdtPlatformDxeHiiHandle\r
- );\r
- }\r
- } else {\r
- if (Status == EFI_INVALID_PARAMETER) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_INVALID_PATH),\r
- mFdtPlatformDxeHiiHandle,\r
- FilePath\r
- );\r
- } else {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_ERROR),\r
- mFdtPlatformDxeHiiHandle,\r
- Status\r
- );\r
- }\r
- }\r
-\r
- if (DevicePath != NULL) {\r
- FreePool (DevicePath);\r
- }\r
- if (TextDevicePath != NULL) {\r
- FreePool (TextDevicePath);\r
- }\r
-\r
- return ShellStatus;\r
-}\r
-\r
-/**\r
- This is the shell command "setfdt" handler function. This function handles\r
- the command when it is invoked in the shell.\r
-\r
- @param[in] This The instance of the\r
- EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] SystemTable The pointer to the UEFI system table.\r
- @param[in] ShellParameters The parameters associated with the command.\r
- @param[in] Shell The instance of the shell protocol used in the\r
- context of processing this command.\r
-\r
- @return SHELL_SUCCESS The operation was successful.\r
- @return SHELL_ABORTED Operation aborted due to internal error.\r
- @return SHELL_INVALID_PARAMETER The parameters of the command are not valid.\r
- @return SHELL_INVALID_PARAMETER The EFI Shell file path is not valid.\r
- @return SHELL_NOT_FOUND Failed to locate a protocol or a file.\r
- @return SHELL_UNSUPPORTED Device path not supported.\r
- @return SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
- @return SHELL_DEVICE_ERROR The "Fdt" variable could not be saved due to a hardware failure.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable is read-only.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable cannot be deleted.\r
- @return SHELL_ACCESS_DENIED The "Fdt" variable could not be written due to security violation.\r
-\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellDynCmdSetFdtHandler (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
- IN EFI_SHELL_PROTOCOL *Shell\r
- )\r
-{\r
- SHELL_STATUS ShellStatus;\r
- EFI_STATUS Status;\r
- LIST_ENTRY *ParamPackage;\r
- BOOLEAN FilePath;\r
- CONST CHAR16 *ValueStr;\r
- CHAR16 *TextDevicePath;\r
-\r
- ShellStatus = SHELL_SUCCESS;\r
- ParamPackage = NULL;\r
- FilePath = FALSE;\r
-\r
- //\r
- // Install the Shell and Shell Parameters Protocols on the driver\r
- // image. This is necessary for the initialisation of the Shell\r
- // Library to succeed in the next step.\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &gImageHandle,\r
- &gEfiShellProtocolGuid, Shell,\r
- &gEfiShellParametersProtocolGuid, ShellParameters,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return SHELL_ABORTED;\r
- }\r
-\r
- //\r
- // Initialise the Shell Library as we are going to use it.\r
- // Assert that the return code is EFI_SUCCESS as it should.\r
- // To anticipate any change is the codes returned by\r
- // ShellInitialize(), leave in case of error.\r
- //\r
- Status = ShellInitialize ();\r
- if (EFI_ERROR (Status)) {\r
- ASSERT_EFI_ERROR (Status);\r
- return SHELL_ABORTED;\r
- }\r
-\r
- Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);\r
- if (!EFI_ERROR (Status)) {\r
- switch (ShellCommandLineGetCount (ParamPackage)) {\r
- case 1:\r
- //\r
- // Case "setfdt" or "setfdt -i"\r
- //\r
- if (!ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
- DisplayFdtDevicePaths ();\r
- }\r
- break;\r
-\r
- case 2:\r
- //\r
- // Case "setfdt file_path" or\r
- // "setfdt -i file_path" or\r
- // "setfdt file_path -i"\r
- //\r
- FilePath = TRUE;\r
- break;\r
-\r
- default:\r
- Status = EFI_INVALID_PARAMETER;\r
- }\r
- }\r
- if (EFI_ERROR (Status)) {\r
- ShellStatus = EfiCodeToShellCode (Status);\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_ERROR),\r
- mFdtPlatformDxeHiiHandle,\r
- Status\r
- );\r
- goto Error;\r
- }\r
-\r
- //\r
- // Update the preferred device path for the FDT if asked for.\r
- //\r
- if (FilePath) {\r
- ValueStr = ShellCommandLineGetRawValue (ParamPackage, 1);\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_UPDATING),\r
- mFdtPlatformDxeHiiHandle\r
- );\r
- ShellStatus = UpdateFdtTextDevicePath (Shell, ValueStr);\r
- if (ShellStatus != SHELL_SUCCESS) {\r
- goto Error;\r
- }\r
- }\r
-\r
- //\r
- // Run the FDT installation process if asked for.\r
- //\r
- if (ShellCommandLineGetFlag (ParamPackage, L"-i")) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_INSTALLING),\r
- mFdtPlatformDxeHiiHandle\r
- );\r
- Status = RunFdtInstallation (&TextDevicePath);\r
- ShellStatus = EfiCodeToShellCode (Status);\r
- if (!EFI_ERROR (Status)) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_INSTALL_SUCCEEDED),\r
- mFdtPlatformDxeHiiHandle,\r
- TextDevicePath\r
- );\r
- FreePool (TextDevicePath);\r
- } else {\r
- if (Status == EFI_INVALID_PARAMETER) {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_INVALID_DEVICE_PATH),\r
- mFdtPlatformDxeHiiHandle\r
- );\r
- } else {\r
- ShellPrintHiiEx (\r
- -1, -1, NULL,\r
- STRING_TOKEN (STR_SETFDT_ERROR),\r
- mFdtPlatformDxeHiiHandle,\r
- Status\r
- );\r
- }\r
- DisplayFdtDevicePaths ();\r
- }\r
- }\r
-\r
-Error:\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- gImageHandle,\r
- &gEfiShellProtocolGuid, Shell,\r
- &gEfiShellParametersProtocolGuid, ShellParameters,\r
- NULL\r
- );\r
- ShellCommandLineFreeVarList (ParamPackage);\r
-\r
- return ShellStatus;\r
-}\r
-\r
-/**\r
- This is the shell command "setfdt" help handler function. This\r
- function returns the formatted help for the "setfdt" command.\r
- The format matchs that in Appendix B of the revision 2.1 of the\r
- UEFI Shell Specification.\r
-\r
- @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
- @param[in] Language The pointer to the language string to use.\r
-\r
- @return CHAR16* Pool allocated help string, must be freed by caller.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-ShellDynCmdSetFdtGetHelp (\r
- IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
- IN CONST CHAR8 *Language\r
- )\r
-{\r
- //\r
- // This allocates memory. The caller has to free the allocated memory.\r
- //\r
- return HiiGetString (\r
- mFdtPlatformDxeHiiHandle,\r
- STRING_TOKEN (STR_GET_HELP_SETFDT),\r
- Language\r
- );\r
-}\r
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x0000001b\r
gEmbeddedTokenSpaceGuid.PcdCacheEnable|FALSE|BOOLEAN|0x00000042\r
gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x00000053\r
- # Enable the development specific features\r
- gEmbeddedTokenSpaceGuid.PcdOverridePlatformFdt|TRUE|BOOLEAN|0x00000054\r
- # Add 'dumpfdt' EFI Shell command\r
- gEmbeddedTokenSpaceGuid.PcdDumpFdtShellCommand|TRUE|BOOLEAN|0x00000056\r
\r
gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeaturePMPSupport|FALSE|BOOLEAN|0x00000050\r
gEmbeddedTokenSpaceGuid.PcdSataSiI3132FeatureDirectCommandIssuing|FALSE|BOOLEAN|0x00000051\r
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16|UINT8|0x00000011\r
\r
[PcdsFixedAtBuild.common, PcdsDynamic.common]\r
- gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055\r
-\r
#\r
# Value to add to a host address to obtain a device address, using\r
# unsigned 64-bit integer arithmetic. This means we can rely on\r
EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf\r
EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcpDxe.inf\r
\r
- # FDT installation\r
- EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf {\r
- <LibraryClasses>\r
- # It depends on BdsLib that depends on TimerLib\r
- TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
- }\r
-\r
[Components.IA32, Components.X64, Components.IPF, Components.ARM]\r
EmbeddedPkg/GdbStub/GdbStub.inf\r