1 | /** @file
|
---|
2 | This library will parse the Slim Bootloader to get required information.
|
---|
3 |
|
---|
4 | Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include <PiDxe.h>
|
---|
10 | #include <Library/BaseLib.h>
|
---|
11 | #include <Library/BaseMemoryLib.h>
|
---|
12 | #include <Library/DebugLib.h>
|
---|
13 | #include <Library/PcdLib.h>
|
---|
14 | #include <Library/IoLib.h>
|
---|
15 | #include <Library/HobLib.h>
|
---|
16 | #include <Library/BlParseLib.h>
|
---|
17 | #include <IndustryStandard/Acpi.h>
|
---|
18 |
|
---|
19 |
|
---|
20 | /**
|
---|
21 | This function retrieves the parameter base address from boot loader.
|
---|
22 |
|
---|
23 | This function will get bootloader specific parameter address for UEFI payload.
|
---|
24 | e.g. HobList pointer for Slim Bootloader, and coreboot table header for Coreboot.
|
---|
25 |
|
---|
26 | @retval NULL Failed to find the GUID HOB.
|
---|
27 | @retval others GUIDed HOB data pointer.
|
---|
28 |
|
---|
29 | **/
|
---|
30 | VOID *
|
---|
31 | EFIAPI
|
---|
32 | GetParameterBase (
|
---|
33 | VOID
|
---|
34 | )
|
---|
35 | {
|
---|
36 | EFI_HOB_HANDOFF_INFO_TABLE *HandoffTable;
|
---|
37 |
|
---|
38 | HandoffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)(UINTN) GET_BOOTLOADER_PARAMETER ();
|
---|
39 | if ((HandoffTable->Header.HobType == EFI_HOB_TYPE_HANDOFF) &&
|
---|
40 | (HandoffTable->Header.HobLength == sizeof (EFI_HOB_HANDOFF_INFO_TABLE)) &&
|
---|
41 | (HandoffTable->Header.Reserved == 0)) {
|
---|
42 | return (VOID *)HandoffTable;
|
---|
43 | }
|
---|
44 |
|
---|
45 | return NULL;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | /**
|
---|
50 | This function retrieves a GUIDed HOB data from Slim Bootloader.
|
---|
51 |
|
---|
52 | This function will search SBL HOB list to find the first GUIDed HOB that
|
---|
53 | its GUID matches Guid.
|
---|
54 |
|
---|
55 | @param[in] Guid A pointer to HOB GUID to search.
|
---|
56 |
|
---|
57 | @retval NULL Failed to find the GUID HOB.
|
---|
58 | @retval others GUIDed HOB data pointer.
|
---|
59 |
|
---|
60 | **/
|
---|
61 | VOID *
|
---|
62 | GetGuidHobDataFromSbl (
|
---|
63 | IN EFI_GUID *Guid
|
---|
64 | )
|
---|
65 | {
|
---|
66 | UINT8 *GuidHob;
|
---|
67 | CONST VOID *HobList;
|
---|
68 |
|
---|
69 | HobList = GetParameterBase ();
|
---|
70 | ASSERT (HobList != NULL);
|
---|
71 | GuidHob = GetNextGuidHob (Guid, HobList);
|
---|
72 | if (GuidHob != NULL) {
|
---|
73 | return GET_GUID_HOB_DATA (GuidHob);
|
---|
74 | }
|
---|
75 |
|
---|
76 | return NULL;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Acquire the memory map information.
|
---|
81 |
|
---|
82 | @param MemInfoCallback The callback routine
|
---|
83 | @param Params Pointer to the callback routine parameter
|
---|
84 |
|
---|
85 | @retval RETURN_SUCCESS Successfully find out the memory information.
|
---|
86 | @retval RETURN_NOT_FOUND Failed to find the memory information.
|
---|
87 |
|
---|
88 | **/
|
---|
89 | RETURN_STATUS
|
---|
90 | EFIAPI
|
---|
91 | ParseMemoryInfo (
|
---|
92 | IN BL_MEM_INFO_CALLBACK MemInfoCallback,
|
---|
93 | IN VOID *Params
|
---|
94 | )
|
---|
95 | {
|
---|
96 | MEMROY_MAP_INFO *MemoryMapInfo;
|
---|
97 | UINTN Idx;
|
---|
98 |
|
---|
99 | MemoryMapInfo = (MEMROY_MAP_INFO *) GetGuidHobDataFromSbl (&gLoaderMemoryMapInfoGuid);
|
---|
100 | if (MemoryMapInfo == NULL) {
|
---|
101 | ASSERT (FALSE);
|
---|
102 | return RETURN_NOT_FOUND;
|
---|
103 | }
|
---|
104 |
|
---|
105 | for (Idx = 0; Idx < MemoryMapInfo->Count; Idx++) {
|
---|
106 | MemInfoCallback (&MemoryMapInfo->Entry[Idx], Params);
|
---|
107 | }
|
---|
108 |
|
---|
109 | return RETURN_SUCCESS;
|
---|
110 | }
|
---|
111 |
|
---|
112 | /**
|
---|
113 | Acquire acpi table and smbios table from slim bootloader
|
---|
114 |
|
---|
115 | @param SystemTableInfo Pointer to the system table info
|
---|
116 |
|
---|
117 | @retval RETURN_SUCCESS Successfully find out the tables.
|
---|
118 | @retval RETURN_NOT_FOUND Failed to find the tables.
|
---|
119 |
|
---|
120 | **/
|
---|
121 | RETURN_STATUS
|
---|
122 | EFIAPI
|
---|
123 | ParseSystemTable (
|
---|
124 | OUT SYSTEM_TABLE_INFO *SystemTableInfo
|
---|
125 | )
|
---|
126 | {
|
---|
127 | SYSTEM_TABLE_INFO *TableInfo;
|
---|
128 |
|
---|
129 | TableInfo = (SYSTEM_TABLE_INFO *)GetGuidHobDataFromSbl (&gUefiSystemTableInfoGuid);
|
---|
130 | if (TableInfo == NULL) {
|
---|
131 | ASSERT (FALSE);
|
---|
132 | return RETURN_NOT_FOUND;
|
---|
133 | }
|
---|
134 |
|
---|
135 | CopyMem (SystemTableInfo, TableInfo, sizeof (SYSTEM_TABLE_INFO));
|
---|
136 |
|
---|
137 | return RETURN_SUCCESS;
|
---|
138 | }
|
---|
139 |
|
---|
140 |
|
---|
141 | /**
|
---|
142 | Find the serial port information
|
---|
143 |
|
---|
144 | @param SERIAL_PORT_INFO Pointer to serial port info structure
|
---|
145 |
|
---|
146 | @retval RETURN_SUCCESS Successfully find the serial port information.
|
---|
147 | @retval RETURN_NOT_FOUND Failed to find the serial port information .
|
---|
148 |
|
---|
149 | **/
|
---|
150 | RETURN_STATUS
|
---|
151 | EFIAPI
|
---|
152 | ParseSerialInfo (
|
---|
153 | OUT SERIAL_PORT_INFO *SerialPortInfo
|
---|
154 | )
|
---|
155 | {
|
---|
156 | SERIAL_PORT_INFO *BlSerialInfo;
|
---|
157 |
|
---|
158 | BlSerialInfo = (SERIAL_PORT_INFO *) GetGuidHobDataFromSbl (&gUefiSerialPortInfoGuid);
|
---|
159 | if (BlSerialInfo == NULL) {
|
---|
160 | ASSERT (FALSE);
|
---|
161 | return RETURN_NOT_FOUND;
|
---|
162 | }
|
---|
163 |
|
---|
164 | CopyMem (SerialPortInfo, BlSerialInfo, sizeof (SERIAL_PORT_INFO));
|
---|
165 |
|
---|
166 | return RETURN_SUCCESS;
|
---|
167 | }
|
---|
168 |
|
---|
169 |
|
---|
170 | /**
|
---|
171 | Find the video frame buffer information
|
---|
172 |
|
---|
173 | @param GfxInfo Pointer to the EFI_PEI_GRAPHICS_INFO_HOB structure
|
---|
174 |
|
---|
175 | @retval RETURN_SUCCESS Successfully find the video frame buffer information.
|
---|
176 | @retval RETURN_NOT_FOUND Failed to find the video frame buffer information .
|
---|
177 |
|
---|
178 | **/
|
---|
179 | RETURN_STATUS
|
---|
180 | EFIAPI
|
---|
181 | ParseGfxInfo (
|
---|
182 | OUT EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo
|
---|
183 | )
|
---|
184 | {
|
---|
185 | EFI_PEI_GRAPHICS_INFO_HOB *BlGfxInfo;
|
---|
186 |
|
---|
187 | BlGfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsInfoHobGuid);
|
---|
188 | if (BlGfxInfo == NULL) {
|
---|
189 | return RETURN_NOT_FOUND;
|
---|
190 | }
|
---|
191 |
|
---|
192 | CopyMem (GfxInfo, BlGfxInfo, sizeof (EFI_PEI_GRAPHICS_INFO_HOB));
|
---|
193 |
|
---|
194 | return RETURN_SUCCESS;
|
---|
195 | }
|
---|
196 |
|
---|
197 | /**
|
---|
198 | Find the video frame buffer device information
|
---|
199 |
|
---|
200 | @param GfxDeviceInfo Pointer to the EFI_PEI_GRAPHICS_DEVICE_INFO_HOB structure
|
---|
201 |
|
---|
202 | @retval RETURN_SUCCESS Successfully find the video frame buffer information.
|
---|
203 | @retval RETURN_NOT_FOUND Failed to find the video frame buffer information.
|
---|
204 |
|
---|
205 | **/
|
---|
206 | RETURN_STATUS
|
---|
207 | EFIAPI
|
---|
208 | ParseGfxDeviceInfo (
|
---|
209 | OUT EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *GfxDeviceInfo
|
---|
210 | )
|
---|
211 | {
|
---|
212 | EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *BlGfxDeviceInfo;
|
---|
213 |
|
---|
214 | BlGfxDeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsDeviceInfoHobGuid);
|
---|
215 | if (BlGfxDeviceInfo == NULL) {
|
---|
216 | return RETURN_NOT_FOUND;
|
---|
217 | }
|
---|
218 |
|
---|
219 | CopyMem (GfxDeviceInfo, BlGfxDeviceInfo, sizeof (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB));
|
---|
220 |
|
---|
221 | return RETURN_SUCCESS;
|
---|
222 | }
|
---|
223 |
|
---|