3 Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "IntelBdsPlatform.h"
19 /// Predefined platform default time out value
21 UINT16 gPlatformBootTimeOutDefault
;
25 PlatformIntelBdsConstructor (
26 IN EFI_HANDLE ImageHandle
,
27 IN EFI_SYSTEM_TABLE
*SystemTable
30 gPlatformBootTimeOutDefault
= (UINT16
)PcdGet16 (PcdPlatformBootTimeOut
);
35 An empty function to pass error checking of CreateEventEx ().
37 @param Event Event whose notification function is being invoked.
38 @param Context Pointer to the notification function's context,
39 which is implementation-dependent.
45 EmptyCallbackFunction (
53 // BDS Platform Functions
56 Platform Bds init. Include the platform firmware vendor, revision
66 EFI_EVENT EndOfDxeEvent
;
70 // Signal EndOfDxe PI Event
72 Status
= gBS
->CreateEventEx (
75 EmptyCallbackFunction
,
77 &gEfiEndOfDxeEventGroupGuid
,
80 if (!EFI_ERROR (Status
)) {
81 gBS
->SignalEvent (EndOfDxeEvent
);
82 gBS
->CloseEvent (EndOfDxeEvent
);
88 GetConsoleDevicePathFromVariable (
89 IN CHAR16
* ConsoleVarName
,
90 IN CHAR16
* DefaultConsolePaths
,
91 OUT EFI_DEVICE_PATH
** DevicePaths
96 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstances
;
97 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstance
;
98 CHAR16
* DevicePathStr
;
99 CHAR16
* NextDevicePathStr
;
100 EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*EfiDevicePathFromTextProtocol
;
102 Status
= EFI_SUCCESS
;
105 DevicePathInstances
= BdsLibGetVariableAndSize (ConsoleVarName
, &gEfiGlobalVariableGuid
, &Size
);
106 if (DevicePathInstances
== NULL
) {
107 // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)
108 if ((DefaultConsolePaths
== NULL
) || (DefaultConsolePaths
[0] == L
'\0')) {
113 Status
= gBS
->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid
, NULL
, (VOID
**)&EfiDevicePathFromTextProtocol
);
114 ASSERT_EFI_ERROR(Status
);
116 // Extract the Device Path instances from the multi-device path string
117 while ((DefaultConsolePaths
!= NULL
) && (DefaultConsolePaths
[0] != L
'\0')) {
118 NextDevicePathStr
= StrStr (DefaultConsolePaths
, L
";");
119 if (NextDevicePathStr
== NULL
) {
120 DevicePathStr
= DefaultConsolePaths
;
121 DefaultConsolePaths
= NULL
;
123 DevicePathStr
= (CHAR16
*)AllocateCopyPool ((NextDevicePathStr
- DefaultConsolePaths
+ 1) * sizeof(CHAR16
), DefaultConsolePaths
);
124 *(DevicePathStr
+ (NextDevicePathStr
- DefaultConsolePaths
)) = L
'\0';
125 DefaultConsolePaths
= NextDevicePathStr
;
126 if (DefaultConsolePaths
[0] == L
';') {
127 DefaultConsolePaths
++;
131 DevicePathInstance
= EfiDevicePathFromTextProtocol
->ConvertTextToDevicePath (DevicePathStr
);
132 ASSERT(DevicePathInstance
!= NULL
);
133 DevicePathInstances
= AppendDevicePathInstance (DevicePathInstances
, DevicePathInstance
);
135 if (NextDevicePathStr
!= NULL
) {
136 FreePool (DevicePathStr
);
138 FreePool (DevicePathInstance
);
141 // Set the environment variable with this device path multi-instances
142 Size
= GetDevicePathSize (DevicePathInstances
);
146 &gEfiGlobalVariableGuid
,
147 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
152 Status
= EFI_INVALID_PARAMETER
;
156 if (!EFI_ERROR(Status
)) {
157 *DevicePaths
= DevicePathInstances
;
164 InitializeConsolePipe (
165 IN EFI_DEVICE_PATH
*ConsoleDevicePaths
,
166 IN EFI_GUID
*Protocol
,
167 OUT EFI_HANDLE
*Handle
,
175 EFI_DEVICE_PATH_PROTOCOL
* DevicePath
;
177 // Connect all the Device Path Consoles
178 while (ConsoleDevicePaths
!= NULL
) {
179 DevicePath
= GetNextDevicePathInstance (&ConsoleDevicePaths
, &Size
);
181 Status
= BdsLibConnectDevicePath (DevicePath
);
182 if (!EFI_ERROR (Status
)) {
184 // If BdsLibConnectDevicePath () succeeded, *Handle must have a non-NULL
185 // value. So ASSERT that this is the case.
187 gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &DevicePath
, Handle
);
188 ASSERT (*Handle
!= NULL
);
191 if (EFI_ERROR(Status
)) {
192 // We convert back to the text representation of the device Path
193 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevicePathToTextProtocol
;
194 CHAR16
*DevicePathTxt
;
196 DevicePathToTextProtocol
= NULL
;
197 gBS
->LocateProtocol(&gEfiDevicePathToTextProtocolGuid
, NULL
, (VOID
**) &DevicePathToTextProtocol
);
198 if (DevicePathToTextProtocol
!= NULL
) {
199 DevicePathTxt
= DevicePathToTextProtocol
->ConvertDevicePathToText (DevicePath
, TRUE
, TRUE
);
201 DEBUG((EFI_D_ERROR
,"Fail to start the console with the Device Path '%s'. (Error '%r')\n", DevicePathTxt
, Status
));
203 FreePool (DevicePathTxt
);
208 // If the console splitter driver is not supported by the platform then use the first Device Path
209 // instance for the console interface.
210 if (!EFI_ERROR(Status
) && (*Interface
== NULL
)) {
211 Status
= gBS
->HandleProtocol (*Handle
, Protocol
, Interface
);
215 // No Device Path has been defined for this console interface. We take the first protocol implementation
216 if (*Interface
== NULL
) {
217 Status
= gBS
->LocateHandleBuffer (ByProtocol
, Protocol
, NULL
, &NoHandles
, &Buffer
);
218 if (EFI_ERROR (Status
)) {
220 Status
= gBS
->LocateHandleBuffer (ByProtocol
, Protocol
, NULL
, &NoHandles
, &Buffer
);
223 if (!EFI_ERROR(Status
)) {
225 Status
= gBS
->HandleProtocol (*Handle
, Protocol
, Interface
);
226 ASSERT_EFI_ERROR (Status
);
230 Status
= EFI_SUCCESS
;
237 Connect the predefined platform default console device. Always try to find
238 and enable the vga device if have.
240 @param PlatformConsole Predefined platform default console device array.
242 @retval EFI_SUCCESS Success connect at least one ConIn and ConOut
243 device, there must have one ConOut device is
245 @return Return the status of BdsLibConnectAllDefaultConsoles ()
249 PlatformBdsConnectConsole (
254 EFI_DEVICE_PATH
* ConOutDevicePaths
;
255 EFI_DEVICE_PATH
* ConInDevicePaths
;
256 EFI_DEVICE_PATH
* ConErrDevicePaths
;
258 // By getting the Console Device Paths from the environment variables before initializing the console pipe, we
259 // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface
260 // of newly installed console drivers
261 Status
= GetConsoleDevicePathFromVariable (L
"ConOut", (CHAR16
*)PcdGetPtr(PcdDefaultConOutPaths
), &ConOutDevicePaths
);
262 ASSERT_EFI_ERROR (Status
);
263 Status
= GetConsoleDevicePathFromVariable (L
"ConIn", (CHAR16
*)PcdGetPtr(PcdDefaultConInPaths
), &ConInDevicePaths
);
264 ASSERT_EFI_ERROR (Status
);
265 Status
= GetConsoleDevicePathFromVariable (L
"ErrOut", (CHAR16
*)PcdGetPtr(PcdDefaultConOutPaths
), &ConErrDevicePaths
);
266 ASSERT_EFI_ERROR (Status
);
268 // Initialize the Consoles
269 Status
= InitializeConsolePipe (ConOutDevicePaths
, &gEfiSimpleTextOutProtocolGuid
, &gST
->ConsoleOutHandle
, (VOID
**)&gST
->ConOut
);
270 ASSERT_EFI_ERROR (Status
);
271 Status
= InitializeConsolePipe (ConInDevicePaths
, &gEfiSimpleTextInProtocolGuid
, &gST
->ConsoleInHandle
, (VOID
**)&gST
->ConIn
);
272 ASSERT_EFI_ERROR (Status
);
273 Status
= InitializeConsolePipe (ConErrDevicePaths
, &gEfiSimpleTextOutProtocolGuid
, &gST
->StandardErrorHandle
, (VOID
**)&gST
->StdErr
);
274 if (EFI_ERROR(Status
)) {
275 // In case of error, we reuse the console output for the error output
276 gST
->StandardErrorHandle
= gST
->ConsoleOutHandle
;
277 gST
->StdErr
= gST
->ConOut
;
284 Connect with predefined platform connect sequence,
285 the OEM/IBV can customize with their own connect sequence.
288 PlatformBdsConnectSequence (
295 Load the predefined driver option, OEM/IBV can customize this
296 to load their own drivers
298 @param BdsDriverLists - The header of the driver option link list.
302 PlatformBdsGetDriverOption (
303 IN OUT LIST_ENTRY
*BdsDriverLists
309 Perform the platform diagnostic, such like test memory. OEM/IBV also
310 can customize this function to support specific platform diagnostic.
312 @param MemoryTestLevel The memory test intensive level
313 @param QuietBoot Indicate if need to enable the quiet boot
314 @param BaseMemoryTest A pointer to BdsMemoryTest()
318 PlatformBdsDiagnostics (
319 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
320 IN BOOLEAN QuietBoot
,
321 IN BASEM_MEMORY_TEST BaseMemoryTest
327 The function will execute with as the platform policy, current policy
328 is driven by boot mode. IBV/OEM can customize this code for their specific
331 @param DriverOptionList The header of the driver option link list
332 @param BootOptionList The header of the boot option link list
333 @param ProcessCapsules A pointer to ProcessCapsules()
334 @param BaseMemoryTest A pointer to BaseMemoryTest()
339 PlatformBdsPolicyBehavior (
340 IN LIST_ENTRY
*DriverOptionList
,
341 IN LIST_ENTRY
*BootOptionList
,
342 IN PROCESS_CAPSULES ProcessCapsules
,
343 IN BASEM_MEMORY_TEST BaseMemoryTest
348 Status
= PlatformBdsConnectConsole ();
349 ASSERT_EFI_ERROR (Status
);
352 // Show the splash screen.
354 EnableQuietBoot (PcdGetPtr (PcdLogoFile
));
358 Hook point after a boot attempt succeeds. We don't expect a boot option to
359 return, so the UEFI 2.0 specification defines that you will default to an
360 interactive mode and stop processing the BootOrder list in this case. This
361 is also a platform implementation and can be customized by IBV/OEM.
363 @param Option Pointer to Boot Option that succeeded to boot.
368 PlatformBdsBootSuccess (
369 IN BDS_COMMON_OPTION
*Option
375 Hook point after a boot attempt fails.
377 @param Option Pointer to Boot Option that failed to boot.
378 @param Status Status returned from failed boot.
379 @param ExitData Exit data returned from failed boot.
380 @param ExitDataSize Exit data size returned from failed boot.
385 PlatformBdsBootFail (
386 IN BDS_COMMON_OPTION
*Option
,
387 IN EFI_STATUS Status
,
389 IN UINTN ExitDataSize
395 This function locks platform flash that is not allowed to be updated during normal boot path.
396 The flash layout is platform specific.
400 PlatformBdsLockNonUpdatableFlash (
409 Lock the ConsoleIn device in system table. All key
410 presses will be ignored until the Password is typed in. The only way to
411 disable the password is to type it in to a ConIn device.
413 @param Password Password used to lock ConIn device.
415 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
416 @retval EFI_UNSUPPORTED Password not found
425 return EFI_UNSUPPORTED
;