--- /dev/null
+/** @file\r
+ This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi\r
+ tables from bootloader.\r
+\r
+ Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include "BlSupportDxe.h"\r
+\r
+/**\r
+ Reserve MMIO/IO resource in GCD\r
+\r
+ @param IsMMIO Flag of whether it is mmio resource or io resource.\r
+ @param GcdType Type of the space.\r
+ @param BaseAddress Base address of the space.\r
+ @param Length Length of the space.\r
+ @param Alignment Align with 2^Alignment\r
+ @param ImageHandle Handle for the image of this driver.\r
+\r
+ @retval EFI_SUCCESS Reserve successful\r
+**/\r
+EFI_STATUS\r
+ReserveResourceInGcd (\r
+ IN BOOLEAN IsMMIO,\r
+ IN UINTN GcdType,\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
+ IN UINT64 Length,\r
+ IN UINTN Alignment,\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ if (IsMMIO) {\r
+ Status = gDS->AddMemorySpace (\r
+ GcdType,\r
+ BaseAddress,\r
+ Length,\r
+ EFI_MEMORY_UC\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "Failed to add memory space :0x%lx 0x%lx\n",\r
+ BaseAddress,\r
+ Length\r
+ ));\r
+ }\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = gDS->AllocateMemorySpace (\r
+ EfiGcdAllocateAddress,\r
+ GcdType,\r
+ Alignment,\r
+ Length,\r
+ &BaseAddress,\r
+ ImageHandle,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ } else {\r
+ Status = gDS->AddIoSpace (\r
+ GcdType,\r
+ BaseAddress,\r
+ Length\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = gDS->AllocateIoSpace (\r
+ EfiGcdAllocateAddress,\r
+ GcdType,\r
+ Alignment,\r
+ Length,\r
+ &BaseAddress,\r
+ ImageHandle,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Main entry for the bootloader support DXE module.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BlDxeEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ SYSTEM_TABLE_INFO *SystemTableInfo;\r
+ EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;\r
+\r
+ Status = EFI_SUCCESS;\r
+ //\r
+ // Report MMIO/IO Resources\r
+ //\r
+ Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, SystemTable); // HPET\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Find the system table information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
+\r
+ //\r
+ // Install Acpi Table\r
+ //\r
+ if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {\r
+ DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));\r
+ Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ //\r
+ // Install Smbios Table\r
+ //\r
+ if (SystemTableInfo->SmbiosTableBase != 0 && SystemTableInfo->SmbiosTableSize != 0) {\r
+ DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));\r
+ Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)SystemTableInfo->SmbiosTableBase);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ //\r
+ // Find the frame buffer information and update PCDs\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);\r
+ if (GuidHob != NULL) {\r
+ GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);\r
+ Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r