]>
Commit | Line | Data |
---|---|---|
43ac100e OM |
1 | /** @file\r |
2 | \r | |
9c8fe63c | 3 | Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r |
43ac100e OM |
4 | Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "IntelBdsPlatform.h"\r | |
17 | \r | |
18 | ///\r | |
19 | /// Predefined platform default time out value\r | |
20 | ///\r | |
21 | UINT16 gPlatformBootTimeOutDefault;\r | |
22 | \r | |
23 | EFI_STATUS\r | |
24 | EFIAPI\r | |
25 | PlatformIntelBdsConstructor (\r | |
26 | IN EFI_HANDLE ImageHandle,\r | |
27 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
28 | )\r | |
29 | {\r | |
30 | gPlatformBootTimeOutDefault = (UINT16)PcdGet16 (PcdPlatformBootTimeOut);\r | |
31 | return EFI_SUCCESS;\r | |
32 | }\r | |
33 | \r | |
34 | //\r | |
35 | // BDS Platform Functions\r | |
36 | //\r | |
37 | /**\r | |
38 | Platform Bds init. Include the platform firmware vendor, revision\r | |
39 | and so crc check.\r | |
40 | \r | |
41 | **/\r | |
42 | VOID\r | |
43 | EFIAPI\r | |
44 | PlatformBdsInit (\r | |
45 | VOID\r | |
46 | )\r | |
47 | {\r | |
0f060e34 AB |
48 | //\r |
49 | // Signal EndOfDxe PI Event\r | |
50 | //\r | |
9c8fe63c | 51 | EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r |
43ac100e OM |
52 | }\r |
53 | \r | |
54 | STATIC\r | |
55 | EFI_STATUS\r | |
56 | GetConsoleDevicePathFromVariable (\r | |
57 | IN CHAR16* ConsoleVarName,\r | |
58 | IN CHAR16* DefaultConsolePaths,\r | |
59 | OUT EFI_DEVICE_PATH** DevicePaths\r | |
60 | )\r | |
61 | {\r | |
62 | EFI_STATUS Status;\r | |
63 | UINTN Size;\r | |
64 | EFI_DEVICE_PATH_PROTOCOL* DevicePathInstances;\r | |
65 | EFI_DEVICE_PATH_PROTOCOL* DevicePathInstance;\r | |
66 | CHAR16* DevicePathStr;\r | |
67 | CHAR16* NextDevicePathStr;\r | |
68 | EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;\r | |
69 | \r | |
3baf5c9f AB |
70 | Status = EFI_SUCCESS;\r |
71 | Size = 0;\r | |
72 | \r | |
73 | DevicePathInstances = BdsLibGetVariableAndSize (ConsoleVarName, &gEfiGlobalVariableGuid, &Size);\r | |
74 | if (DevicePathInstances == NULL) {\r | |
43ac100e OM |
75 | // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)\r |
76 | if ((DefaultConsolePaths == NULL) || (DefaultConsolePaths[0] == L'\0')) {\r | |
77 | *DevicePaths = NULL;\r | |
78 | return EFI_SUCCESS;\r | |
79 | }\r | |
80 | \r | |
81 | Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);\r | |
82 | ASSERT_EFI_ERROR(Status);\r | |
83 | \r | |
43ac100e OM |
84 | // Extract the Device Path instances from the multi-device path string\r |
85 | while ((DefaultConsolePaths != NULL) && (DefaultConsolePaths[0] != L'\0')) {\r | |
86 | NextDevicePathStr = StrStr (DefaultConsolePaths, L";");\r | |
87 | if (NextDevicePathStr == NULL) {\r | |
88 | DevicePathStr = DefaultConsolePaths;\r | |
89 | DefaultConsolePaths = NULL;\r | |
90 | } else {\r | |
91 | DevicePathStr = (CHAR16*)AllocateCopyPool ((NextDevicePathStr - DefaultConsolePaths + 1) * sizeof(CHAR16), DefaultConsolePaths);\r | |
92 | *(DevicePathStr + (NextDevicePathStr - DefaultConsolePaths)) = L'\0';\r | |
93 | DefaultConsolePaths = NextDevicePathStr;\r | |
94 | if (DefaultConsolePaths[0] == L';') {\r | |
95 | DefaultConsolePaths++;\r | |
96 | }\r | |
97 | }\r | |
98 | \r | |
99 | DevicePathInstance = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (DevicePathStr);\r | |
100 | ASSERT(DevicePathInstance != NULL);\r | |
101 | DevicePathInstances = AppendDevicePathInstance (DevicePathInstances, DevicePathInstance);\r | |
102 | \r | |
103 | if (NextDevicePathStr != NULL) {\r | |
104 | FreePool (DevicePathStr);\r | |
105 | }\r | |
106 | FreePool (DevicePathInstance);\r | |
107 | }\r | |
108 | \r | |
109 | // Set the environment variable with this device path multi-instances\r | |
110 | Size = GetDevicePathSize (DevicePathInstances);\r | |
111 | if (Size > 0) {\r | |
112 | gRT->SetVariable (\r | |
113 | ConsoleVarName,\r | |
114 | &gEfiGlobalVariableGuid,\r | |
115 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
116 | Size,\r | |
117 | DevicePathInstances\r | |
118 | );\r | |
119 | } else {\r | |
120 | Status = EFI_INVALID_PARAMETER;\r | |
121 | }\r | |
122 | }\r | |
123 | \r | |
124 | if (!EFI_ERROR(Status)) {\r | |
125 | *DevicePaths = DevicePathInstances;\r | |
126 | }\r | |
127 | return Status;\r | |
128 | }\r | |
129 | \r | |
130 | STATIC\r | |
131 | EFI_STATUS\r | |
132 | InitializeConsolePipe (\r | |
133 | IN EFI_DEVICE_PATH *ConsoleDevicePaths,\r | |
134 | IN EFI_GUID *Protocol,\r | |
135 | OUT EFI_HANDLE *Handle,\r | |
136 | OUT VOID* *Interface\r | |
137 | )\r | |
138 | {\r | |
139 | EFI_STATUS Status;\r | |
140 | UINTN Size;\r | |
141 | UINTN NoHandles;\r | |
142 | EFI_HANDLE *Buffer;\r | |
143 | EFI_DEVICE_PATH_PROTOCOL* DevicePath;\r | |
144 | \r | |
145 | // Connect all the Device Path Consoles\r | |
146 | while (ConsoleDevicePaths != NULL) {\r | |
147 | DevicePath = GetNextDevicePathInstance (&ConsoleDevicePaths, &Size);\r | |
148 | \r | |
3baf5c9f AB |
149 | Status = BdsLibConnectDevicePath (DevicePath);\r |
150 | if (!EFI_ERROR (Status)) {\r | |
3858b4a1 | 151 | \r |
3baf5c9f | 152 | //\r |
3858b4a1 AB |
153 | // We connect all supplied console device paths, but only return the first\r |
154 | // one that connects successfully via *Handle/*Interface. Note that this\r | |
155 | // may imply that *Handle/*Interface are not updated at all if they have\r | |
156 | // been connected already, e.g., by the console splitter driver.\r | |
3baf5c9f | 157 | //\r |
3858b4a1 AB |
158 | if (*Interface == NULL) {\r |
159 | //\r | |
160 | // If BdsLibConnectDevicePath () succeeded, *Handle must have a non-NULL\r | |
161 | // value. So ASSERT that this is the case.\r | |
162 | //\r | |
163 | gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, Handle);\r | |
164 | ASSERT (*Handle != NULL);\r | |
165 | \r | |
166 | gBS->HandleProtocol (*Handle, Protocol, Interface);\r | |
167 | }\r | |
3baf5c9f | 168 | }\r |
43ac100e OM |
169 | DEBUG_CODE_BEGIN();\r |
170 | if (EFI_ERROR(Status)) {\r | |
171 | // We convert back to the text representation of the device Path\r | |
3d175bcb AB |
172 | EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevicePathToTextProtocol;\r |
173 | CHAR16 *DevicePathTxt;\r | |
43ac100e | 174 | \r |
3d175bcb AB |
175 | DevicePathToTextProtocol = NULL;\r |
176 | gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **) &DevicePathToTextProtocol);\r | |
177 | if (DevicePathToTextProtocol != NULL) {\r | |
43ac100e OM |
178 | DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (DevicePath, TRUE, TRUE);\r |
179 | \r | |
180 | DEBUG((EFI_D_ERROR,"Fail to start the console with the Device Path '%s'. (Error '%r')\n", DevicePathTxt, Status));\r | |
181 | \r | |
182 | FreePool (DevicePathTxt);\r | |
183 | }\r | |
184 | }\r | |
185 | DEBUG_CODE_END();\r | |
43ac100e OM |
186 | }\r |
187 | \r | |
188 | // No Device Path has been defined for this console interface. We take the first protocol implementation\r | |
189 | if (*Interface == NULL) {\r | |
190 | Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);\r | |
191 | if (EFI_ERROR (Status)) {\r | |
3baf5c9f | 192 | BdsLibConnectAll ();\r |
43ac100e OM |
193 | Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);\r |
194 | }\r | |
195 | \r | |
196 | if (!EFI_ERROR(Status)) {\r | |
197 | *Handle = Buffer[0];\r | |
198 | Status = gBS->HandleProtocol (*Handle, Protocol, Interface);\r | |
199 | ASSERT_EFI_ERROR (Status);\r | |
3a2b37f0 | 200 | FreePool (Buffer);\r |
43ac100e | 201 | }\r |
43ac100e OM |
202 | } else {\r |
203 | Status = EFI_SUCCESS;\r | |
204 | }\r | |
205 | \r | |
206 | return Status;\r | |
207 | }\r | |
208 | \r | |
209 | /**\r | |
210 | Connect the predefined platform default console device. Always try to find\r | |
211 | and enable the vga device if have.\r | |
212 | \r | |
213 | @param PlatformConsole Predefined platform default console device array.\r | |
214 | \r | |
215 | @retval EFI_SUCCESS Success connect at least one ConIn and ConOut\r | |
216 | device, there must have one ConOut device is\r | |
217 | active vga device.\r | |
218 | @return Return the status of BdsLibConnectAllDefaultConsoles ()\r | |
219 | \r | |
220 | **/\r | |
221 | EFI_STATUS\r | |
222 | PlatformBdsConnectConsole (\r | |
223 | VOID\r | |
224 | )\r | |
225 | {\r | |
226 | EFI_STATUS Status;\r | |
227 | EFI_DEVICE_PATH* ConOutDevicePaths;\r | |
228 | EFI_DEVICE_PATH* ConInDevicePaths;\r | |
229 | EFI_DEVICE_PATH* ConErrDevicePaths;\r | |
230 | \r | |
231 | // By getting the Console Device Paths from the environment variables before initializing the console pipe, we\r | |
232 | // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface\r | |
233 | // of newly installed console drivers\r | |
234 | Status = GetConsoleDevicePathFromVariable (L"ConOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConOutDevicePaths);\r | |
235 | ASSERT_EFI_ERROR (Status);\r | |
236 | Status = GetConsoleDevicePathFromVariable (L"ConIn", (CHAR16*)PcdGetPtr(PcdDefaultConInPaths), &ConInDevicePaths);\r | |
237 | ASSERT_EFI_ERROR (Status);\r | |
238 | Status = GetConsoleDevicePathFromVariable (L"ErrOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConErrDevicePaths);\r | |
239 | ASSERT_EFI_ERROR (Status);\r | |
240 | \r | |
241 | // Initialize the Consoles\r | |
242 | Status = InitializeConsolePipe (ConOutDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST->ConOut);\r | |
243 | ASSERT_EFI_ERROR (Status);\r | |
244 | Status = InitializeConsolePipe (ConInDevicePaths, &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST->ConIn);\r | |
245 | ASSERT_EFI_ERROR (Status);\r | |
246 | Status = InitializeConsolePipe (ConErrDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **)&gST->StdErr);\r | |
247 | if (EFI_ERROR(Status)) {\r | |
248 | // In case of error, we reuse the console output for the error output\r | |
249 | gST->StandardErrorHandle = gST->ConsoleOutHandle;\r | |
250 | gST->StdErr = gST->ConOut;\r | |
251 | }\r | |
252 | \r | |
253 | return Status;\r | |
254 | }\r | |
255 | \r | |
256 | /**\r | |
257 | Connect with predefined platform connect sequence,\r | |
258 | the OEM/IBV can customize with their own connect sequence.\r | |
259 | **/\r | |
260 | VOID\r | |
261 | PlatformBdsConnectSequence (\r | |
262 | VOID\r | |
263 | )\r | |
264 | {\r | |
265 | }\r | |
266 | \r | |
267 | /**\r | |
268 | Load the predefined driver option, OEM/IBV can customize this\r | |
269 | to load their own drivers\r | |
270 | \r | |
271 | @param BdsDriverLists - The header of the driver option link list.\r | |
272 | \r | |
273 | **/\r | |
274 | VOID\r | |
275 | PlatformBdsGetDriverOption (\r | |
276 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
277 | )\r | |
278 | {\r | |
279 | }\r | |
280 | \r | |
281 | /**\r | |
282 | Perform the platform diagnostic, such like test memory. OEM/IBV also\r | |
283 | can customize this function to support specific platform diagnostic.\r | |
284 | \r | |
285 | @param MemoryTestLevel The memory test intensive level\r | |
286 | @param QuietBoot Indicate if need to enable the quiet boot\r | |
287 | @param BaseMemoryTest A pointer to BdsMemoryTest()\r | |
288 | \r | |
289 | **/\r | |
290 | VOID\r | |
291 | PlatformBdsDiagnostics (\r | |
292 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
293 | IN BOOLEAN QuietBoot,\r | |
294 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
295 | )\r | |
296 | {\r | |
297 | }\r | |
298 | \r | |
299 | /**\r | |
300 | The function will execute with as the platform policy, current policy\r | |
301 | is driven by boot mode. IBV/OEM can customize this code for their specific\r | |
302 | policy action.\r | |
303 | \r | |
304 | @param DriverOptionList The header of the driver option link list\r | |
305 | @param BootOptionList The header of the boot option link list\r | |
306 | @param ProcessCapsules A pointer to ProcessCapsules()\r | |
307 | @param BaseMemoryTest A pointer to BaseMemoryTest()\r | |
308 | \r | |
309 | **/\r | |
310 | VOID\r | |
311 | EFIAPI\r | |
312 | PlatformBdsPolicyBehavior (\r | |
313 | IN LIST_ENTRY *DriverOptionList,\r | |
314 | IN LIST_ENTRY *BootOptionList,\r | |
315 | IN PROCESS_CAPSULES ProcessCapsules,\r | |
316 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
317 | )\r | |
318 | {\r | |
319 | EFI_STATUS Status;\r | |
320 | \r | |
321 | Status = PlatformBdsConnectConsole ();\r | |
322 | ASSERT_EFI_ERROR (Status);\r | |
a680d52f AB |
323 | \r |
324 | //\r | |
325 | // Show the splash screen.\r | |
326 | //\r | |
327 | EnableQuietBoot (PcdGetPtr (PcdLogoFile));\r | |
50e8d393 LL |
328 | \r |
329 | //\r | |
330 | // Connect _all_ devices, to pick up plug-in and removable devices\r | |
331 | // TODO: do this more cleanly, permitting faster boot times when boot config\r | |
332 | // is known\r | |
333 | //\r | |
334 | BdsLibConnectAll ();\r | |
43ac100e OM |
335 | }\r |
336 | \r | |
337 | /**\r | |
338 | Hook point after a boot attempt succeeds. We don't expect a boot option to\r | |
339 | return, so the UEFI 2.0 specification defines that you will default to an\r | |
340 | interactive mode and stop processing the BootOrder list in this case. This\r | |
341 | is also a platform implementation and can be customized by IBV/OEM.\r | |
342 | \r | |
343 | @param Option Pointer to Boot Option that succeeded to boot.\r | |
344 | \r | |
345 | **/\r | |
346 | VOID\r | |
347 | EFIAPI\r | |
348 | PlatformBdsBootSuccess (\r | |
349 | IN BDS_COMMON_OPTION *Option\r | |
350 | )\r | |
351 | {\r | |
352 | }\r | |
353 | \r | |
354 | /**\r | |
355 | Hook point after a boot attempt fails.\r | |
356 | \r | |
357 | @param Option Pointer to Boot Option that failed to boot.\r | |
358 | @param Status Status returned from failed boot.\r | |
359 | @param ExitData Exit data returned from failed boot.\r | |
360 | @param ExitDataSize Exit data size returned from failed boot.\r | |
361 | \r | |
362 | **/\r | |
363 | VOID\r | |
364 | EFIAPI\r | |
365 | PlatformBdsBootFail (\r | |
366 | IN BDS_COMMON_OPTION *Option,\r | |
367 | IN EFI_STATUS Status,\r | |
368 | IN CHAR16 *ExitData,\r | |
369 | IN UINTN ExitDataSize\r | |
370 | )\r | |
371 | {\r | |
372 | }\r | |
373 | \r | |
374 | /**\r | |
375 | This function locks platform flash that is not allowed to be updated during normal boot path.\r | |
376 | The flash layout is platform specific.\r | |
377 | **/\r | |
378 | VOID\r | |
379 | EFIAPI\r | |
380 | PlatformBdsLockNonUpdatableFlash (\r | |
381 | VOID\r | |
382 | )\r | |
383 | {\r | |
384 | return;\r | |
385 | }\r | |
386 | \r | |
387 | \r | |
388 | /**\r | |
389 | Lock the ConsoleIn device in system table. All key\r | |
390 | presses will be ignored until the Password is typed in. The only way to\r | |
391 | disable the password is to type it in to a ConIn device.\r | |
392 | \r | |
393 | @param Password Password used to lock ConIn device.\r | |
394 | \r | |
395 | @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r | |
396 | @retval EFI_UNSUPPORTED Password not found\r | |
397 | \r | |
398 | **/\r | |
399 | EFI_STATUS\r | |
400 | EFIAPI\r | |
401 | LockKeyboards (\r | |
402 | IN CHAR16 *Password\r | |
403 | )\r | |
404 | {\r | |
405 | return EFI_UNSUPPORTED;\r | |
406 | }\r |