]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiPayloadPkg / BlSupportDxe / BlSupportDxe.c
... / ...
CommitLineData
1/** @file\r
2 This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi\r
3 tables from bootloader.\r
4\r
5 Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9#include "BlSupportDxe.h"\r
10\r
11/**\r
12 Reserve MMIO/IO resource in GCD\r
13\r
14 @param IsMMIO Flag of whether it is mmio resource or io resource.\r
15 @param GcdType Type of the space.\r
16 @param BaseAddress Base address of the space.\r
17 @param Length Length of the space.\r
18 @param Alignment Align with 2^Alignment\r
19 @param ImageHandle Handle for the image of this driver.\r
20\r
21 @retval EFI_SUCCESS Reserve successful\r
22**/\r
23EFI_STATUS\r
24ReserveResourceInGcd (\r
25 IN BOOLEAN IsMMIO,\r
26 IN UINTN GcdType,\r
27 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
28 IN UINT64 Length,\r
29 IN UINTN Alignment,\r
30 IN EFI_HANDLE ImageHandle\r
31 )\r
32{\r
33 EFI_STATUS Status;\r
34\r
35 if (IsMMIO) {\r
36 Status = gDS->AddMemorySpace (\r
37 GcdType,\r
38 BaseAddress,\r
39 Length,\r
40 EFI_MEMORY_UC\r
41 );\r
42 if (EFI_ERROR (Status)) {\r
43 DEBUG ((\r
44 DEBUG_ERROR,\r
45 "Failed to add memory space :0x%lx 0x%lx\n",\r
46 BaseAddress,\r
47 Length\r
48 ));\r
49 }\r
50 ASSERT_EFI_ERROR (Status);\r
51 Status = gDS->AllocateMemorySpace (\r
52 EfiGcdAllocateAddress,\r
53 GcdType,\r
54 Alignment,\r
55 Length,\r
56 &BaseAddress,\r
57 ImageHandle,\r
58 NULL\r
59 );\r
60 ASSERT_EFI_ERROR (Status);\r
61 } else {\r
62 Status = gDS->AddIoSpace (\r
63 GcdType,\r
64 BaseAddress,\r
65 Length\r
66 );\r
67 ASSERT_EFI_ERROR (Status);\r
68 Status = gDS->AllocateIoSpace (\r
69 EfiGcdAllocateAddress,\r
70 GcdType,\r
71 Alignment,\r
72 Length,\r
73 &BaseAddress,\r
74 ImageHandle,\r
75 NULL\r
76 );\r
77 ASSERT_EFI_ERROR (Status);\r
78 }\r
79 return Status;\r
80}\r
81\r
82\r
83/**\r
84 Main entry for the bootloader support DXE module.\r
85\r
86 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
87 @param[in] SystemTable A pointer to the EFI System Table.\r
88\r
89 @retval EFI_SUCCESS The entry point is executed successfully.\r
90 @retval other Some error occurs when executing this entry point.\r
91\r
92**/\r
93EFI_STATUS\r
94EFIAPI\r
95BlDxeEntryPoint (\r
96 IN EFI_HANDLE ImageHandle,\r
97 IN EFI_SYSTEM_TABLE *SystemTable\r
98 )\r
99{\r
100 EFI_STATUS Status;\r
101 EFI_HOB_GUID_TYPE *GuidHob;\r
102 SYSTEM_TABLE_INFO *SystemTableInfo;\r
103 EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;\r
104\r
105 Status = EFI_SUCCESS;\r
106 //\r
107 // Report MMIO/IO Resources\r
108 //\r
109 Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC\r
110 ASSERT_EFI_ERROR (Status);\r
111\r
112 Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET\r
113 ASSERT_EFI_ERROR (Status);\r
114\r
115 //\r
116 // Find the system table information guid hob\r
117 //\r
118 GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);\r
119 ASSERT (GuidHob != NULL);\r
120 SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
121\r
122 //\r
123 // Install Acpi Table\r
124 //\r
125 if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {\r
126 DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));\r
127 Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);\r
128 ASSERT_EFI_ERROR (Status);\r
129 }\r
130\r
131 //\r
132 // Install Smbios Table\r
133 //\r
134 if (SystemTableInfo->SmbiosTableBase != 0 && SystemTableInfo->SmbiosTableSize != 0) {\r
135 DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));\r
136 Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)SystemTableInfo->SmbiosTableBase);\r
137 ASSERT_EFI_ERROR (Status);\r
138 }\r
139\r
140 //\r
141 // Find the frame buffer information and update PCDs\r
142 //\r
143 GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);\r
144 if (GuidHob != NULL) {\r
145 GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);\r
146 Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
147 ASSERT_EFI_ERROR (Status);\r
148 Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
149 ASSERT_EFI_ERROR (Status);\r
150 Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
151 ASSERT_EFI_ERROR (Status);\r
152 Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
153 ASSERT_EFI_ERROR (Status);\r
154 }\r
155\r
156 return EFI_SUCCESS;\r
157}\r
158\r