]>
Commit | Line | Data |
---|---|---|
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 | |
302a8f35 | 5 | Copyright (c) 2014 - 2021, 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 | |
23 | EFI_STATUS\r | |
24 | ReserveResourceInGcd (\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 | |
86e6948c | 44 | DEBUG_WARN,\r |
04af8bf2 DG |
45 | "Failed to add memory space :0x%lx 0x%lx\n",\r |
46 | BaseAddress,\r | |
47 | Length\r | |
48 | ));\r | |
49 | }\r | |
04af8bf2 DG |
50 | Status = gDS->AllocateMemorySpace (\r |
51 | EfiGcdAllocateAddress,\r | |
52 | GcdType,\r | |
53 | Alignment,\r | |
54 | Length,\r | |
55 | &BaseAddress,\r | |
56 | ImageHandle,\r | |
57 | NULL\r | |
58 | );\r | |
04af8bf2 DG |
59 | } else {\r |
60 | Status = gDS->AddIoSpace (\r | |
61 | GcdType,\r | |
62 | BaseAddress,\r | |
63 | Length\r | |
64 | );\r | |
86e6948c ZL |
65 | if (EFI_ERROR (Status)) {\r |
66 | DEBUG ((\r | |
67 | DEBUG_WARN,\r | |
68 | "Failed to add IO space :0x%lx 0x%lx\n",\r | |
69 | BaseAddress,\r | |
70 | Length\r | |
71 | ));\r | |
72 | }\r | |
04af8bf2 DG |
73 | Status = gDS->AllocateIoSpace (\r |
74 | EfiGcdAllocateAddress,\r | |
75 | GcdType,\r | |
76 | Alignment,\r | |
77 | Length,\r | |
78 | &BaseAddress,\r | |
79 | ImageHandle,\r | |
80 | NULL\r | |
81 | );\r | |
04af8bf2 DG |
82 | }\r |
83 | return Status;\r | |
84 | }\r | |
85 | \r | |
86 | \r | |
87 | /**\r | |
88 | Main entry for the bootloader support DXE module.\r | |
89 | \r | |
90 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
91 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
92 | \r | |
93 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
94 | @retval other Some error occurs when executing this entry point.\r | |
95 | \r | |
96 | **/\r | |
97 | EFI_STATUS\r | |
98 | EFIAPI\r | |
99 | BlDxeEntryPoint (\r | |
100 | IN EFI_HANDLE ImageHandle,\r | |
101 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
102 | )\r | |
103 | {\r | |
104 | EFI_STATUS Status;\r | |
105 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
04af8bf2 | 106 | EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;\r |
3900a63e | 107 | ACPI_BOARD_INFO *AcpiBoardInfo;\r |
04af8bf2 DG |
108 | \r |
109 | Status = EFI_SUCCESS;\r | |
110 | //\r | |
111 | // Report MMIO/IO Resources\r | |
112 | //\r | |
86e6948c | 113 | ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC\r |
04af8bf2 | 114 | \r |
86e6948c | 115 | ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET\r |
04af8bf2 | 116 | \r |
04af8bf2 DG |
117 | //\r |
118 | // Find the frame buffer information and update PCDs\r | |
119 | //\r | |
120 | GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);\r | |
121 | if (GuidHob != NULL) {\r | |
122 | GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);\r | |
123 | Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r | |
124 | ASSERT_EFI_ERROR (Status);\r | |
125 | Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r | |
126 | ASSERT_EFI_ERROR (Status);\r | |
127 | Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r | |
128 | ASSERT_EFI_ERROR (Status);\r | |
129 | Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r | |
130 | ASSERT_EFI_ERROR (Status);\r | |
131 | }\r | |
132 | \r | |
3900a63e | 133 | //\r |
8028b290 | 134 | // Set PcdPciExpressBaseAddress and PcdPciExpressBaseSize by HOB info\r |
3900a63e RN |
135 | //\r |
136 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
137 | if (GuidHob != NULL) {\r | |
138 | AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);\r | |
139 | Status = PcdSet64S (PcdPciExpressBaseAddress, AcpiBoardInfo->PcieBaseAddress);\r | |
140 | ASSERT_EFI_ERROR (Status);\r | |
8028b290 MSB |
141 | Status = PcdSet64S (PcdPciExpressBaseSize, AcpiBoardInfo->PcieBaseSize);\r |
142 | ASSERT_EFI_ERROR (Status);\r | |
3900a63e RN |
143 | }\r |
144 | \r | |
04af8bf2 DG |
145 | return EFI_SUCCESS;\r |
146 | }\r | |
147 | \r |