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
STATIC\r
EFI_STATUS\r
RunFdtInstallation (\r
- VOID\r
+ OUT CHAR16 **SuccessfullDevicePath\r
)\r
{\r
EFI_STATUS Status;\r
UINTN DataSize;\r
- VOID *Data;\r
+ CHAR16 *TextDevicePath;\r
CHAR16 *TextDevicePathStart;\r
CHAR16 *TextDevicePathSeparator;\r
UINTN TextDevicePathLen;\r
- CHAR16 *TextDevicePath;\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
- Data = NULL;\r
DataSize = 0;\r
Status = gRT->GetVariable (\r
L"Fdt",\r
&gFdtVariableGuid,\r
NULL,\r
&DataSize,\r
- Data\r
+ NULL\r
);\r
\r
//\r
//\r
\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
- Data = AllocatePool (DataSize);\r
- if (Data == NULL) {\r
+ TextDevicePath = AllocatePool (DataSize);\r
+ if (TextDevicePath == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
- } else {\r
- Status = gRT->GetVariable (\r
- L"Fdt",\r
- &gFdtVariableGuid,\r
- NULL,\r
- &DataSize,\r
- Data\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- Status = InstallFdt ((CHAR16*)Data);\r
- if (!EFI_ERROR (Status)) {\r
- DEBUG ((\r
- EFI_D_WARN,\r
- "Installation of the FDT using the device path <%s> completed.\n",\r
- (CHAR16*)Data\r
- ));\r
- }\r
- }\r
- FreePool (Data);\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_ERROR,\r
- "Installation of the FDT specified by the \"Fdt\" UEFI variable failed - %r\n",\r
- Status\r
+ EFI_D_WARN,\r
+ "Installation of the FDT using the device path <%s> completed.\n",\r
+ TextDevicePath\r
));\r
- } else {\r
- return Status;\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
// paths are in text form and separated by a semi-colon.\r
//\r
\r
- Status = EFI_SUCCESS;\r
+ Status = EFI_NOT_FOUND;\r
for (TextDevicePathStart = (CHAR16*)PcdGetPtr (PcdFdtDevicePaths);\r
*TextDevicePathStart != L'\0' ; ) {\r
TextDevicePathSeparator = StrStr (TextDevicePathStart, L";");\r
// Last device path of the list\r
//\r
if (TextDevicePathSeparator == NULL) {\r
- TextDevicePath = TextDevicePathStart;\r
+ TextDevicePathLen = StrLen (TextDevicePathStart);\r
} else {\r
TextDevicePathLen = (UINTN)(TextDevicePathSeparator - TextDevicePathStart);\r
- TextDevicePath = AllocateCopyPool (\r
- (TextDevicePathLen + 1) * sizeof (CHAR16),\r
- TextDevicePathStart\r
- );\r
- if (TextDevicePath == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- DEBUG ((EFI_D_ERROR, "Memory allocation error during FDT installation process.\n"));\r
- break;\r
- }\r
- TextDevicePath[TextDevicePathLen] = L'\0';\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> failed - %r.\n",\r
- TextDevicePath, Status\r
- ));\r
- } else {\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
- break;\r
- } else {\r
- FreePool (TextDevicePath);\r
- if (!EFI_ERROR (Status)) {\r
- break;\r
- }\r
- TextDevicePathStart = TextDevicePathSeparator + 1;\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
- return Status;\r
+ if (SuccessfullDevicePath != NULL) {\r
+ *SuccessfullDevicePath = TextDevicePath;\r
+ } else {\r
+ FreePool (TextDevicePath);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
LIST_ENTRY *ParamPackage;\r
BOOLEAN FilePath;\r
CONST CHAR16 *ValueStr;\r
+ CHAR16 *TextDevicePath;\r
\r
ShellStatus = SHELL_SUCCESS;\r
ParamPackage = NULL;\r
STRING_TOKEN (STR_SETFDT_INSTALLING),\r
mFdtPlatformDxeHiiHandle\r
);\r
- Status = RunFdtInstallation ();\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
+ mFdtPlatformDxeHiiHandle,\r
+ TextDevicePath\r
);\r
+ FreePool (TextDevicePath);\r
} else {\r
if (Status == EFI_INVALID_PARAMETER) {\r
ShellPrintHiiEx (\r
ShellPrintHiiEx (\r
-1, -1, NULL,\r
STRING_TOKEN (STR_SETFDT_UPDATE_DELETED),\r
- mFdtPlatformDxeHiiHandle,\r
- FdtVariableValue\r
+ mFdtPlatformDxeHiiHandle\r
);\r
}\r
} else {\r