3 Copyright (c) 2004 - 2017, 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 // BDS Platform Functions
38 Platform Bds init. Include the platform firmware vendor, revision
49 // Signal EndOfDxe PI Event
51 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid
);
56 GetConsoleDevicePathFromVariable (
57 IN CHAR16
* ConsoleVarName
,
58 IN CHAR16
* DefaultConsolePaths
,
59 OUT EFI_DEVICE_PATH
** DevicePaths
64 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstances
;
65 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstance
;
66 CHAR16
* DevicePathStr
;
67 CHAR16
* NextDevicePathStr
;
68 EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*EfiDevicePathFromTextProtocol
;
73 DevicePathInstances
= BdsLibGetVariableAndSize (ConsoleVarName
, &gEfiGlobalVariableGuid
, &Size
);
74 if (DevicePathInstances
== NULL
) {
75 // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)
76 if ((DefaultConsolePaths
== NULL
) || (DefaultConsolePaths
[0] == L
'\0')) {
81 Status
= gBS
->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid
, NULL
, (VOID
**)&EfiDevicePathFromTextProtocol
);
82 ASSERT_EFI_ERROR(Status
);
84 // Extract the Device Path instances from the multi-device path string
85 while ((DefaultConsolePaths
!= NULL
) && (DefaultConsolePaths
[0] != L
'\0')) {
86 NextDevicePathStr
= StrStr (DefaultConsolePaths
, L
";");
87 if (NextDevicePathStr
== NULL
) {
88 DevicePathStr
= DefaultConsolePaths
;
89 DefaultConsolePaths
= NULL
;
91 DevicePathStr
= (CHAR16
*)AllocateCopyPool ((NextDevicePathStr
- DefaultConsolePaths
+ 1) * sizeof(CHAR16
), DefaultConsolePaths
);
92 *(DevicePathStr
+ (NextDevicePathStr
- DefaultConsolePaths
)) = L
'\0';
93 DefaultConsolePaths
= NextDevicePathStr
;
94 if (DefaultConsolePaths
[0] == L
';') {
95 DefaultConsolePaths
++;
99 DevicePathInstance
= EfiDevicePathFromTextProtocol
->ConvertTextToDevicePath (DevicePathStr
);
100 ASSERT(DevicePathInstance
!= NULL
);
101 DevicePathInstances
= AppendDevicePathInstance (DevicePathInstances
, DevicePathInstance
);
103 if (NextDevicePathStr
!= NULL
) {
104 FreePool (DevicePathStr
);
106 FreePool (DevicePathInstance
);
109 // Set the environment variable with this device path multi-instances
110 Size
= GetDevicePathSize (DevicePathInstances
);
114 &gEfiGlobalVariableGuid
,
115 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
120 Status
= EFI_INVALID_PARAMETER
;
124 if (!EFI_ERROR(Status
)) {
125 *DevicePaths
= DevicePathInstances
;
132 InitializeConsolePipe (
133 IN EFI_DEVICE_PATH
*ConsoleDevicePaths
,
134 IN EFI_GUID
*Protocol
,
135 OUT EFI_HANDLE
*Handle
,
143 EFI_DEVICE_PATH_PROTOCOL
* DevicePath
;
145 // Connect all the Device Path Consoles
146 while (ConsoleDevicePaths
!= NULL
) {
147 DevicePath
= GetNextDevicePathInstance (&ConsoleDevicePaths
, &Size
);
149 Status
= BdsLibConnectDevicePath (DevicePath
);
150 if (!EFI_ERROR (Status
)) {
152 // If BdsLibConnectDevicePath () succeeded, *Handle must have a non-NULL
153 // value. So ASSERT that this is the case.
155 gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &DevicePath
, Handle
);
156 ASSERT (*Handle
!= NULL
);
159 if (EFI_ERROR(Status
)) {
160 // We convert back to the text representation of the device Path
161 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevicePathToTextProtocol
;
162 CHAR16
*DevicePathTxt
;
164 DevicePathToTextProtocol
= NULL
;
165 gBS
->LocateProtocol(&gEfiDevicePathToTextProtocolGuid
, NULL
, (VOID
**) &DevicePathToTextProtocol
);
166 if (DevicePathToTextProtocol
!= NULL
) {
167 DevicePathTxt
= DevicePathToTextProtocol
->ConvertDevicePathToText (DevicePath
, TRUE
, TRUE
);
169 DEBUG((EFI_D_ERROR
,"Fail to start the console with the Device Path '%s'. (Error '%r')\n", DevicePathTxt
, Status
));
171 FreePool (DevicePathTxt
);
176 // If the console splitter driver is not supported by the platform then use the first Device Path
177 // instance for the console interface.
178 if (!EFI_ERROR(Status
) && (*Interface
== NULL
)) {
179 Status
= gBS
->HandleProtocol (*Handle
, Protocol
, Interface
);
183 // No Device Path has been defined for this console interface. We take the first protocol implementation
184 if (*Interface
== NULL
) {
185 Status
= gBS
->LocateHandleBuffer (ByProtocol
, Protocol
, NULL
, &NoHandles
, &Buffer
);
186 if (EFI_ERROR (Status
)) {
188 Status
= gBS
->LocateHandleBuffer (ByProtocol
, Protocol
, NULL
, &NoHandles
, &Buffer
);
191 if (!EFI_ERROR(Status
)) {
193 Status
= gBS
->HandleProtocol (*Handle
, Protocol
, Interface
);
194 ASSERT_EFI_ERROR (Status
);
198 Status
= EFI_SUCCESS
;
205 Connect the predefined platform default console device. Always try to find
206 and enable the vga device if have.
208 @param PlatformConsole Predefined platform default console device array.
210 @retval EFI_SUCCESS Success connect at least one ConIn and ConOut
211 device, there must have one ConOut device is
213 @return Return the status of BdsLibConnectAllDefaultConsoles ()
217 PlatformBdsConnectConsole (
222 EFI_DEVICE_PATH
* ConOutDevicePaths
;
223 EFI_DEVICE_PATH
* ConInDevicePaths
;
224 EFI_DEVICE_PATH
* ConErrDevicePaths
;
226 // By getting the Console Device Paths from the environment variables before initializing the console pipe, we
227 // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface
228 // of newly installed console drivers
229 Status
= GetConsoleDevicePathFromVariable (L
"ConOut", (CHAR16
*)PcdGetPtr(PcdDefaultConOutPaths
), &ConOutDevicePaths
);
230 ASSERT_EFI_ERROR (Status
);
231 Status
= GetConsoleDevicePathFromVariable (L
"ConIn", (CHAR16
*)PcdGetPtr(PcdDefaultConInPaths
), &ConInDevicePaths
);
232 ASSERT_EFI_ERROR (Status
);
233 Status
= GetConsoleDevicePathFromVariable (L
"ErrOut", (CHAR16
*)PcdGetPtr(PcdDefaultConOutPaths
), &ConErrDevicePaths
);
234 ASSERT_EFI_ERROR (Status
);
236 // Initialize the Consoles
237 Status
= InitializeConsolePipe (ConOutDevicePaths
, &gEfiSimpleTextOutProtocolGuid
, &gST
->ConsoleOutHandle
, (VOID
**)&gST
->ConOut
);
238 ASSERT_EFI_ERROR (Status
);
239 Status
= InitializeConsolePipe (ConInDevicePaths
, &gEfiSimpleTextInProtocolGuid
, &gST
->ConsoleInHandle
, (VOID
**)&gST
->ConIn
);
240 ASSERT_EFI_ERROR (Status
);
241 Status
= InitializeConsolePipe (ConErrDevicePaths
, &gEfiSimpleTextOutProtocolGuid
, &gST
->StandardErrorHandle
, (VOID
**)&gST
->StdErr
);
242 if (EFI_ERROR(Status
)) {
243 // In case of error, we reuse the console output for the error output
244 gST
->StandardErrorHandle
= gST
->ConsoleOutHandle
;
245 gST
->StdErr
= gST
->ConOut
;
252 Connect with predefined platform connect sequence,
253 the OEM/IBV can customize with their own connect sequence.
256 PlatformBdsConnectSequence (
263 Load the predefined driver option, OEM/IBV can customize this
264 to load their own drivers
266 @param BdsDriverLists - The header of the driver option link list.
270 PlatformBdsGetDriverOption (
271 IN OUT LIST_ENTRY
*BdsDriverLists
277 Perform the platform diagnostic, such like test memory. OEM/IBV also
278 can customize this function to support specific platform diagnostic.
280 @param MemoryTestLevel The memory test intensive level
281 @param QuietBoot Indicate if need to enable the quiet boot
282 @param BaseMemoryTest A pointer to BdsMemoryTest()
286 PlatformBdsDiagnostics (
287 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
288 IN BOOLEAN QuietBoot
,
289 IN BASEM_MEMORY_TEST BaseMemoryTest
295 The function will execute with as the platform policy, current policy
296 is driven by boot mode. IBV/OEM can customize this code for their specific
299 @param DriverOptionList The header of the driver option link list
300 @param BootOptionList The header of the boot option link list
301 @param ProcessCapsules A pointer to ProcessCapsules()
302 @param BaseMemoryTest A pointer to BaseMemoryTest()
307 PlatformBdsPolicyBehavior (
308 IN LIST_ENTRY
*DriverOptionList
,
309 IN LIST_ENTRY
*BootOptionList
,
310 IN PROCESS_CAPSULES ProcessCapsules
,
311 IN BASEM_MEMORY_TEST BaseMemoryTest
316 Status
= PlatformBdsConnectConsole ();
317 ASSERT_EFI_ERROR (Status
);
320 // Show the splash screen.
322 EnableQuietBoot (PcdGetPtr (PcdLogoFile
));
325 // Connect _all_ devices, to pick up plug-in and removable devices
326 // TODO: do this more cleanly, permitting faster boot times when boot config
333 Hook point after a boot attempt succeeds. We don't expect a boot option to
334 return, so the UEFI 2.0 specification defines that you will default to an
335 interactive mode and stop processing the BootOrder list in this case. This
336 is also a platform implementation and can be customized by IBV/OEM.
338 @param Option Pointer to Boot Option that succeeded to boot.
343 PlatformBdsBootSuccess (
344 IN BDS_COMMON_OPTION
*Option
350 Hook point after a boot attempt fails.
352 @param Option Pointer to Boot Option that failed to boot.
353 @param Status Status returned from failed boot.
354 @param ExitData Exit data returned from failed boot.
355 @param ExitDataSize Exit data size returned from failed boot.
360 PlatformBdsBootFail (
361 IN BDS_COMMON_OPTION
*Option
,
362 IN EFI_STATUS Status
,
364 IN UINTN ExitDataSize
370 This function locks platform flash that is not allowed to be updated during normal boot path.
371 The flash layout is platform specific.
375 PlatformBdsLockNonUpdatableFlash (
384 Lock the ConsoleIn device in system table. All key
385 presses will be ignored until the Password is typed in. The only way to
386 disable the password is to type it in to a ConIn device.
388 @param Password Password used to lock ConIn device.
390 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
391 @retval EFI_UNSUPPORTED Password not found
400 return EFI_UNSUPPORTED
;