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"
18 #include <Library/QemuBootOrderLib.h>
21 // BDS Platform Functions
24 Platform Bds init. Include the platform firmware vendor, revision
38 GetConsoleDevicePathFromVariable (
39 IN CHAR16
* ConsoleVarName
,
40 IN CHAR16
* DefaultConsolePaths
,
41 OUT EFI_DEVICE_PATH
** DevicePaths
46 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstances
;
47 EFI_DEVICE_PATH_PROTOCOL
* DevicePathInstance
;
48 CHAR16
* DevicePathStr
;
49 CHAR16
* NextDevicePathStr
;
50 EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*EfiDevicePathFromTextProtocol
;
52 Status
= GetGlobalEnvironmentVariable (ConsoleVarName
, NULL
, NULL
, (VOID
**)&DevicePathInstances
);
53 if (EFI_ERROR (Status
)) {
54 // In case no default console device path has been defined we assume a driver handles the console (eg: SimpleTextInOutSerial)
55 if ((DefaultConsolePaths
== NULL
) || (DefaultConsolePaths
[0] == L
'\0')) {
60 Status
= gBS
->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid
, NULL
, (VOID
**)&EfiDevicePathFromTextProtocol
);
61 ASSERT_EFI_ERROR (Status
);
63 DevicePathInstances
= NULL
;
65 // Extract the Device Path instances from the multi-device path string
66 while ((DefaultConsolePaths
!= NULL
) && (DefaultConsolePaths
[0] != L
'\0')) {
67 NextDevicePathStr
= StrStr (DefaultConsolePaths
, L
";");
68 if (NextDevicePathStr
== NULL
) {
69 DevicePathStr
= DefaultConsolePaths
;
70 DefaultConsolePaths
= NULL
;
72 DevicePathStr
= (CHAR16
*)AllocateCopyPool ((NextDevicePathStr
- DefaultConsolePaths
+ 1) * sizeof (CHAR16
), DefaultConsolePaths
);
73 *(DevicePathStr
+ (NextDevicePathStr
- DefaultConsolePaths
)) = L
'\0';
74 DefaultConsolePaths
= NextDevicePathStr
;
75 if (DefaultConsolePaths
[0] == L
';') {
76 DefaultConsolePaths
++;
80 DevicePathInstance
= EfiDevicePathFromTextProtocol
->ConvertTextToDevicePath (DevicePathStr
);
81 ASSERT (DevicePathInstance
!= NULL
);
82 DevicePathInstances
= AppendDevicePathInstance (DevicePathInstances
, DevicePathInstance
);
84 if (NextDevicePathStr
!= NULL
) {
85 FreePool (DevicePathStr
);
87 FreePool (DevicePathInstance
);
90 // Set the environment variable with this device path multi-instances
91 Size
= GetDevicePathSize (DevicePathInstances
);
95 &gEfiGlobalVariableGuid
,
96 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
101 Status
= EFI_INVALID_PARAMETER
;
105 if (!EFI_ERROR (Status
)) {
106 *DevicePaths
= DevicePathInstances
;
113 SetConsoleVariables (
118 EFI_DEVICE_PATH
* ConOutDevicePaths
;
119 EFI_DEVICE_PATH
* ConInDevicePaths
;
120 EFI_DEVICE_PATH
* ConErrDevicePaths
;
122 // By getting the Console Device Paths from the environment variables before initializing the console pipe, we
123 // create the 3 environment variables (ConIn, ConOut, ConErr) that allows to initialize all the console interface
124 // of newly installed console drivers
125 Status
= GetConsoleDevicePathFromVariable (L
"ConOut", (CHAR16
*)PcdGetPtr (PcdDefaultConOutPaths
), &ConOutDevicePaths
);
126 ASSERT_EFI_ERROR (Status
);
127 Status
= GetConsoleDevicePathFromVariable (L
"ConIn", (CHAR16
*)PcdGetPtr (PcdDefaultConInPaths
), &ConInDevicePaths
);
128 ASSERT_EFI_ERROR (Status
);
129 Status
= GetConsoleDevicePathFromVariable (L
"ErrOut", (CHAR16
*)PcdGetPtr (PcdDefaultConOutPaths
), &ConErrDevicePaths
);
130 ASSERT_EFI_ERROR (Status
);
134 Connect with predefined platform connect sequence,
135 the OEM/IBV can customize with their own connect sequence.
138 PlatformBdsConnectSequence (
145 Load the predefined driver option, OEM/IBV can customize this
146 to load their own drivers
148 @param BdsDriverLists - The header of the driver option link list.
152 PlatformBdsGetDriverOption (
153 IN OUT LIST_ENTRY
*BdsDriverLists
159 Perform the platform diagnostic, such like test memory. OEM/IBV also
160 can customize this function to support specific platform diagnostic.
162 @param MemoryTestLevel The memory test intensive level
163 @param QuietBoot Indicate if need to enable the quiet boot
164 @param BaseMemoryTest A pointer to BdsMemoryTest()
168 PlatformBdsDiagnostics (
169 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
170 IN BOOLEAN QuietBoot
,
171 IN BASEM_MEMORY_TEST BaseMemoryTest
177 The function will execute with as the platform policy, current policy
178 is driven by boot mode. IBV/OEM can customize this code for their specific
181 @param DriverOptionList The header of the driver option link list
182 @param BootOptionList The header of the boot option link list
183 @param ProcessCapsules A pointer to ProcessCapsules()
184 @param BaseMemoryTest A pointer to BaseMemoryTest()
189 PlatformBdsPolicyBehavior (
190 IN LIST_ENTRY
*DriverOptionList
,
191 IN LIST_ENTRY
*BootOptionList
,
192 IN PROCESS_CAPSULES ProcessCapsules
,
193 IN BASEM_MEMORY_TEST BaseMemoryTest
196 SetConsoleVariables ();
200 // Process QEMU's -kernel command line option. Note that the kernel booted
201 // this way should receive ACPI tables, which is why we connect all devices
202 // first (see above) -- PCI enumeration blocks ACPI table installation, if
203 // there is a PCI host.
205 TryRunningQemuKernel ();
207 BdsLibEnumerateAllBootOption (BootOptionList
);
208 SetBootOrderFromQemu (BootOptionList
);
210 // The BootOrder variable may have changed, reload the in-memory list with
213 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
215 PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE
);
219 Hook point after a boot attempt succeeds. We don't expect a boot option to
220 return, so the UEFI 2.0 specification defines that you will default to an
221 interactive mode and stop processing the BootOrder list in this case. This
222 is also a platform implementation and can be customized by IBV/OEM.
224 @param Option Pointer to Boot Option that succeeded to boot.
229 PlatformBdsBootSuccess (
230 IN BDS_COMMON_OPTION
*Option
236 Hook point after a boot attempt fails.
238 @param Option Pointer to Boot Option that failed to boot.
239 @param Status Status returned from failed boot.
240 @param ExitData Exit data returned from failed boot.
241 @param ExitDataSize Exit data size returned from failed boot.
246 PlatformBdsBootFail (
247 IN BDS_COMMON_OPTION
*Option
,
248 IN EFI_STATUS Status
,
250 IN UINTN ExitDataSize
256 This function locks platform flash that is not allowed to be updated during normal boot path.
257 The flash layout is platform specific.
261 PlatformBdsLockNonUpdatableFlash (
270 Lock the ConsoleIn device in system table. All key
271 presses will be ignored until the Password is typed in. The only way to
272 disable the password is to type it in to a ConIn device.
274 @param Password Password used to lock ConIn device.
276 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
277 @retval EFI_UNSUPPORTED Password not found
286 return EFI_UNSUPPORTED
;