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