]>
Commit | Line | Data |
---|---|---|
43ac100e OM |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r | |
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 | |
48 | }\r | |
49 | \r | |
50 | STATIC\r | |
51 | EFI_STATUS\r | |
52 | GetConsoleDevicePathFromVariable (\r | |
53 | IN CHAR16* ConsoleVarName,\r | |
54 | IN CHAR16* DefaultConsolePaths,\r | |
55 | OUT EFI_DEVICE_PATH** DevicePaths\r | |
56 | )\r | |
57 | {\r | |
58 | EFI_STATUS Status;\r | |
59 | UINTN Size;\r | |
60 | EFI_DEVICE_PATH_PROTOCOL* DevicePathInstances;\r | |
61 | EFI_DEVICE_PATH_PROTOCOL* DevicePathInstance;\r | |
62 | CHAR16* DevicePathStr;\r | |
63 | CHAR16* NextDevicePathStr;\r | |
64 | EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol;\r | |
65 | \r | |
66 | Status = GetGlobalEnvironmentVariable (ConsoleVarName, NULL, NULL, (VOID**)&DevicePathInstances);\r | |
67 | if (EFI_ERROR(Status)) {\r | |
68 | // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)\r | |
69 | if ((DefaultConsolePaths == NULL) || (DefaultConsolePaths[0] == L'\0')) {\r | |
70 | *DevicePaths = NULL;\r | |
71 | return EFI_SUCCESS;\r | |
72 | }\r | |
73 | \r | |
74 | Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);\r | |
75 | ASSERT_EFI_ERROR(Status);\r | |
76 | \r | |
77 | DevicePathInstances = NULL;\r | |
78 | \r | |
79 | // Extract the Device Path instances from the multi-device path string\r | |
80 | while ((DefaultConsolePaths != NULL) && (DefaultConsolePaths[0] != L'\0')) {\r | |
81 | NextDevicePathStr = StrStr (DefaultConsolePaths, L";");\r | |
82 | if (NextDevicePathStr == NULL) {\r | |
83 | DevicePathStr = DefaultConsolePaths;\r | |
84 | DefaultConsolePaths = NULL;\r | |
85 | } else {\r | |
86 | DevicePathStr = (CHAR16*)AllocateCopyPool ((NextDevicePathStr - DefaultConsolePaths + 1) * sizeof(CHAR16), DefaultConsolePaths);\r | |
87 | *(DevicePathStr + (NextDevicePathStr - DefaultConsolePaths)) = L'\0';\r | |
88 | DefaultConsolePaths = NextDevicePathStr;\r | |
89 | if (DefaultConsolePaths[0] == L';') {\r | |
90 | DefaultConsolePaths++;\r | |
91 | }\r | |
92 | }\r | |
93 | \r | |
94 | DevicePathInstance = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (DevicePathStr);\r | |
95 | ASSERT(DevicePathInstance != NULL);\r | |
96 | DevicePathInstances = AppendDevicePathInstance (DevicePathInstances, DevicePathInstance);\r | |
97 | \r | |
98 | if (NextDevicePathStr != NULL) {\r | |
99 | FreePool (DevicePathStr);\r | |
100 | }\r | |
101 | FreePool (DevicePathInstance);\r | |
102 | }\r | |
103 | \r | |
104 | // Set the environment variable with this device path multi-instances\r | |
105 | Size = GetDevicePathSize (DevicePathInstances);\r | |
106 | if (Size > 0) {\r | |
107 | gRT->SetVariable (\r | |
108 | ConsoleVarName,\r | |
109 | &gEfiGlobalVariableGuid,\r | |
110 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
111 | Size,\r | |
112 | DevicePathInstances\r | |
113 | );\r | |
114 | } else {\r | |
115 | Status = EFI_INVALID_PARAMETER;\r | |
116 | }\r | |
117 | }\r | |
118 | \r | |
119 | if (!EFI_ERROR(Status)) {\r | |
120 | *DevicePaths = DevicePathInstances;\r | |
121 | }\r | |
122 | return Status;\r | |
123 | }\r | |
124 | \r | |
125 | STATIC\r | |
126 | EFI_STATUS\r | |
127 | InitializeConsolePipe (\r | |
128 | IN EFI_DEVICE_PATH *ConsoleDevicePaths,\r | |
129 | IN EFI_GUID *Protocol,\r | |
130 | OUT EFI_HANDLE *Handle,\r | |
131 | OUT VOID* *Interface\r | |
132 | )\r | |
133 | {\r | |
134 | EFI_STATUS Status;\r | |
135 | UINTN Size;\r | |
136 | UINTN NoHandles;\r | |
137 | EFI_HANDLE *Buffer;\r | |
138 | EFI_DEVICE_PATH_PROTOCOL* DevicePath;\r | |
139 | \r | |
140 | // Connect all the Device Path Consoles\r | |
141 | while (ConsoleDevicePaths != NULL) {\r | |
142 | DevicePath = GetNextDevicePathInstance (&ConsoleDevicePaths, &Size);\r | |
143 | \r | |
144 | Status = BdsConnectDevicePath (DevicePath, Handle, NULL);\r | |
145 | DEBUG_CODE_BEGIN();\r | |
146 | if (EFI_ERROR(Status)) {\r | |
147 | // We convert back to the text representation of the device Path\r | |
148 | EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r | |
149 | CHAR16* DevicePathTxt;\r | |
150 | EFI_STATUS Status;\r | |
151 | \r | |
152 | Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r | |
153 | if (!EFI_ERROR(Status)) {\r | |
154 | DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (DevicePath, TRUE, TRUE);\r | |
155 | \r | |
156 | DEBUG((EFI_D_ERROR,"Fail to start the console with the Device Path '%s'. (Error '%r')\n", DevicePathTxt, Status));\r | |
157 | \r | |
158 | FreePool (DevicePathTxt);\r | |
159 | }\r | |
160 | }\r | |
161 | DEBUG_CODE_END();\r | |
162 | \r | |
163 | // If the console splitter driver is not supported by the platform then use the first Device Path\r | |
164 | // instance for the console interface.\r | |
165 | if (!EFI_ERROR(Status) && (*Interface == NULL)) {\r | |
166 | Status = gBS->HandleProtocol (*Handle, Protocol, Interface);\r | |
167 | }\r | |
168 | }\r | |
169 | \r | |
170 | // No Device Path has been defined for this console interface. We take the first protocol implementation\r | |
171 | if (*Interface == NULL) {\r | |
172 | Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);\r | |
173 | if (EFI_ERROR (Status)) {\r | |
174 | BdsConnectAllDrivers ();\r | |
175 | Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL, &NoHandles, &Buffer);\r | |
176 | }\r | |
177 | \r | |
178 | if (!EFI_ERROR(Status)) {\r | |
179 | *Handle = Buffer[0];\r | |
180 | Status = gBS->HandleProtocol (*Handle, Protocol, Interface);\r | |
181 | ASSERT_EFI_ERROR (Status);\r | |
182 | }\r | |
183 | FreePool (Buffer);\r | |
184 | } else {\r | |
185 | Status = EFI_SUCCESS;\r | |
186 | }\r | |
187 | \r | |
188 | return Status;\r | |
189 | }\r | |
190 | \r | |
191 | /**\r | |
192 | Connect the predefined platform default console device. Always try to find\r | |
193 | and enable the vga device if have.\r | |
194 | \r | |
195 | @param PlatformConsole Predefined platform default console device array.\r | |
196 | \r | |
197 | @retval EFI_SUCCESS Success connect at least one ConIn and ConOut\r | |
198 | device, there must have one ConOut device is\r | |
199 | active vga device.\r | |
200 | @return Return the status of BdsLibConnectAllDefaultConsoles ()\r | |
201 | \r | |
202 | **/\r | |
203 | EFI_STATUS\r | |
204 | PlatformBdsConnectConsole (\r | |
205 | VOID\r | |
206 | )\r | |
207 | {\r | |
208 | EFI_STATUS Status;\r | |
209 | EFI_DEVICE_PATH* ConOutDevicePaths;\r | |
210 | EFI_DEVICE_PATH* ConInDevicePaths;\r | |
211 | EFI_DEVICE_PATH* ConErrDevicePaths;\r | |
212 | \r | |
213 | // By getting the Console Device Paths from the environment variables before initializing the console pipe, we\r | |
214 | // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface\r | |
215 | // of newly installed console drivers\r | |
216 | Status = GetConsoleDevicePathFromVariable (L"ConOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConOutDevicePaths);\r | |
217 | ASSERT_EFI_ERROR (Status);\r | |
218 | Status = GetConsoleDevicePathFromVariable (L"ConIn", (CHAR16*)PcdGetPtr(PcdDefaultConInPaths), &ConInDevicePaths);\r | |
219 | ASSERT_EFI_ERROR (Status);\r | |
220 | Status = GetConsoleDevicePathFromVariable (L"ErrOut", (CHAR16*)PcdGetPtr(PcdDefaultConOutPaths), &ConErrDevicePaths);\r | |
221 | ASSERT_EFI_ERROR (Status);\r | |
222 | \r | |
223 | // Initialize the Consoles\r | |
224 | Status = InitializeConsolePipe (ConOutDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST->ConOut);\r | |
225 | ASSERT_EFI_ERROR (Status);\r | |
226 | Status = InitializeConsolePipe (ConInDevicePaths, &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST->ConIn);\r | |
227 | ASSERT_EFI_ERROR (Status);\r | |
228 | Status = InitializeConsolePipe (ConErrDevicePaths, &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **)&gST->StdErr);\r | |
229 | if (EFI_ERROR(Status)) {\r | |
230 | // In case of error, we reuse the console output for the error output\r | |
231 | gST->StandardErrorHandle = gST->ConsoleOutHandle;\r | |
232 | gST->StdErr = gST->ConOut;\r | |
233 | }\r | |
234 | \r | |
235 | return Status;\r | |
236 | }\r | |
237 | \r | |
238 | /**\r | |
239 | Connect with predefined platform connect sequence,\r | |
240 | the OEM/IBV can customize with their own connect sequence.\r | |
241 | **/\r | |
242 | VOID\r | |
243 | PlatformBdsConnectSequence (\r | |
244 | VOID\r | |
245 | )\r | |
246 | {\r | |
247 | }\r | |
248 | \r | |
249 | /**\r | |
250 | Load the predefined driver option, OEM/IBV can customize this\r | |
251 | to load their own drivers\r | |
252 | \r | |
253 | @param BdsDriverLists - The header of the driver option link list.\r | |
254 | \r | |
255 | **/\r | |
256 | VOID\r | |
257 | PlatformBdsGetDriverOption (\r | |
258 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
259 | )\r | |
260 | {\r | |
261 | }\r | |
262 | \r | |
263 | /**\r | |
264 | Perform the platform diagnostic, such like test memory. OEM/IBV also\r | |
265 | can customize this function to support specific platform diagnostic.\r | |
266 | \r | |
267 | @param MemoryTestLevel The memory test intensive level\r | |
268 | @param QuietBoot Indicate if need to enable the quiet boot\r | |
269 | @param BaseMemoryTest A pointer to BdsMemoryTest()\r | |
270 | \r | |
271 | **/\r | |
272 | VOID\r | |
273 | PlatformBdsDiagnostics (\r | |
274 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
275 | IN BOOLEAN QuietBoot,\r | |
276 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
277 | )\r | |
278 | {\r | |
279 | }\r | |
280 | \r | |
281 | /**\r | |
282 | The function will execute with as the platform policy, current policy\r | |
283 | is driven by boot mode. IBV/OEM can customize this code for their specific\r | |
284 | policy action.\r | |
285 | \r | |
286 | @param DriverOptionList The header of the driver option link list\r | |
287 | @param BootOptionList The header of the boot option link list\r | |
288 | @param ProcessCapsules A pointer to ProcessCapsules()\r | |
289 | @param BaseMemoryTest A pointer to BaseMemoryTest()\r | |
290 | \r | |
291 | **/\r | |
292 | VOID\r | |
293 | EFIAPI\r | |
294 | PlatformBdsPolicyBehavior (\r | |
295 | IN LIST_ENTRY *DriverOptionList,\r | |
296 | IN LIST_ENTRY *BootOptionList,\r | |
297 | IN PROCESS_CAPSULES ProcessCapsules,\r | |
298 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
299 | )\r | |
300 | {\r | |
301 | EFI_STATUS Status;\r | |
302 | \r | |
303 | Status = PlatformBdsConnectConsole ();\r | |
304 | ASSERT_EFI_ERROR (Status);\r | |
305 | }\r | |
306 | \r | |
307 | /**\r | |
308 | Hook point after a boot attempt succeeds. We don't expect a boot option to\r | |
309 | return, so the UEFI 2.0 specification defines that you will default to an\r | |
310 | interactive mode and stop processing the BootOrder list in this case. This\r | |
311 | is also a platform implementation and can be customized by IBV/OEM.\r | |
312 | \r | |
313 | @param Option Pointer to Boot Option that succeeded to boot.\r | |
314 | \r | |
315 | **/\r | |
316 | VOID\r | |
317 | EFIAPI\r | |
318 | PlatformBdsBootSuccess (\r | |
319 | IN BDS_COMMON_OPTION *Option\r | |
320 | )\r | |
321 | {\r | |
322 | }\r | |
323 | \r | |
324 | /**\r | |
325 | Hook point after a boot attempt fails.\r | |
326 | \r | |
327 | @param Option Pointer to Boot Option that failed to boot.\r | |
328 | @param Status Status returned from failed boot.\r | |
329 | @param ExitData Exit data returned from failed boot.\r | |
330 | @param ExitDataSize Exit data size returned from failed boot.\r | |
331 | \r | |
332 | **/\r | |
333 | VOID\r | |
334 | EFIAPI\r | |
335 | PlatformBdsBootFail (\r | |
336 | IN BDS_COMMON_OPTION *Option,\r | |
337 | IN EFI_STATUS Status,\r | |
338 | IN CHAR16 *ExitData,\r | |
339 | IN UINTN ExitDataSize\r | |
340 | )\r | |
341 | {\r | |
342 | }\r | |
343 | \r | |
344 | /**\r | |
345 | This function locks platform flash that is not allowed to be updated during normal boot path.\r | |
346 | The flash layout is platform specific.\r | |
347 | **/\r | |
348 | VOID\r | |
349 | EFIAPI\r | |
350 | PlatformBdsLockNonUpdatableFlash (\r | |
351 | VOID\r | |
352 | )\r | |
353 | {\r | |
354 | return;\r | |
355 | }\r | |
356 | \r | |
357 | \r | |
358 | /**\r | |
359 | Lock the ConsoleIn device in system table. All key\r | |
360 | presses will be ignored until the Password is typed in. The only way to\r | |
361 | disable the password is to type it in to a ConIn device.\r | |
362 | \r | |
363 | @param Password Password used to lock ConIn device.\r | |
364 | \r | |
365 | @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r | |
366 | @retval EFI_UNSUPPORTED Password not found\r | |
367 | \r | |
368 | **/\r | |
369 | EFI_STATUS\r | |
370 | EFIAPI\r | |
371 | LockKeyboards (\r | |
372 | IN CHAR16 *Password\r | |
373 | )\r | |
374 | {\r | |
375 | return EFI_UNSUPPORTED;\r | |
376 | }\r |