]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
667810fbb5e8e2e173c235609e174ceea933471d
[mirror_edk2.git] / ArmPlatformPkg / ArmVirtualizationPkg / Library / PlatformIntelBdsLib / IntelBdsPlatform.c
1 /** @file
2
3 Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
5
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
10
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.
13
14 **/
15
16 #include "IntelBdsPlatform.h"
17
18 #include <Library/QemuBootOrderLib.h>
19
20 //
21 // BDS Platform Functions
22 //
23 /**
24 Platform Bds init. Include the platform firmware vendor, revision
25 and so crc check.
26
27 **/
28 VOID
29 EFIAPI
30 PlatformBdsInit (
31 VOID
32 )
33 {
34 }
35
36 STATIC
37 EFI_STATUS
38 GetConsoleDevicePathFromVariable (
39 IN CHAR16* ConsoleVarName,
40 IN CHAR16* DefaultConsolePaths,
41 OUT EFI_DEVICE_PATH** DevicePaths
42 )
43 {
44 EFI_STATUS Status;
45 UINTN Size;
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;
51
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')) {
56 *DevicePaths = NULL;
57 return EFI_SUCCESS;
58 }
59
60 Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
61 ASSERT_EFI_ERROR (Status);
62
63 DevicePathInstances = NULL;
64
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;
71 } else {
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++;
77 }
78 }
79
80 DevicePathInstance = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (DevicePathStr);
81 ASSERT (DevicePathInstance != NULL);
82 DevicePathInstances = AppendDevicePathInstance (DevicePathInstances, DevicePathInstance);
83
84 if (NextDevicePathStr != NULL) {
85 FreePool (DevicePathStr);
86 }
87 FreePool (DevicePathInstance);
88 }
89
90 // Set the environment variable with this device path multi-instances
91 Size = GetDevicePathSize (DevicePathInstances);
92 if (Size > 0) {
93 gRT->SetVariable (
94 ConsoleVarName,
95 &gEfiGlobalVariableGuid,
96 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
97 Size,
98 DevicePathInstances
99 );
100 } else {
101 Status = EFI_INVALID_PARAMETER;
102 }
103 }
104
105 if (!EFI_ERROR (Status)) {
106 *DevicePaths = DevicePathInstances;
107 }
108 return Status;
109 }
110
111 STATIC
112 VOID
113 SetConsoleVariables (
114 VOID
115 )
116 {
117 EFI_STATUS Status;
118 EFI_DEVICE_PATH* ConOutDevicePaths;
119 EFI_DEVICE_PATH* ConInDevicePaths;
120 EFI_DEVICE_PATH* ConErrDevicePaths;
121
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);
131 }
132
133 /**
134 Connect with predefined platform connect sequence,
135 the OEM/IBV can customize with their own connect sequence.
136 **/
137 VOID
138 PlatformBdsConnectSequence (
139 VOID
140 )
141 {
142 }
143
144 /**
145 Load the predefined driver option, OEM/IBV can customize this
146 to load their own drivers
147
148 @param BdsDriverLists - The header of the driver option link list.
149
150 **/
151 VOID
152 PlatformBdsGetDriverOption (
153 IN OUT LIST_ENTRY *BdsDriverLists
154 )
155 {
156 }
157
158 /**
159 Perform the platform diagnostic, such like test memory. OEM/IBV also
160 can customize this function to support specific platform diagnostic.
161
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()
165
166 **/
167 VOID
168 PlatformBdsDiagnostics (
169 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
170 IN BOOLEAN QuietBoot,
171 IN BASEM_MEMORY_TEST BaseMemoryTest
172 )
173 {
174 }
175
176 /**
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
179 policy action.
180
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()
185
186 **/
187 VOID
188 EFIAPI
189 PlatformBdsPolicyBehavior (
190 IN LIST_ENTRY *DriverOptionList,
191 IN LIST_ENTRY *BootOptionList,
192 IN PROCESS_CAPSULES ProcessCapsules,
193 IN BASEM_MEMORY_TEST BaseMemoryTest
194 )
195 {
196 SetConsoleVariables ();
197 BdsLibConnectAll ();
198
199 //
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.
204 //
205 TryRunningQemuKernel ();
206
207 BdsLibEnumerateAllBootOption (BootOptionList);
208 SetBootOrderFromQemu (BootOptionList);
209 //
210 // The BootOrder variable may have changed, reload the in-memory list with
211 // it.
212 //
213 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
214
215 PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE);
216 }
217
218 /**
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.
223
224 @param Option Pointer to Boot Option that succeeded to boot.
225
226 **/
227 VOID
228 EFIAPI
229 PlatformBdsBootSuccess (
230 IN BDS_COMMON_OPTION *Option
231 )
232 {
233 }
234
235 /**
236 Hook point after a boot attempt fails.
237
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.
242
243 **/
244 VOID
245 EFIAPI
246 PlatformBdsBootFail (
247 IN BDS_COMMON_OPTION *Option,
248 IN EFI_STATUS Status,
249 IN CHAR16 *ExitData,
250 IN UINTN ExitDataSize
251 )
252 {
253 }
254
255 /**
256 This function locks platform flash that is not allowed to be updated during normal boot path.
257 The flash layout is platform specific.
258 **/
259 VOID
260 EFIAPI
261 PlatformBdsLockNonUpdatableFlash (
262 VOID
263 )
264 {
265 return;
266 }
267
268
269 /**
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.
273
274 @param Password Password used to lock ConIn device.
275
276 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
277 @retval EFI_UNSUPPORTED Password not found
278
279 **/
280 EFI_STATUS
281 EFIAPI
282 LockKeyboards (
283 IN CHAR16 *Password
284 )
285 {
286 return EFI_UNSUPPORTED;
287 }