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