]>
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 | |
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 | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | BlDxeEntryPoint (\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 | |
04af8bf2 | 102 | EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;\r |
3900a63e | 103 | ACPI_BOARD_INFO *AcpiBoardInfo;\r |
04af8bf2 DG |
104 | \r |
105 | Status = EFI_SUCCESS;\r | |
106 | //\r | |
107 | // Report MMIO/IO Resources\r | |
108 | //\r | |
976d0353 | 109 | Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC\r |
04af8bf2 DG |
110 | ASSERT_EFI_ERROR (Status);\r |
111 | \r | |
976d0353 | 112 | Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET\r |
04af8bf2 DG |
113 | ASSERT_EFI_ERROR (Status);\r |
114 | \r | |
04af8bf2 DG |
115 | //\r |
116 | // Find the frame buffer information and update PCDs\r | |
117 | //\r | |
118 | GuidHob = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);\r | |
119 | if (GuidHob != NULL) {\r | |
120 | GfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GET_GUID_HOB_DATA (GuidHob);\r | |
121 | Status = PcdSet32S (PcdVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r | |
122 | ASSERT_EFI_ERROR (Status);\r | |
123 | Status = PcdSet32S (PcdVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r | |
124 | ASSERT_EFI_ERROR (Status);\r | |
125 | Status = PcdSet32S (PcdSetupVideoHorizontalResolution, GfxInfo->GraphicsMode.HorizontalResolution);\r | |
126 | ASSERT_EFI_ERROR (Status);\r | |
127 | Status = PcdSet32S (PcdSetupVideoVerticalResolution, GfxInfo->GraphicsMode.VerticalResolution);\r | |
128 | ASSERT_EFI_ERROR (Status);\r | |
129 | }\r | |
130 | \r | |
3900a63e | 131 | //\r |
8028b290 | 132 | // Set PcdPciExpressBaseAddress and PcdPciExpressBaseSize by HOB info\r |
3900a63e RN |
133 | //\r |
134 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
135 | if (GuidHob != NULL) {\r | |
136 | AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);\r | |
137 | Status = PcdSet64S (PcdPciExpressBaseAddress, AcpiBoardInfo->PcieBaseAddress);\r | |
138 | ASSERT_EFI_ERROR (Status);\r | |
8028b290 MSB |
139 | Status = PcdSet64S (PcdPciExpressBaseSize, AcpiBoardInfo->PcieBaseSize);\r |
140 | ASSERT_EFI_ERROR (Status);\r | |
3900a63e RN |
141 | }\r |
142 | \r | |
04af8bf2 DG |
143 | return EFI_SUCCESS;\r |
144 | }\r | |
145 | \r |