]> git.proxmox.com Git - mirror_edk2.git/blame - UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
MdePkg: PciExpressLib support variable size MMCONF
[mirror_edk2.git] / UefiPayloadPkg / BlSupportDxe / BlSupportDxe.c
CommitLineData
04af8bf2
DG
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
3900a63e 5 Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>\r
04af8bf2
DG
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
3900a63e 104 ACPI_BOARD_INFO *AcpiBoardInfo;\r
04af8bf2
DG
105\r
106 Status = EFI_SUCCESS;\r
107 //\r
108 // Report MMIO/IO Resources\r
109 //\r
976d0353 110 Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC\r
04af8bf2
DG
111 ASSERT_EFI_ERROR (Status);\r
112\r
976d0353 113 Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET\r
04af8bf2
DG
114 ASSERT_EFI_ERROR (Status);\r
115\r
116 //\r
117 // Find the system table information guid hob\r
118 //\r
119 GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);\r
120 ASSERT (GuidHob != NULL);\r
121 SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
122\r
123 //\r
124 // Install Acpi Table\r
125 //\r
126 if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {\r
127 DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));\r
128 Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);\r
129 ASSERT_EFI_ERROR (Status);\r
130 }\r
131\r
132 //\r
133 // Install Smbios Table\r
134 //\r
135 if (SystemTableInfo->SmbiosTableBase != 0 && SystemTableInfo->SmbiosTableSize != 0) {\r
136 DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));\r
137 Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)SystemTableInfo->SmbiosTableBase);\r
138 ASSERT_EFI_ERROR (Status);\r
139 }\r
140\r
141 //\r
142 // Find the frame buffer information and update PCDs\r
143 //\r
144 GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);\r
145 if (GuidHob != NULL) {\r
146 GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);\r
147 Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
148 ASSERT_EFI_ERROR (Status);\r
149 Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
150 ASSERT_EFI_ERROR (Status);\r
151 Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r
152 ASSERT_EFI_ERROR (Status);\r
153 Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r
154 ASSERT_EFI_ERROR (Status);\r
155 }\r
156\r
3900a63e
RN
157 //\r
158 // Set PcdPciExpressBaseAddress by HOB info\r
159 //\r
160 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
161 if (GuidHob != NULL) {\r
162 AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
163 Status = PcdSet64S (PcdPciExpressBaseAddress, AcpiBoardInfo->PcieBaseAddress);\r
164 ASSERT_EFI_ERROR (Status);\r
165 }\r
166\r
04af8bf2
DG
167 return EFI_SUCCESS;\r
168}\r
169\r