-STATIC VOID OnEndOfDxe (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- );\r
-STATIC EFI_STATUS RunFdtInstallation (\r
- VOID\r
- );\r
-STATIC EFI_STATUS InstallFdt (\r
- IN CONST CHAR16* TextDevicePath\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.\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_EVENT EndOfDxeEvent;\r
-\r
- //\r
- // Create an event belonging to the "gEfiEndOfDxeEventGroupGuid" group.\r
- // The "OnEndOfDxe()" function is declared as the call back function.\r
- // It will be called at the end of the DXE phase when an event of the\r
- // same group is signalled to inform about the end of the DXE phase.\r
- //\r
- Status = gBS->CreateEventEx (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_CALLBACK,\r
- OnEndOfDxe,\r
- NULL,\r
- &gEfiEndOfDxeEventGroupGuid,\r
- &EndOfDxeEvent\r
- );\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Notification function of the event defined as belonging to the\r
- EFI_END_OF_DXE_EVENT_GROUP_GUID event group that was created in\r
- the entry point of the driver.\r
-\r
- This function is called when an event belonging to the\r
- EFI_END_OF_DXE_EVENT_GROUP_GUID event group is signalled. Such an\r
- event is signalled once at the end of the dispatching of all\r
- drivers (end of the so called DXE phase).\r
-\r
- @param[in] Event Event declared in the entry point of the driver whose\r
- notification function is being invoked.\r
- @param[in] Context NULL\r
-\r
-**/\r
-STATIC\r
-VOID\r
-OnEndOfDxe (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- RunFdtInstallation ();\r
- gBS->CloseEvent (Event);\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
- @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
-STATIC\r
-EFI_STATUS\r
-RunFdtInstallation (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN DataSize;\r
- VOID *Data;\r
- CHAR16 *TextDevicePathStart;\r
- CHAR16 *TextDevicePathSeparator;\r
- UINTN TextDevicePathLen;\r
- CHAR16 *TextDevicePath;\r
-\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
- );\r
-\r
- //\r
- // Keep going only if the "Fdt" variable is defined.\r
- //\r
-\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- Data = AllocatePool (DataSize);\r
- if (Data == 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
- }\r
-\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
- ));\r
- } else {\r
- return Status;\r
- }\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_SUCCESS;\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
- TextDevicePath = 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