Vlv2TbltDevicePkg/Bds: use Tcg2 instead of TrEE.
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / PlatformBdsLib / BdsPlatform.c
CommitLineData
3cbfba02
DW
1/** @file\r
2\r
b52e697b 3 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
04d8d883
JY
4 \r
5 This program and the accompanying materials are licensed and made available under\r
6 the terms and conditions of the BSD License that accompanies this distribution. \r
7 The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php. \r
9 \r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12 \r
3cbfba02
DW
13\r
14\r
15Module Name:\r
16\r
17 BdsPlatform.c\r
18\r
19Abstract:\r
20\r
21 This file include all platform action which can be customized\r
22 by IBV/OEM.\r
23\r
24--*/\r
25\r
26#include "BdsPlatform.h"\r
27#include "SetupMode.h"\r
28#include <Guid/SetupVariable.h>\r
29#include <Library/TcgPhysicalPresenceLib.h>\r
33aaf8d7 30#include <Library/Tcg2PhysicalPresenceLib.h>\r
3cbfba02
DW
31#include <Protocol/I2cMasterMcg.h>\r
32#include <TianoApi.h>\r
33#include <PlatformBaseAddresses.h>\r
34#include <Protocol/GlobalNvsArea.h>\r
35#include <Library/DxeServicesTableLib.h>\r
36#include <Protocol/BlockIo.h>\r
37#include <PchRegs/PchRegsPcu.h>\r
38#include <Library/S3BootScriptLib.h>\r
39#include "PchAccess.h"\r
40#include "PchRegs/PchRegsSata.h"\r
41#include <Library/SerialPortLib.h>\r
42#include <Library/DebugLib.h>\r
43\r
69a99d0b
MG
44#include <Library/GenericBdsLib/InternalBdsLib.h>\r
45#include <Library/GenericBdsLib/String.h>\r
46#include <Library/NetLib.h>\r
3cbfba02 47\r
04d8d883
JY
48#include <Library/CapsuleLib.h>\r
49#include <Protocol/EsrtManagement.h>\r
50\r
3cbfba02
DW
51EFI_GUID *ConnectDriverTable[] = {\r
52 &gEfiMmioDeviceProtocolGuid,\r
53 &gEfiI2cMasterProtocolGuid,\r
54 &gEfiI2cHostProtocolGuid\r
55};\r
56\r
57#define SHELL_ENVIRONMENT_INTERFACE_PROTOCOL \\r
58 { \\r
59 0x47c7b221, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
60 }\r
61VOID *mShellImageCallbackReg = NULL;\r
62\r
63\r
64\r
65EFI_USER_PROFILE_HANDLE mCurrentUser = NULL;\r
66EFI_EVENT mHotKeyTimerEvent = NULL;\r
67EFI_EVENT mHitHotkeyEvent = NULL;\r
68EFI_EVENT mUsbKeyboardConnectEvent = NULL;\r
69BOOLEAN mHotKeyPressed = FALSE;\r
70VOID *mHitHotkeyRegistration;\r
71#define KEYBOARD_TIMER_INTERVAL 20000 // 0.02s\r
72\r
73VOID\r
74ConnectUSBController (\r
75 VOID\r
76 );\r
77\r
78EFI_STATUS\r
79PlatformBdsConnectSimpleConsole (\r
80 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
81);\r
82\r
83VOID \r
84BootIntoFirmwareInterface(\r
85 VOID\r
86 );\r
87 \r
88VOID\r
89EFIAPI\r
90PlatformBdsInitHotKeyEvent (\r
91 VOID\r
92 );\r
93\r
94VOID\r
95EFIAPI\r
96DisableAhciCtlr (\r
97 IN EFI_EVENT Event,\r
98 IN VOID *Context\r
99 )\r
100{\r
101 UINT32 PmcDisableAddress;\r
102 UINT8 SataStorageAmount;\r
103 UINT32 SataBase;\r
104 UINT16 SataPortStatus;\r
105\r
106\r
107 DEBUG ((EFI_D_INFO, "Disable AHCI event is signalled\n"));\r
108 SataStorageAmount = 0;\r
109 SataBase = *(UINT32*) Context;\r
110\r
111 //\r
112 // BayTrail-M EDS chapter 16 ---- PCI IO Register Offset 92 (SATA Port Control and Status)\r
113 //\r
114 SataPortStatus = MmioRead16 (SataBase + R_PCH_SATA_PCS);\r
115\r
116 //\r
117 // Bit 8 EN: Port 0 Present\r
118 //\r
119 if ((SataPortStatus & 0x100) == 0x100) {\r
120 SataStorageAmount++;\r
121 }\r
122\r
123 //\r
124 // Bit 9 EN: Port 1 Present\r
125 //\r
126 if ((SataPortStatus & 0x200) == 0x200) {\r
127 SataStorageAmount++;\r
128 }\r
129\r
130 //\r
131 // Disable SATA controller when it sets to AHCI mode without carrying any devices\r
132 // in order to prevent AHCI yellow bang under Win device manager.\r
133 //\r
134 if (SataStorageAmount == 0) {\r
135 PmcDisableAddress = (MmioRead32 ((PCH_PCI_EXPRESS_BASE_ADDRESS + (UINT32) (31 << 15)) + R_PCH_LPC_PMC_BASE) & B_PCH_LPC_PMC_BASE_BAR) + R_PCH_PMC_FUNC_DIS;\r
136 MmioOr32 (PmcDisableAddress, B_PCH_PMC_FUNC_DIS_SATA);\r
137 S3BootScriptSaveMemWrite (\r
138 EfiBootScriptWidthUint32,\r
139 (UINTN) PmcDisableAddress,\r
140 1,\r
141 (VOID *) (UINTN) PmcDisableAddress\r
142 );\r
143 }\r
144}\r
145\r
146VOID\r
147InstallReadyToLock (\r
148 VOID\r
149 )\r
150{\r
151 EFI_STATUS Status;\r
152 EFI_HANDLE Handle;\r
153 EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;\r
154 EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;\r
155\r
156 //\r
157 // Install DxeSmmReadyToLock protocol prior to the processing of boot options\r
158 //\r
159 Status = gBS->LocateProtocol (\r
160 &gEfiSmmAccess2ProtocolGuid,\r
161 NULL,\r
162 (VOID **) &SmmAccess\r
163 );\r
164 if (!EFI_ERROR (Status)) {\r
165\r
166 //\r
167 // Prepare S3 information, this MUST be done before DxeSmmReadyToLock\r
168 //\r
169 Status = gBS->LocateProtocol (\r
170 &gEfiAcpiS3SaveProtocolGuid,\r
171 NULL,\r
172 (VOID **)&AcpiS3Save\r
173 );\r
174 if (!EFI_ERROR (Status)) {\r
175 AcpiS3Save->S3Save (AcpiS3Save, NULL);\r
176 }\r
177\r
178 Handle = NULL;\r
179 Status = gBS->InstallProtocolInterface (\r
180 &Handle,\r
181 &gExitPmAuthProtocolGuid,\r
182 EFI_NATIVE_INTERFACE,\r
183 NULL\r
184 );\r
185 ASSERT_EFI_ERROR (Status);\r
186\r
18b00c8c 187 //\r
188 // Signal EndOfDxe PI Event\r
189 //\r
190 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
191\r
3cbfba02
DW
192 Handle = NULL;\r
193 Status = gBS->InstallProtocolInterface (\r
194 &Handle,\r
195 &gEfiDxeSmmReadyToLockProtocolGuid,\r
196 EFI_NATIVE_INTERFACE,\r
197 NULL\r
198 );\r
199 ASSERT_EFI_ERROR (Status);\r
200 }\r
201\r
202 return ;\r
203}\r
204\r
205VOID\r
206EFIAPI\r
207ShellImageCallback (\r
208 IN EFI_EVENT Event,\r
209 IN VOID *Context\r
210 )\r
211{\r
212 BdsSetConsoleMode (TRUE);\r
213 DEBUG ((EFI_D_INFO, "BdsEntry ShellImageCallback \n"));\r
214}\r
215\r
216//\r
217// BDS Platform Functions\r
218//\r
219/**\r
2e182e30 220 Platform Bds init. Include the platform firmware vendor, revision\r
3cbfba02
DW
221 and so crc check.\r
222\r
223 @param VOID\r
224\r
225 @retval None.\r
226\r
227**/\r
228VOID\r
229EFIAPI\r
230PlatformBdsInit (\r
231 VOID\r
232 )\r
233{\r
234 EFI_STATUS Status;\r
235 EFI_EVENT ShellImageEvent;\r
236 EFI_GUID ShellEnvProtocol = SHELL_ENVIRONMENT_INTERFACE_PROTOCOL;\r
237\r
238 #ifdef __GNUC__\r
239 SerialPortWrite((UINT8 *)">>>>BdsEntry[GCC]\r\n", 19);\r
240 #else\r
241 SerialPortWrite((UINT8 *)">>>>BdsEntry\r\n", 14);\r
242 #endif\r
243 BdsLibSaveMemoryTypeInformation ();\r
244\r
245 //\r
246 // Before user authentication, the user identification devices need be connected\r
247 // from the platform customized device paths\r
248 //\r
249 PlatformBdsConnectAuthDevice ();\r
250\r
251 //\r
252 // As console is not ready, the auto logon user will be identified.\r
253 //\r
254 BdsLibUserIdentify (&mCurrentUser);\r
255\r
256 //\r
257 // Change Gop mode when boot into Shell\r
258 //\r
259 if (mShellImageCallbackReg == NULL) {\r
260 Status = gBS->CreateEvent (\r
261 EFI_EVENT_NOTIFY_SIGNAL,\r
262 EFI_TPL_CALLBACK,\r
263 ShellImageCallback,\r
264 NULL,\r
265 &ShellImageEvent\r
266 );\r
267 if (!EFI_ERROR (Status)) {\r
268 Status = gBS->RegisterProtocolNotify (\r
269 &ShellEnvProtocol,\r
270 ShellImageEvent,\r
271 &mShellImageCallbackReg\r
272 );\r
273\r
274 DEBUG ((EFI_D_INFO, "BdsEntry ShellImageCallback \n"));\r
275 }\r
276 }\r
277}\r
278\r
279EFI_STATUS\r
280GetGopDevicePath (\r
281 IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
282 OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
283 )\r
284{\r
285 UINTN Index;\r
286 EFI_STATUS Status;\r
287 EFI_HANDLE PciDeviceHandle;\r
288 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
289 EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r
290 UINTN GopHandleCount;\r
291 EFI_HANDLE *GopHandleBuffer;\r
292\r
293 UINTN VarSize;\r
294 SYSTEM_CONFIGURATION mSystemConfiguration;\r
295\r
296 if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
297 return EFI_INVALID_PARAMETER;\r
298 }\r
299\r
300 //\r
301 // Initialize the GopDevicePath to be PciDevicePath\r
302 //\r
303 *GopDevicePath = PciDevicePath;\r
304 TempPciDevicePath = PciDevicePath;\r
305\r
306 Status = gBS->LocateDevicePath (\r
307 &gEfiDevicePathProtocolGuid,\r
308 &TempPciDevicePath,\r
309 &PciDeviceHandle\r
310 );\r
311 if (EFI_ERROR (Status)) {\r
312 return Status;\r
313 }\r
314\r
315 //\r
2e182e30 316 // Try to connect this handle, so that GOP driver could start on this\r
3cbfba02
DW
317 // device and create child handles with GraphicsOutput Protocol installed\r
318 // on them, then we get device paths of these child handles and select\r
319 // them as possible console device.\r
320 //\r
321\r
322 //\r
323 // Select display devices\r
324 //\r
325 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
326 Status = gRT->GetVariable(\r
327 L"Setup",\r
328 &gEfiNormalSetupGuid,\r
329 NULL,\r
330 &VarSize,\r
331 &mSystemConfiguration\r
332 );\r
620f2891
TH
333 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
334 //The setup variable is corrupted\r
335 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
336 Status = gRT->GetVariable(\r
337 L"SetupRecovery",\r
338 &gEfiNormalSetupGuid,\r
339 NULL,\r
340 &VarSize,\r
341 &mSystemConfiguration\r
342 );\r
343 ASSERT_EFI_ERROR (Status);\r
344 } \r
3cbfba02
DW
345\r
346 if(mSystemConfiguration.BootDisplayDevice != 0x0)\r
347 {\r
348 ACPI_ADR_DEVICE_PATH AcpiAdr;\r
349 EFI_DEVICE_PATH_PROTOCOL *MyDevicePath = NULL;\r
350\r
351 AcpiAdr.Header.Type = ACPI_DEVICE_PATH;\r
352 AcpiAdr.Header.SubType = ACPI_ADR_DP;\r
353\r
354 switch (mSystemConfiguration.BootDisplayDevice) {\r
355 case 1:\r
356 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, PORT_CRT, 0); //CRT Device\r
357 break;\r
358 case 2:\r
359 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, PORT_B_HDMI, 0); //HDMI Device Port B\r
360 break;\r
361 case 3:\r
362 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, PORT_B_DP, 0); //DP PortB\r
363 break;\r
364 case 4:\r
365 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, PORT_C_DP, 0); //DP PortC\r
366 break;\r
367 case 5:\r
368 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL, PORT_C_DP, 0); //eDP Port C\r
369 break;\r
370 case 6:\r
371 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL, PORT_MIPI_A, 0); //DSI Port A\r
372 break;\r
373 case 7:\r
374 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL, PORT_MIPI_C, 0); //DSI Port C\r
375 break;\r
376 default:\r
377 AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, PORT_CRT, 0);\r
378 break;\r
379 }\r
380\r
381 SetDevicePathNodeLength (&AcpiAdr.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
382\r
383 MyDevicePath = AppendDevicePathNode(MyDevicePath, (EFI_DEVICE_PATH_PROTOCOL*)&AcpiAdr);\r
384\r
385 gBS->ConnectController (\r
386 PciDeviceHandle,\r
387 NULL,\r
388 MyDevicePath,\r
389 FALSE\r
390 );\r
391\r
392 FreePool(MyDevicePath);\r
393 }\r
394 else\r
395 {\r
396 gBS->ConnectController (\r
397 PciDeviceHandle,\r
398 NULL,\r
399 NULL,\r
400 FALSE\r
401 );\r
402 }\r
403\r
404 Status = gBS->LocateHandleBuffer (\r
405 ByProtocol,\r
406 &gEfiGraphicsOutputProtocolGuid,\r
407 NULL,\r
408 &GopHandleCount,\r
409 &GopHandleBuffer\r
410 );\r
411 if (!EFI_ERROR (Status)) {\r
412 //\r
413 // Add all the child handles as possible Console Device\r
414 //\r
415 for (Index = 0; Index < GopHandleCount; Index++) {\r
416 Status = gBS->HandleProtocol (\r
417 GopHandleBuffer[Index],\r
418 &gEfiDevicePathProtocolGuid,\r
419 (VOID**)&TempDevicePath\r
420 );\r
421 if (EFI_ERROR (Status)) {\r
422 continue;\r
423 }\r
424 if (CompareMem (\r
425 PciDevicePath,\r
426 TempDevicePath,\r
427 GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
428 ) == 0) {\r
429 //\r
430 // In current implementation, we only enable one of the child handles\r
431 // as console device, i.e. sotre one of the child handle's device\r
432 // path to variable "ConOut"\r
2e182e30 433 // In future, we could select all child handles to be console device\r
3cbfba02
DW
434 //\r
435 *GopDevicePath = TempDevicePath;\r
436 }\r
437 }\r
438 gBS->FreePool (GopHandleBuffer);\r
439 }\r
440\r
441 return EFI_SUCCESS;\r
442}\r
443\r
444/**\r
445\r
446 Search out all the platform pci or agp video device. The function may will\r
447 find multiple video device, and return all enabled device path.\r
448\r
449 @param PlugInPciVgaDevicePath Return the platform plug in pci video device\r
450 path if the system have plug in pci video device.\r
451 @param OnboardPciVgaDevicePath Return the platform active agp video device path\r
452 if the system have plug in agp video device or on\r
453 chip agp device.\r
454\r
455 @retval EFI_SUCCSS Get all platform active video device path.\r
456 @retval EFI_STATUS Return the status of gBS->LocateDevicePath (),\r
457 gBS->ConnectController (),\r
458 and gBS->LocateHandleBuffer ().\r
459\r
460**/\r
461EFI_STATUS\r
462GetPlugInPciVgaDevicePath (\r
463 IN OUT EFI_DEVICE_PATH_PROTOCOL **PlugInPciVgaDevicePath,\r
464 IN OUT EFI_DEVICE_PATH_PROTOCOL **OnboardPciVgaDevicePath\r
465 )\r
466{\r
467 EFI_STATUS Status;\r
468 EFI_HANDLE RootHandle;\r
469 UINTN HandleCount;\r
470 EFI_HANDLE *HandleBuffer;\r
471 UINTN Index;\r
472 UINTN Index1;\r
473 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
474 BOOLEAN PlugInPciVga;\r
475 EFI_PCI_IO_PROTOCOL *PciIo;\r
476 PCI_TYPE00 Pci;\r
477\r
478 DevicePath = NULL;\r
479 PlugInPciVga = TRUE;\r
480 HandleCount = 0;\r
481 HandleBuffer = NULL;\r
482\r
483 //\r
484 // Make all the PCI_IO protocols on PCI Seg 0 show up\r
485 //\r
486 BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r
487\r
488 Status = gBS->LocateDevicePath (\r
489 &gEfiDevicePathProtocolGuid,\r
490 &gPlatformRootBridges[0],\r
491 &RootHandle\r
492 );\r
493 if (EFI_ERROR (Status)) {\r
494 return Status;\r
495 }\r
496\r
497 Status = gBS->ConnectController (\r
498 RootHandle,\r
499 NULL,\r
500 NULL,\r
501 FALSE\r
502 );\r
503 if (EFI_ERROR (Status)) {\r
504 return Status;\r
505 }\r
506\r
507 //\r
508 // Start to check all the pci io to find all possible VGA device\r
509 //\r
510 HandleCount = 0;\r
511 HandleBuffer = NULL;\r
512 Status = gBS->LocateHandleBuffer (\r
513 ByProtocol,\r
514 &gEfiPciIoProtocolGuid,\r
515 NULL,\r
516 &HandleCount,\r
517 &HandleBuffer\r
518 );\r
519 if (EFI_ERROR (Status)) {\r
520 return Status;\r
521 }\r
522\r
523 for (Index = 0; Index < HandleCount; Index++) {\r
524 Status = gBS->HandleProtocol (\r
525 HandleBuffer[Index],\r
526 &gEfiPciIoProtocolGuid,\r
527 (VOID**)&PciIo\r
528 );\r
529 if (!EFI_ERROR (Status)) {\r
530\r
531 //\r
532 // Check for all VGA device\r
533 //\r
534 Status = PciIo->Pci.Read (\r
535 PciIo,\r
536 EfiPciIoWidthUint32,\r
537 0,\r
538 sizeof (Pci) / sizeof (UINT32),\r
539 &Pci\r
540 );\r
541 if (EFI_ERROR (Status)) {\r
542 continue;\r
543 }\r
544\r
545 //\r
546 // Here we decide which VGA device to enable in PCI bus\r
547 //\r
548 // The first plugin PCI VGA card device will be present as PCI VGA\r
549 // The onchip AGP or AGP card will be present as AGP VGA\r
550 //\r
551 if (!IS_PCI_VGA (&Pci)) {\r
552 continue;\r
553 }\r
554\r
555 //\r
556 // Set the device as the possible console out device,\r
557 //\r
558 // Below code will make every VGA device to be one\r
559 // of the possibe console out device\r
560 //\r
561 PlugInPciVga = TRUE;\r
562 gBS->HandleProtocol (\r
563 HandleBuffer[Index],\r
564 &gEfiDevicePathProtocolGuid,\r
565 (VOID**)&DevicePath\r
566 );\r
567\r
568 Index1 = 0;\r
569\r
570 while (gPlatformAllPossiblePciVgaConsole[Index1] != NULL) {\r
571 if (CompareMem (\r
572 DevicePath,\r
573 gPlatformAllPossiblePciVgaConsole[Index1],\r
574 GetDevicePathSize (gPlatformAllPossiblePciVgaConsole[Index1])\r
575 ) == 0) {\r
576\r
577 //\r
578 // This device is an AGP device\r
579 //\r
580 *OnboardPciVgaDevicePath = DevicePath;\r
581 PlugInPciVga = FALSE;\r
582 break;\r
583 }\r
584\r
585 Index1 ++;\r
586 }\r
587\r
588 if (PlugInPciVga) {\r
589 *PlugInPciVgaDevicePath = DevicePath;\r
590 }\r
591 }\r
592 }\r
593\r
594 FreePool (HandleBuffer);\r
595\r
596 return EFI_SUCCESS;\r
597}\r
598\r
599/**\r
600\r
601 Find the platform active vga, and base on the policy to enable the vga as\r
602 the console out device. The policy is driven by one setup variable "VBIOS".\r
603\r
604 None.\r
605\r
606 @param EFI_UNSUPPORTED There is no active vga device\r
607\r
608 @retval EFI_STATUS Return the status of BdsLibGetVariableAndSize ()\r
609\r
610**/\r
611EFI_STATUS\r
612PlatformBdsForceActiveVga (\r
613 VOID\r
614 )\r
615{\r
616 EFI_STATUS Status;\r
617 EFI_DEVICE_PATH_PROTOCOL *PlugInPciVgaDevicePath;\r
618 EFI_DEVICE_PATH_PROTOCOL *OnboardPciVgaDevicePath;\r
619 EFI_DEVICE_PATH_PROTOCOL *DevicePathFirst;\r
620 EFI_DEVICE_PATH_PROTOCOL *DevicePathSecond;\r
621 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
622 UINTN VarSize;\r
623 SYSTEM_CONFIGURATION mSystemConfiguration;\r
624\r
625 Status = EFI_SUCCESS;\r
626 PlugInPciVgaDevicePath = NULL;\r
627 OnboardPciVgaDevicePath = NULL;\r
628\r
629 //\r
630 // Check the policy which is the first enabled VGA\r
631 //\r
632 GetPlugInPciVgaDevicePath (&PlugInPciVgaDevicePath, &OnboardPciVgaDevicePath);\r
633\r
634 if (PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath == NULL) {\r
635 return EFI_UNSUPPORTED;\r
636 }\r
637\r
638 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
639 Status = gRT->GetVariable(\r
640 L"Setup",\r
641 &gEfiNormalSetupGuid,\r
642 NULL,\r
643 &VarSize,\r
644 &mSystemConfiguration\r
645 );\r
620f2891
TH
646 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
647 //The setup variable is corrupted\r
648 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
649 Status = gRT->GetVariable(\r
650 L"SetupRecovery",\r
651 &gEfiNormalSetupGuid,\r
652 NULL,\r
653 &VarSize,\r
654 &mSystemConfiguration\r
655 );\r
656 ASSERT_EFI_ERROR (Status);\r
657 } \r
3cbfba02
DW
658\r
659\r
660 if ((PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath != NULL) ) {\r
661 DEBUG ((EFI_D_ERROR,"Update onboard PCI VGA ...\n"));\r
662 DevicePathFirst = OnboardPciVgaDevicePath;\r
663 DevicePathSecond = PlugInPciVgaDevicePath;\r
664 goto UpdateConOut;\r
665 }\r
666 if(OnboardPciVgaDevicePath != NULL && mSystemConfiguration.PrimaryVideoAdaptor == 0) {\r
667 DEBUG ((EFI_D_ERROR,"Update onboard PCI VGA When set primary!!!...\n"));\r
668 DevicePathFirst = OnboardPciVgaDevicePath;\r
669 DevicePathSecond = PlugInPciVgaDevicePath;\r
670 goto UpdateConOut;\r
671 }\r
672\r
673 DEBUG ((EFI_D_ERROR,"Update plug in PCI VGA ...\n"));\r
674 DevicePathFirst = PlugInPciVgaDevicePath;\r
675 DevicePathSecond = OnboardPciVgaDevicePath;\r
676\r
677UpdateConOut:\r
678 GetGopDevicePath (DevicePathFirst, &GopDevicePath);\r
679 DevicePathFirst = GopDevicePath;\r
680\r
681 Status = BdsLibUpdateConsoleVariable (\r
682 L"ConOut",\r
683 DevicePathFirst,\r
684 DevicePathSecond\r
685 );\r
686\r
687 return Status;\r
688}\r
689\r
690VOID\r
691UpdateConsoleResolution(\r
692 VOID\r
693 )\r
694{\r
695 UINT32 HorizontalResolution;\r
696 UINT32 VerticalResolution;\r
697 SYSTEM_CONFIGURATION SystemConfiguration;\r
698 UINTN VarSize;\r
699 EFI_STATUS Status;\r
700\r
701\r
702 HorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
703 VerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);\r
704\r
705 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
706 Status = gRT->GetVariable(\r
707 L"Setup",\r
708 &gEfiNormalSetupGuid,\r
709 NULL,\r
710 &VarSize,\r
711 &SystemConfiguration\r
712 );\r
620f2891
TH
713 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
714 //The setup variable is corrupted\r
715 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
716 Status = gRT->GetVariable(\r
717 L"SetupRecovery",\r
718 &gEfiNormalSetupGuid,\r
719 NULL,\r
720 &VarSize,\r
721 &SystemConfiguration\r
722 );\r
723 ASSERT_EFI_ERROR (Status);\r
724 } \r
3cbfba02
DW
725\r
726 switch (SystemConfiguration.IgdFlatPanel) {\r
727\r
728 case 0:\r
729 //\r
730 // Use the detault PCD values.\r
731 //\r
732 break;\r
733\r
734 case 1:\r
735 HorizontalResolution = 640;\r
736 VerticalResolution = 480;\r
737 break;\r
738\r
739 case 2:\r
740 HorizontalResolution = 800;\r
741 VerticalResolution = 600;\r
742 break;\r
743\r
744 case 3:\r
745 HorizontalResolution = 1024;\r
746 VerticalResolution = 768;\r
747 break;\r
748\r
749 case 4:\r
750 HorizontalResolution = 1280;\r
751 VerticalResolution = 1024;\r
752 break;\r
753\r
754 case 5:\r
755 HorizontalResolution = 1366;\r
756 VerticalResolution = 768;\r
757 break;\r
758\r
759 case 6:\r
760 HorizontalResolution = 1680;\r
761 VerticalResolution = 1050;\r
762 break;\r
763\r
764 case 7:\r
765 HorizontalResolution = 1920;\r
766 VerticalResolution = 1200;\r
767 break;\r
768\r
769 case 8:\r
770 HorizontalResolution = 1280;\r
771 VerticalResolution = 800;\r
772 break;\r
773 }\r
774\r
775 PcdSet32 (PcdSetupVideoHorizontalResolution, HorizontalResolution);\r
776 PcdSet32 (PcdSetupVideoVerticalResolution, VerticalResolution);\r
777 DEBUG ((EFI_D_ERROR, "HorizontalResolution = %x; VerticalResolution = %x", HorizontalResolution, VerticalResolution));\r
778\r
779 return;\r
780}\r
781\r
782/**\r
783 Connect the predefined platform default console device. Always try to find\r
784 and enable the vga device if have.\r
785\r
2e182e30 786 @param PlatformConsole Predefined platform default console device array.\r
3cbfba02
DW
787\r
788 @retval EFI_SUCCESS Success connect at least one ConIn and ConOut\r
789 device, there must have one ConOut device is\r
790 active vga device.\r
791\r
792 @retval EFI_STATUS Return the status of\r
793 BdsLibConnectAllDefaultConsoles ()\r
794\r
795**/\r
796EFI_STATUS\r
797PlatformBdsConnectConsole (\r
798 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
799)\r
800{\r
801 EFI_STATUS Status;\r
802 UINTN Index;\r
803 EFI_DEVICE_PATH_PROTOCOL *VarConout;\r
804 EFI_DEVICE_PATH_PROTOCOL *VarConin;\r
805 UINTN DevicePathSize;\r
806\r
807 UpdateConsoleResolution();\r
808\r
809 Index = 0;\r
810 Status = EFI_SUCCESS;\r
811 DevicePathSize = 0;\r
812 VarConout = BdsLibGetVariableAndSize (\r
813 L"ConOut",\r
814 &gEfiGlobalVariableGuid,\r
815 &DevicePathSize\r
816 );\r
817 VarConin = BdsLibGetVariableAndSize (\r
818 L"ConIn",\r
819 &gEfiGlobalVariableGuid,\r
820 &DevicePathSize\r
821 );\r
822 if (VarConout == NULL || VarConin == NULL) {\r
823 //\r
824 // Have chance to connect the platform default console,\r
2e182e30 825 // the platform default console is the minimum device group\r
3cbfba02
DW
826 // the platform should support\r
827 //\r
828 while (PlatformConsole[Index].DevicePath != NULL) {\r
829\r
830 //\r
831 // Update the console variable with the connect type\r
832 //\r
833 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
834 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
835 }\r
836\r
837 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
838 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
839 }\r
840\r
841 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
842 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
843 }\r
844\r
845 Index ++;\r
846 }\r
847 }\r
848\r
849 //\r
850 // Make sure we have at least one active VGA, and have the right\r
851 // active VGA in console variable\r
852 //\r
853 Status = PlatformBdsForceActiveVga ();\r
854 if (EFI_ERROR (Status)) {\r
855 return Status;\r
856 }\r
857\r
858 DEBUG ((EFI_D_INFO, "DISPLAY INIT DONE\n"));\r
859\r
860 //\r
861 // Connect the all the default console with current console variable\r
862 //\r
863 Status = BdsLibConnectAllDefaultConsoles ();\r
864 if (EFI_ERROR (Status)) {\r
865 return Status;\r
866 }\r
867\r
868 return EFI_SUCCESS;\r
869}\r
870\r
871/**\r
2e182e30 872 Connect with predefined platform connect sequence,\r
3cbfba02
DW
873 the OEM/IBV can customize with their own connect sequence.\r
874\r
875 @param None.\r
876\r
877 @retval None.\r
878\r
879**/\r
880VOID\r
881PlatformBdsConnectSequence (\r
882 VOID\r
883 )\r
884{\r
885 UINTN Index;\r
886\r
887 Index = 0;\r
888\r
889 //\r
890 // Here we can get the customized platform connect sequence\r
891 // Notes: we can connect with new variable which record the\r
892 // last time boots connect device path sequence\r
893 //\r
894 while (gPlatformConnectSequence[Index] != NULL) {\r
895\r
896 //\r
897 // Build the platform boot option\r
898 //\r
899 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
900 Index ++;\r
901 }\r
902\r
903 //\r
904 // Just use the simple policy to connect all devices\r
905 // There should be no difference between debug tip and release tip, or it will be extremely hard to debug.\r
906 //\r
907 // There is case that IdeController driver will write boot script in driver model Start() function. It will be rejected by boot script save.\r
908 // It is only found when DEBUG disabled, because we are using BdsLibConnectAll() when DEBUG enabled.\r
909 //\r
910 // So we use BdsLibConnectAll() here to make sure IdeController.Start() is invoked before InstallReadyToLock().\r
911 // We may also consider to connect SataController only later if needed.\r
912 //\r
913 BdsLibConnectAll ();\r
914}\r
915\r
916/**\r
917\r
918 Load the predefined driver option, OEM/IBV can customize this\r
919 to load their own drivers\r
920\r
921 @param BdsDriverLists The header of the driver option link list.\r
922\r
923 @retval None.\r
924\r
925**/\r
926VOID\r
927PlatformBdsGetDriverOption (\r
928 IN OUT LIST_ENTRY *BdsDriverLists\r
929 )\r
930{\r
931 UINTN Index;\r
932\r
933 Index = 0;\r
934\r
935 //\r
936 // Here we can get the customized platform driver option\r
937 //\r
938 while (gPlatformDriverOption[Index] != NULL) {\r
939\r
940 //\r
941 // Build the platform boot option\r
942 //\r
943 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
944 Index ++;\r
945 }\r
946\r
947}\r
948\r
949/**\r
950 This function is used for some critical time if the the system\r
951 have no any boot option, and there is no time out for user to add\r
952 the new boot option. This can also treat as the platform default\r
953 boot option.\r
954\r
955 @param BdsBootOptionList The header of the boot option link list.\r
956\r
957 @retval None.\r
958\r
959**/\r
960VOID\r
961PlatformBdsPredictBootOption (\r
962 IN OUT LIST_ENTRY *BdsBootOptionList\r
963 )\r
964{\r
965 UINTN Index;\r
966\r
967 Index = 0;\r
968\r
969 //\r
970 // Here give chance to get platform boot option data\r
971 //\r
972 while (gPlatformBootOption[Index] != NULL) {\r
973\r
974 //\r
975 // Build the platform boot option\r
976 //\r
977 BdsLibRegisterNewOption (BdsBootOptionList, gPlatformBootOption[Index], NULL, L"BootOrder");\r
978 Index ++;\r
979 }\r
980}\r
981\r
982/**\r
983 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
984 can customize this fuction to support specific platform diagnostic.\r
985\r
986 @param MemoryTestLevel The memory test intensive level\r
987 @param QuietBoot Indicate if need to enable the quiet boot\r
988 @param BaseMemoryTest A pointer to BdsMemoryTest()\r
989\r
990 @retval None.\r
991\r
992**/\r
993VOID\r
994PlatformBdsDiagnostics (\r
995 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
996 IN BOOLEAN QuietBoot,\r
997 IN BASEM_MEMORY_TEST BaseMemoryTest\r
998 )\r
999{\r
1000 EFI_STATUS Status;\r
1001\r
1002 //\r
1003 // Here we can decide if we need to show\r
1004 // the diagnostics screen\r
1005 // Notes: this quiet boot code should be remove\r
1006 // from the graphic lib\r
1007 //\r
1008 if (QuietBoot) {\r
1009 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
1010\r
1011 //\r
1012 // Perform system diagnostic\r
1013 //\r
1014 Status = BaseMemoryTest (MemoryTestLevel);\r
1015 if (EFI_ERROR (Status)) {\r
1016 DisableQuietBoot ();\r
1017 }\r
1018\r
1019 return;\r
1020 }\r
1021\r
1022 //\r
1023 // Perform system diagnostic\r
1024 //\r
1025 Status = BaseMemoryTest (MemoryTestLevel);\r
1026}\r
1027\r
1028\r
69a99d0b
MG
1029/**\r
1030 For EFI boot option, BDS separate them as six types:\r
1031 1. Network - The boot option points to the SimpleNetworkProtocol device.\r
1032 Bds will try to automatically create this type boot option when enumerate.\r
1033 2. Shell - The boot option points to internal flash shell.\r
1034 Bds will try to automatically create this type boot option when enumerate.\r
1035 3. Removable BlockIo - The boot option only points to the removable media\r
1036 device, like USB flash disk, DVD, Floppy etc.\r
1037 These device should contain a *removable* blockIo\r
1038 protocol in their device handle.\r
1039 Bds will try to automatically create this type boot option\r
1040 when enumerate.\r
1041 4. Fixed BlockIo - The boot option only points to a Fixed blockIo device,\r
1042 like HardDisk.\r
1043 These device should contain a *fixed* blockIo\r
1044 protocol in their device handle.\r
1045 BDS will skip fixed blockIo devices, and NOT\r
1046 automatically create boot option for them. But BDS\r
1047 will help to delete those fixed blockIo boot option,\r
1048 whose description rule conflict with other auto-created\r
1049 boot options.\r
1050 5. Non-BlockIo Simplefile - The boot option points to a device whose handle\r
1051 has SimpleFileSystem Protocol, but has no blockio\r
1052 protocol. These devices do not offer blockIo\r
1053 protocol, but BDS still can get the\r
1054 \EFI\BOOT\boot{machinename}.EFI by SimpleFileSystem\r
1055 Protocol.\r
1056 6. File - The boot option points to a file. These boot options are usually\r
1057 created by user manually or OS loader. BDS will not delete or modify\r
1058 these boot options.\r
1059\r
1060 This function will enumerate all possible boot device in the system, and\r
1061 automatically create boot options for Network, Shell, Removable BlockIo,\r
1062 and Non-BlockIo Simplefile devices.\r
1063 It will only execute once of every boot.\r
1064\r
1065 @param BdsBootOptionList The header of the link list which indexed all\r
1066 current boot options\r
1067\r
1068 @retval EFI_SUCCESS Finished all the boot device enumerate and create\r
1069 the boot option base on that boot device\r
1070\r
1071 @retval EFI_OUT_OF_RESOURCES Failed to enumerate the boot device and create the boot option list\r
1072**/\r
1073EFI_STATUS\r
1074EFIAPI\r
1075PlatformBdsLibEnumerateAllBootOption (\r
1076 IN OUT LIST_ENTRY *BdsBootOptionList\r
1077 )\r
1078{\r
1079 EFI_STATUS Status;\r
1080 UINT16 FloppyNumber;\r
1081 UINT16 HarddriveNumber;\r
1082 UINT16 CdromNumber;\r
1083 UINT16 UsbNumber;\r
1084 UINT16 MiscNumber;\r
1085 UINT16 ScsiNumber;\r
1086 UINT16 NonBlockNumber;\r
1087 UINTN NumberBlockIoHandles;\r
1088 EFI_HANDLE *BlockIoHandles;\r
1089 EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
1090 BOOLEAN Removable[2];\r
1091 UINTN RemovableIndex;\r
1092 UINTN Index;\r
1093 UINTN NumOfLoadFileHandles;\r
1094 EFI_HANDLE *LoadFileHandles;\r
1095 UINTN FvHandleCount;\r
1096 EFI_HANDLE *FvHandleBuffer;\r
1097 EFI_FV_FILETYPE Type;\r
1098 UINTN Size;\r
1099 EFI_FV_FILE_ATTRIBUTES Attributes;\r
1100 UINT32 AuthenticationStatus;\r
1101 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
1102 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
1103 UINTN DevicePathType;\r
1104 CHAR16 Buffer[40];\r
1105 EFI_HANDLE *FileSystemHandles;\r
1106 UINTN NumberFileSystemHandles;\r
1107 BOOLEAN NeedDelete;\r
1108 EFI_IMAGE_DOS_HEADER DosHeader;\r
1109 CHAR8 *PlatLang;\r
1110 CHAR8 *LastLang;\r
1111 EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData;\r
1112 EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
1113 CHAR16 *MacStr;\r
1114 CHAR16 *IPverStr;\r
1115 EFI_HANDLE *NetworkHandles;\r
1116 UINTN BufferSize;\r
1117\r
1118 FloppyNumber = 0;\r
1119 HarddriveNumber = 0;\r
1120 CdromNumber = 0;\r
1121 UsbNumber = 0;\r
1122 MiscNumber = 0;\r
1123 ScsiNumber = 0;\r
1124 PlatLang = NULL;\r
1125 LastLang = NULL;\r
1126 ZeroMem (Buffer, sizeof (Buffer));\r
1127\r
1128 //\r
1129 // If the boot device enumerate happened, just get the boot\r
1130 // device from the boot order variable\r
1131 //\r
1132 if (mEnumBootDevice) {\r
1133 GetVariable2 (LAST_ENUM_LANGUAGE_VARIABLE_NAME, &gLastEnumLangGuid, (VOID**)&LastLang, NULL);\r
1134 GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatLang, NULL);\r
1135 ASSERT (PlatLang != NULL);\r
1136 if ((LastLang != NULL) && (AsciiStrCmp (LastLang, PlatLang) == 0)) {\r
1137 Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
1138 FreePool (LastLang);\r
1139 FreePool (PlatLang);\r
1140 return Status;\r
1141 } else {\r
1142 Status = gRT->SetVariable (\r
1143 LAST_ENUM_LANGUAGE_VARIABLE_NAME,\r
1144 &gLastEnumLangGuid,\r
1145 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
1146 AsciiStrSize (PlatLang),\r
1147 PlatLang\r
1148 );\r
1149 //\r
1150 // Failure to set the variable only impacts the performance next time enumerating the boot options.\r
1151 //\r
1152\r
1153 if (LastLang != NULL) {\r
1154 FreePool (LastLang);\r
1155 }\r
1156 FreePool (PlatLang);\r
1157 }\r
1158 }\r
1159\r
1160 //\r
1161 // Notes: this dirty code is to get the legacy boot option from the\r
1162 // BBS table and create to variable as the EFI boot option, it should\r
1163 // be removed after the CSM can provide legacy boot option directly\r
1164 //\r
1165 REFRESH_LEGACY_BOOT_OPTIONS;\r
1166\r
1167 //\r
1168 // Delete invalid boot option\r
1169 //\r
1170 BdsDeleteAllInvalidEfiBootOption ();\r
1171\r
1172 //\r
1173 // Parse removable media followed by fixed media.\r
1174 // The Removable[] array is used by the for-loop below to create removable media boot options \r
1175 // at first, and then to create fixed media boot options.\r
1176 //\r
1177 Removable[0] = FALSE;\r
1178 Removable[1] = TRUE;\r
1179\r
1180 gBS->LocateHandleBuffer (\r
1181 ByProtocol,\r
1182 &gEfiBlockIoProtocolGuid,\r
1183 NULL,\r
1184 &NumberBlockIoHandles,\r
1185 &BlockIoHandles\r
1186 );\r
1187\r
1188 for (RemovableIndex = 0; RemovableIndex < 2; RemovableIndex++) {\r
1189 for (Index = 0; Index < NumberBlockIoHandles; Index++) {\r
1190 Status = gBS->HandleProtocol (\r
1191 BlockIoHandles[Index],\r
1192 &gEfiBlockIoProtocolGuid,\r
1193 (VOID **) &BlkIo\r
1194 );\r
1195 //\r
1196 // skip the logical partition\r
1197 //\r
1198 if (EFI_ERROR (Status) || BlkIo->Media->LogicalPartition) {\r
1199 continue;\r
1200 }\r
1201\r
1202 //\r
1203 // firstly fixed block io then the removable block io\r
1204 //\r
1205 if (BlkIo->Media->RemovableMedia == Removable[RemovableIndex]) {\r
1206 continue;\r
1207 }\r
1208 DevicePath = DevicePathFromHandle (BlockIoHandles[Index]);\r
1209 DevicePathType = BdsGetBootTypeFromDevicePath (DevicePath);\r
1210\r
1211 switch (DevicePathType) {\r
1212 case BDS_EFI_ACPI_FLOPPY_BOOT:\r
1213 if (FloppyNumber != 0) {\r
1214 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber);\r
1215 } else {\r
1216 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)));\r
1217 }\r
1218 BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
1219 FloppyNumber++;\r
1220 break;\r
1221\r
1222 //\r
1223 // Assume a removable SATA device should be the DVD/CD device, a fixed SATA device should be the Hard Drive device.\r
1224 //\r
1225 case BDS_EFI_MESSAGE_ATAPI_BOOT:\r
1226 case BDS_EFI_MESSAGE_SATA_BOOT:\r
1227 if (BlkIo->Media->RemovableMedia) {\r
1228 if (CdromNumber != 0) {\r
1229 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber);\r
1230 } else {\r
1231 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)));\r
1232 }\r
1233 CdromNumber++;\r
1234 } else {\r
1235 if (HarddriveNumber != 0) {\r
1236 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber);\r
1237 } else {\r
1238 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)));\r
1239 }\r
1240 HarddriveNumber++;\r
1241 }\r
1242 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Buffer: %S\n", Buffer));\r
1243 BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
1244 break;\r
1245\r
1246 case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:\r
1247 if (UsbNumber != 0) {\r
1248 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber);\r
1249 } else {\r
1250 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)));\r
1251 }\r
1252 BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
1253 UsbNumber++;\r
1254 break;\r
1255\r
1256 case BDS_EFI_MESSAGE_SCSI_BOOT:\r
1257 if (ScsiNumber != 0) {\r
1258 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber);\r
1259 } else {\r
1260 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)));\r
1261 }\r
1262 BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
1263 ScsiNumber++;\r
1264 break;\r
1265\r
1266 case BDS_EFI_MESSAGE_MISC_BOOT:\r
1267 default:\r
1268 if (MiscNumber != 0) {\r
1269 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)), MiscNumber);\r
1270 } else {\r
1271 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)));\r
1272 }\r
1273 BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
1274 MiscNumber++;\r
1275 break;\r
1276 }\r
1277 }\r
1278 }\r
1279\r
1280 if (NumberBlockIoHandles != 0) {\r
1281 FreePool (BlockIoHandles);\r
1282 }\r
1283\r
1284 //\r
1285 // If there is simple file protocol which does not consume block Io protocol, create a boot option for it here.\r
1286 //\r
1287 NonBlockNumber = 0;\r
1288 gBS->LocateHandleBuffer (\r
1289 ByProtocol,\r
1290 &gEfiSimpleFileSystemProtocolGuid,\r
1291 NULL,\r
1292 &NumberFileSystemHandles,\r
1293 &FileSystemHandles\r
1294 );\r
1295 for (Index = 0; Index < NumberFileSystemHandles; Index++) {\r
1296 Status = gBS->HandleProtocol (\r
1297 FileSystemHandles[Index],\r
1298 &gEfiBlockIoProtocolGuid,\r
1299 (VOID **) &BlkIo\r
1300 );\r
1301 if (!EFI_ERROR (Status)) {\r
1302 //\r
1303 // Skip if the file system handle supports a BlkIo protocol,\r
1304 //\r
1305 continue;\r
1306 }\r
1307\r
1308 //\r
1309 // Do the removable Media thing. \EFI\BOOT\boot{machinename}.EFI\r
1310 // machinename is ia32, ia64, x64, ...\r
1311 //\r
1312 Hdr.Union = &HdrData;\r
1313 NeedDelete = TRUE;\r
1314 Status = BdsLibGetImageHeader (\r
1315 FileSystemHandles[Index],\r
1316 EFI_REMOVABLE_MEDIA_FILE_NAME,\r
1317 &DosHeader,\r
1318 Hdr\r
1319 );\r
1320 if (!EFI_ERROR (Status) &&\r
1321 EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Hdr.Pe32->FileHeader.Machine) &&\r
1322 Hdr.Pe32->OptionalHeader.Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
1323 NeedDelete = FALSE;\r
1324 }\r
1325\r
1326 if (NeedDelete) {\r
1327 //\r
1328 // No such file or the file is not a EFI application, delete this boot option\r
1329 //\r
1330 BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);\r
1331 } else {\r
1332 if (NonBlockNumber != 0) {\r
1333 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber);\r
1334 } else {\r
1335 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)));\r
1336 }\r
1337 BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList, Buffer);\r
1338 NonBlockNumber++;\r
1339 }\r
1340 }\r
1341\r
1342 if (NumberFileSystemHandles != 0) {\r
1343 FreePool (FileSystemHandles);\r
1344 }\r
1345\r
1346 //\r
1347 // Check if we have on flash shell\r
1348 //\r
1349 gBS->LocateHandleBuffer (\r
1350 ByProtocol,\r
1351 &gEfiFirmwareVolume2ProtocolGuid,\r
1352 NULL,\r
1353 &FvHandleCount,\r
1354 &FvHandleBuffer\r
1355 );\r
1356 for (Index = 0; Index < FvHandleCount; Index++) {\r
1357 gBS->HandleProtocol (\r
1358 FvHandleBuffer[Index],\r
1359 &gEfiFirmwareVolume2ProtocolGuid,\r
1360 (VOID **) &Fv\r
1361 );\r
1362\r
1363 Status = Fv->ReadFile (\r
1364 Fv,\r
1365 PcdGetPtr(PcdShellFile),\r
1366 NULL,\r
1367 &Size,\r
1368 &Type,\r
1369 &Attributes,\r
1370 &AuthenticationStatus\r
1371 );\r
1372 if (EFI_ERROR (Status)) {\r
1373 //\r
1374 // Skip if no shell file in the FV\r
1375 //\r
1376 continue;\r
1377 }\r
1378 //\r
1379 // Build the shell boot option\r
1380 //\r
1381 BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
1382 }\r
1383\r
1384 if (FvHandleCount != 0) {\r
1385 FreePool (FvHandleBuffer);\r
1386 }\r
1387\r
1388 //\r
1389 // Parse Network Boot Device\r
1390 //\r
1391 NumOfLoadFileHandles = 0;\r
1392 //\r
1393 // Search Load File protocol for PXE boot option.\r
1394 //\r
1395 gBS->LocateHandleBuffer (\r
1396 ByProtocol,\r
1397 &gEfiLoadFileProtocolGuid,\r
1398 NULL,\r
1399 &NumOfLoadFileHandles,\r
1400 &LoadFileHandles\r
1401 );\r
1402\r
1403 for (Index = 0; Index < NumOfLoadFileHandles; Index++) {\r
1404\r
1405//\r
1406//Locate EFI_DEVICE_PATH_PROTOCOL to dynamically get IPv4/IPv6 protocol information.\r
1407//\r
1408\r
1409 Status = gBS->HandleProtocol (\r
1410 LoadFileHandles[Index],\r
1411 &gEfiDevicePathProtocolGuid,\r
1412 (VOID **) &DevicePath\r
1413 );\r
1414 \r
1415 ASSERT_EFI_ERROR (Status);\r
1416\r
1417 while (!IsDevicePathEnd (DevicePath)) {\r
1418 if ((DevicePath->Type == MESSAGING_DEVICE_PATH) &&\r
1419 (DevicePath->SubType == MSG_IPv4_DP)) {\r
1420\r
1421 //\r
1422 //Get handle infomation\r
1423 //\r
1424 BufferSize = 0;\r
1425 NetworkHandles = NULL;\r
1426 Status = gBS->LocateHandle (\r
1427 ByProtocol, \r
1428 &gEfiSimpleNetworkProtocolGuid,\r
1429 NULL,\r
1430 &BufferSize,\r
1431 NetworkHandles\r
1432 );\r
1433\r
1434 if (Status == EFI_BUFFER_TOO_SMALL) {\r
1435 NetworkHandles = AllocateZeroPool(BufferSize);\r
1436 if (NetworkHandles == NULL) {\r
1437 return (EFI_OUT_OF_RESOURCES);\r
1438 }\r
1439 Status = gBS->LocateHandle(\r
1440 ByProtocol,\r
1441 &gEfiSimpleNetworkProtocolGuid,\r
1442 NULL,\r
1443 &BufferSize,\r
1444 NetworkHandles\r
1445 );\r
1446 }\r
1447 \r
1448 //\r
1449 //Get the MAC string\r
1450 //\r
1451 Status = NetLibGetMacString (\r
1452 *NetworkHandles,\r
1453 NULL,\r
1454 &MacStr\r
1455 );\r
1456 if (EFI_ERROR (Status)) { \r
1457 return Status;\r
1458 }\r
1459 IPverStr = L" IPv4";\r
1460 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%s%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)),MacStr,IPverStr);\r
1461 break;\r
1462 }\r
1463 if((DevicePath->Type == MESSAGING_DEVICE_PATH) &&\r
1464 (DevicePath->SubType == MSG_IPv6_DP)) {\r
1465\r
1466 //\r
1467 //Get handle infomation\r
1468 //\r
1469 BufferSize = 0;\r
1470 NetworkHandles = NULL;\r
1471 Status = gBS->LocateHandle (\r
1472 ByProtocol, \r
1473 &gEfiSimpleNetworkProtocolGuid,\r
1474 NULL,\r
1475 &BufferSize,\r
1476 NetworkHandles\r
1477 );\r
1478\r
1479 if (Status == EFI_BUFFER_TOO_SMALL) {\r
1480 NetworkHandles = AllocateZeroPool(BufferSize);\r
1481 if (NetworkHandles == NULL) {\r
1482 return (EFI_OUT_OF_RESOURCES);\r
1483 }\r
1484 Status = gBS->LocateHandle(\r
1485 ByProtocol,\r
1486 &gEfiSimpleNetworkProtocolGuid,\r
1487 NULL,\r
1488 &BufferSize,\r
1489 NetworkHandles\r
1490 );\r
1491 }\r
1492 \r
1493 //\r
1494 //Get the MAC string\r
1495 //\r
1496 Status = NetLibGetMacString (\r
1497 *NetworkHandles,\r
1498 NULL,\r
1499 &MacStr\r
1500 );\r
1501 if (EFI_ERROR (Status)) { \r
1502 return Status;\r
1503 }\r
1504 IPverStr = L" IPv6";\r
1505 UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%s%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)),MacStr,IPverStr);\r
1506 break;\r
1507 }\r
1508 DevicePath = NextDevicePathNode (DevicePath);\r
1509 }\r
1510 \r
1511 BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList, Buffer);\r
1512 }\r
1513\r
1514 if (NumOfLoadFileHandles != 0) {\r
1515 FreePool (LoadFileHandles);\r
1516 }\r
1517\r
1518 //\r
1519 // Check if we have on flash shell\r
1520 //\r
1521 /* gBS->LocateHandleBuffer (\r
1522 ByProtocol,\r
1523 &gEfiFirmwareVolume2ProtocolGuid,\r
1524 NULL,\r
1525 &FvHandleCount,\r
1526 &FvHandleBuffer\r
1527 );\r
1528 for (Index = 0; Index < FvHandleCount; Index++) {\r
1529 gBS->HandleProtocol (\r
1530 FvHandleBuffer[Index],\r
1531 &gEfiFirmwareVolume2ProtocolGuid,\r
1532 (VOID **) &Fv\r
1533 );\r
1534\r
1535 Status = Fv->ReadFile (\r
1536 Fv,\r
1537 PcdGetPtr(PcdShellFile),\r
1538 NULL,\r
1539 &Size,\r
1540 &Type,\r
1541 &Attributes,\r
1542 &AuthenticationStatus\r
1543 );\r
1544 if (EFI_ERROR (Status)) {\r
1545 //\r
1546 // Skip if no shell file in the FV\r
1547 //\r
1548 continue;\r
1549 }\r
1550 //\r
1551 // Build the shell boot option\r
1552 //\r
1553 BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
1554 }\r
1555\r
1556 if (FvHandleCount != 0) {\r
1557 FreePool (FvHandleBuffer);\r
1558 } */\r
1559 \r
1560 //\r
1561 // Make sure every boot only have one time\r
1562 // boot device enumerate\r
1563 //\r
1564 Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
1565 mEnumBootDevice = TRUE;\r
1566\r
1567 return Status;\r
1568} \r
1569\r
1570\r
1571\r
3cbfba02
DW
1572/**\r
1573\r
2e182e30 1574 The function will execute with as the platform policy, current policy\r
3cbfba02
DW
1575 is driven by boot mode. IBV/OEM can customize this code for their specific\r
1576 policy action.\r
1577\r
1578 @param DriverOptionList - The header of the driver option link list\r
1579 @param BootOptionList - The header of the boot option link list\r
1580 @param ProcessCapsules - A pointer to ProcessCapsules()\r
1581 @param BaseMemoryTest - A pointer to BaseMemoryTest()\r
1582\r
1583 @retval None.\r
1584\r
1585**/\r
1586VOID\r
1587EFIAPI\r
1588PlatformBdsPolicyBehavior (\r
1589 IN OUT LIST_ENTRY *DriverOptionList,\r
1590 IN OUT LIST_ENTRY *BootOptionList,\r
04d8d883 1591 IN PROCESS_CAPSULES BdsProcessCapsules,\r
3cbfba02
DW
1592 IN BASEM_MEMORY_TEST BaseMemoryTest\r
1593 )\r
1594{\r
1595 EFI_STATUS Status;\r
1596 UINT16 Timeout;\r
1597 EFI_BOOT_MODE BootMode;\r
1598 BOOLEAN DeferredImageExist;\r
1599 UINTN Index;\r
3cbfba02
DW
1600 SYSTEM_CONFIGURATION SystemConfiguration;\r
1601 UINTN VarSize;\r
3cbfba02
DW
1602 PLATFORM_PCI_DEVICE_PATH *EmmcBootDevPath;\r
1603 EFI_GLOBAL_NVS_AREA_PROTOCOL *GlobalNvsArea;\r
1604 EFI_HANDLE FvProtocolHandle;\r
1605 UINTN HandleCount;\r
1606 EFI_HANDLE *HandleBuffer;\r
1607 UINTN Index1;\r
1608 UINTN SataPciRegBase = 0;\r
1609 UINT16 SataModeSelect = 0;\r
1610 VOID *RegistrationExitPmAuth = NULL;\r
1611 EFI_EVENT Event;\r
1612 BOOLEAN IsFirstBoot;\r
1613 UINT16 *BootOrder;\r
1614 UINTN BootOrderSize;\r
04d8d883 1615 ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;\r
3cbfba02
DW
1616\r
1617 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
620f2891
TH
1618 if (Timeout > 10 ) {\r
1619 //we think the Timeout variable is corrupted\r
1620 Timeout = 10;\r
1621 }\r
04d8d883 1622\r
3cbfba02
DW
1623 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
1624 Status = gRT->GetVariable(\r
1625 NORMAL_SETUP_NAME,\r
1626 &gEfiNormalSetupGuid,\r
1627 NULL,\r
1628 &VarSize,\r
1629 &SystemConfiguration\r
1630 );\r
620f2891
TH
1631\r
1632 if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
1633 //The setup variable is corrupted\r
1634 VarSize = sizeof(SYSTEM_CONFIGURATION);\r
1635 Status = gRT->GetVariable(\r
1636 L"SetupRecovery",\r
1637 &gEfiNormalSetupGuid,\r
1638 NULL,\r
1639 &VarSize,\r
1640 &SystemConfiguration\r
1641 );\r
1642 ASSERT_EFI_ERROR (Status);\r
04d8d883 1643 }\r
3cbfba02
DW
1644\r
1645 //\r
1646 // Load the driver option as the driver option list\r
1647 //\r
1648 PlatformBdsGetDriverOption (DriverOptionList);\r
1649\r
1650 //\r
1651 // Get current Boot Mode\r
1652 //\r
1653 BootMode = GetBootModeHob();\r
1654\r
3cbfba02
DW
1655 //\r
1656 // No deferred images exist by default\r
1657 //\r
1658 DeferredImageExist = FALSE;\r
1659 if ((BootMode != BOOT_WITH_MINIMAL_CONFIGURATION) && (PcdGet32(PcdFlashFvShellSize) > 0)){\r
1660 gDS->ProcessFirmwareVolume (\r
1661 (VOID *)(UINTN)PcdGet32(PcdFlashFvShellBase),\r
1662 PcdGet32(PcdFlashFvShellSize),\r
1663 &FvProtocolHandle\r
1664 );\r
1665 }\r
1666\r
1667 if (SystemConfiguration.FastBoot == 1) {\r
1668 BootOrder = BdsLibGetVariableAndSize (\r
1669 L"BootOrder",\r
1670 &gEfiGlobalVariableGuid,\r
1671 &BootOrderSize\r
1672 );\r
1673 if ((BootOrder != NULL) && (BootMode != BOOT_ON_FLASH_UPDATE)) {\r
1674 //\r
1675 // BootOrder exist, it means system has boot before. We can do fast boot.\r
1676 //\r
1677 BootMode = BOOT_WITH_MINIMAL_CONFIGURATION;\r
1678 }\r
1679 }\r
1680\r
1681\r
1682 //\r
1683 // Use eMMC to boot OS and turn on AHCI, when SATA HDD is diconnected,\r
1684 // SATA AHCI CTLR device will show yellow bang, implement this solution to solve it.\r
1685 //\r
1686 SataPciRegBase = MmPciAddress (0, 0, PCI_DEVICE_NUMBER_PCH_SATA, 0, 0);\r
1687 SataModeSelect = MmioRead16 (SataPciRegBase + R_PCH_SATA_MAP) & B_PCH_SATA_MAP_SMS_MASK;\r
1688 Status = EFI_SUCCESS;\r
1689 if (SataModeSelect != V_PCH_SATA_MAP_SMS_IDE) {\r
1690 Status = gBS->CreateEvent (\r
1691 EVT_NOTIFY_SIGNAL,\r
1692 TPL_CALLBACK,\r
1693 DisableAhciCtlr,\r
1694 &SataPciRegBase,\r
1695 &Event\r
1696 );\r
1697 if (!EFI_ERROR (Status)) {\r
1698 Status = gBS->RegisterProtocolNotify (\r
1699 &gExitPmAuthProtocolGuid,\r
1700 Event,\r
1701 &RegistrationExitPmAuth\r
1702 );\r
1703 }\r
1704 }\r
1705\r
04d8d883
JY
1706 Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);\r
1707 if (EFI_ERROR(Status)) {\r
1708 EsrtManagement = NULL;\r
1709 }\r
1710\r
3cbfba02
DW
1711 switch (BootMode) {\r
1712\r
1713 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
1714 PlatformBdsInitHotKeyEvent ();\r
1715 PlatformBdsConnectSimpleConsole (gPlatformSimpleConsole);\r
1716\r
1717\r
1718 //\r
1719 // Check to see if it's needed to dispatch more DXE drivers.\r
1720 //\r
1721 for (Index = 0; Index < sizeof(ConnectDriverTable)/sizeof(EFI_GUID *); Index++) {\r
1722 Status = gBS->LocateHandleBuffer (\r
1723 ByProtocol,\r
1724 ConnectDriverTable[Index],\r
1725 NULL,\r
1726 &HandleCount,\r
1727 &HandleBuffer\r
1728 );\r
1729 if (!EFI_ERROR (Status)) {\r
1730 for (Index1 = 0; Index1 < HandleCount; Index1++) {\r
1731 gBS->ConnectController (\r
1732 HandleBuffer[Index1],\r
1733 NULL,\r
1734 NULL,\r
1735 TRUE\r
1736 );\r
1737 }\r
1738 }\r
1739\r
1740 if (HandleBuffer != NULL) {\r
1741 FreePool (HandleBuffer);\r
1742 }\r
1743\r
1744 gDS->Dispatch ();\r
1745 }\r
1746\r
1747 //\r
1748 // Locate the Global NVS Protocol.\r
1749 //\r
1750 Status = gBS->LocateProtocol (\r
1751 &gEfiGlobalNvsAreaProtocolGuid,\r
1752 NULL,\r
1753 (void **)&GlobalNvsArea\r
1754 );\r
1755 if (GlobalNvsArea->Area->emmcVersion == 0){\r
1756 EmmcBootDevPath = (PLATFORM_PCI_DEVICE_PATH *)gPlatformSimpleBootOption[0];\r
1757 EmmcBootDevPath->PciDevice.Device = 0x10;\r
1758 }\r
1759\r
1760 //\r
1761 // Connect boot device here to give time to read keyboard.\r
1762 //\r
1763 BdsLibConnectDevicePath (gPlatformSimpleBootOption[0]);\r
1764\r
1765 //\r
1766 // This is a workround for dectecting hotkey from USB keyboard.\r
1767 //\r
1768 gBS->Stall(KEYBOARD_TIMER_INTERVAL);\r
1769\r
1770 if (mHotKeyTimerEvent != NULL) {\r
1771 gBS->SetTimer (\r
1772 mHotKeyTimerEvent,\r
1773 TimerCancel,\r
1774 0\r
1775 );\r
1776 gBS->CloseEvent (mHotKeyTimerEvent);\r
1777 mHotKeyTimerEvent = NULL;\r
1778 }\r
1779 if (mHotKeyPressed) {\r
1780 //\r
1781 // Skip show progress count down\r
1782 //\r
1783 Timeout = 0xFFFF;\r
1784 goto FULL_CONFIGURATION;\r
1785 }\r
1786\r
1787 if (SystemConfiguration.QuietBoot) {\r
1788 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
1789 } else {\r
1790 PlatformBdsDiagnostics (IGNORE, FALSE, BaseMemoryTest);\r
1791 }\r
1792\r
1793\r
f4e7aa05
TH
1794 #ifdef TPM_ENABLED\r
1795 TcgPhysicalPresenceLibProcessRequest();\r
1796 #endif\r
1797 #ifdef FTPM_ENABLE\r
33aaf8d7 1798 Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
f4e7aa05 1799 #endif\r
04d8d883
JY
1800\r
1801 if (EsrtManagement != NULL) {\r
1802 EsrtManagement->LockEsrtRepository();\r
1803 }\r
1804\r
3cbfba02
DW
1805 //\r
1806 // Close boot script and install ready to lock\r
1807 //\r
1808 InstallReadyToLock ();\r
1809\r
1810 //\r
04d8d883 1811 // Give one chance to enter the setup if we\r
3cbfba02
DW
1812 // select Gummiboot "Reboot Into Firmware Interface" and Fast Boot is enabled.\r
1813 //\r
1814 BootIntoFirmwareInterface();\r
1815 break;\r
1816\r
1817 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
1818\r
1819 //\r
1820 // In no-configuration boot mode, we can connect the\r
1821 // console directly.\r
1822 //\r
1823 BdsLibConnectAllDefaultConsoles ();\r
1824 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
1825\r
1826 //\r
1827 // Perform some platform specific connect sequence\r
1828 //\r
1829 PlatformBdsConnectSequence ();\r
1830\r
1831 //\r
1832 // As console is ready, perform user identification again.\r
1833 //\r
1834 if (mCurrentUser == NULL) {\r
1835 PlatformBdsUserIdentify (&mCurrentUser, &DeferredImageExist);\r
1836 if (DeferredImageExist) {\r
1837 //\r
1838 // After user authentication, the deferred drivers was loaded again.\r
1839 // Here, need to ensure the deferred images are connected.\r
1840 //\r
1841 BdsLibConnectAllDefaultConsoles ();\r
1842 PlatformBdsConnectSequence ();\r
1843 }\r
1844 }\r
1845\r
04d8d883
JY
1846 if (EsrtManagement != NULL) {\r
1847 EsrtManagement->LockEsrtRepository();\r
1848 }\r
1849\r
3cbfba02
DW
1850 //\r
1851 // Close boot script and install ready to lock\r
1852 //\r
1853 InstallReadyToLock ();\r
1854\r
1855 //\r
1856 // Notes: current time out = 0 can not enter the\r
1857 // front page\r
1858 //\r
1859 PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE);\r
1860\r
1861 //\r
1862 // Check the boot option with the boot option list\r
1863 //\r
1864 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
1865 break;\r
1866\r
1867 case BOOT_ON_FLASH_UPDATE:\r
1868\r
1869 //\r
1870 // Boot with the specific configuration\r
1871 //\r
1872 PlatformBdsConnectConsole (gPlatformConsole);\r
1873 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
04d8d883 1874\r
1ed0b254 1875 DEBUG((DEBUG_INFO, "ProcessCapsules Before EndOfDxe......\n"));\r
04d8d883 1876 ProcessCapsules ();\r
1ed0b254 1877 DEBUG((DEBUG_INFO, "ProcessCapsules Done\n"));\r
04d8d883
JY
1878\r
1879 //\r
1880 // Close boot script and install ready to lock\r
1881 //\r
1882 InstallReadyToLock ();\r
1883\r
3cbfba02
DW
1884 BdsLibConnectAll ();\r
1885\r
1886 //\r
1887 // Perform user identification\r
1888 //\r
1889 if (mCurrentUser == NULL) {\r
1890 PlatformBdsUserIdentify (&mCurrentUser, &DeferredImageExist);\r
1891 if (DeferredImageExist) {\r
1892 //\r
1893 // After user authentication, the deferred drivers was loaded again.\r
1894 // Here, need to ensure the deferred images are connected.\r
1895 //\r
1896 BdsLibConnectAll ();\r
1897 }\r
1898 }\r
1899\r
04d8d883
JY
1900 if (EsrtManagement != NULL) {\r
1901 EsrtManagement->SyncEsrtFmp();\r
1902 }\r
3cbfba02 1903\r
1ed0b254 1904 DEBUG((DEBUG_INFO, "ProcessCapsules After ConnectAll......\n"));\r
04d8d883 1905 ProcessCapsules();\r
1ed0b254 1906 DEBUG((DEBUG_INFO, "ProcessCapsules Done\n"));\r
3cbfba02
DW
1907 break;\r
1908\r
1909 case BOOT_IN_RECOVERY_MODE:\r
1910\r
1911 //\r
1912 // In recovery mode, just connect platform console\r
1913 // and show up the front page\r
1914 //\r
1915 PlatformBdsConnectConsole (gPlatformConsole);\r
1916 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
1917 BdsLibConnectAll ();\r
1918\r
1919 //\r
1920 // Perform user identification\r
1921 //\r
1922 if (mCurrentUser == NULL) {\r
1923 PlatformBdsUserIdentify (&mCurrentUser, &DeferredImageExist);\r
1924 if (DeferredImageExist) {\r
1925 //\r
1926 // After user authentication, the deferred drivers was loaded again.\r
1927 // Here, need to ensure the deferred drivers are connected.\r
1928 //\r
1929 BdsLibConnectAll ();\r
1930 }\r
1931 }\r
1932\r
1933 //\r
1934 // Close boot script and install ready to lock\r
1935 //\r
1936 InstallReadyToLock ();\r
1937\r
1938 //\r
1939 // In recovery boot mode, we still enter to the\r
1940 // frong page now\r
1941 //\r
1942 PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE);\r
1943 break;\r
1944\r
1945FULL_CONFIGURATION:\r
1946 case BOOT_WITH_FULL_CONFIGURATION:\r
1947 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
1948 case BOOT_WITH_DEFAULT_SETTINGS:\r
1949 default:\r
1950\r
1951 //\r
1952 // Connect platform console\r
1953 //\r
1954 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
1955 if (EFI_ERROR (Status)) {\r
1956\r
1957 //\r
1958 // Here OEM/IBV can customize with defined action\r
1959 //\r
1960 PlatformBdsNoConsoleAction ();\r
1961 }\r
1962\r
1963 //\r
1964 // Chenyunh[TODO]: This is Workgroud to show the fs for uSDcard,\r
1965 // Need to root cause this issue.\r
1966 //\r
1967 DEBUG ((DEBUG_ERROR, "Start to reconnect all driver.\n"));\r
1968 BdsLibDisconnectAllEfi();\r
1969 BdsLibConnectAll ();\r
1970 DEBUG ((DEBUG_ERROR, "End to reconnect all driver.\n"));\r
1971\r
1972 //\r
1973 // Perform some platform specific connect sequence\r
1974 //\r
1975 PlatformBdsConnectSequence ();\r
1976 if (SystemConfiguration.QuietBoot) {\r
1977 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
1978 } else {\r
1979 PlatformBdsDiagnostics (IGNORE, FALSE, BaseMemoryTest);\r
1980 }\r
1981\r
1982 //\r
1983 // Do a pre-delay so Hard Disk can spin up and see more logo.\r
1984 //\r
1985 gBS->Stall(SystemConfiguration.HddPredelay * 1000000);\r
1986\r
1987 //\r
1988 // Perform user identification\r
1989 //\r
1990 if (mCurrentUser == NULL) {\r
1991 PlatformBdsUserIdentify (&mCurrentUser, &DeferredImageExist);\r
1992 if (DeferredImageExist) {\r
1993 //\r
1994 // After user authentication, the deferred drivers was loaded again.\r
1995 // Here, need to ensure the deferred drivers are connected.\r
1996 //\r
1997 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
1998 if (EFI_ERROR (Status)) {\r
1999 PlatformBdsNoConsoleAction ();\r
2000 }\r
2001 PlatformBdsConnectSequence ();\r
2002 }\r
2003 }\r
f4e7aa05 2004 #ifdef TPM_ENABLED\r
3cbfba02 2005 TcgPhysicalPresenceLibProcessRequest();\r
f4e7aa05
TH
2006 #endif\r
2007 #ifdef FTPM_ENABLE\r
33aaf8d7 2008 Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
f4e7aa05 2009 #endif\r
04d8d883
JY
2010\r
2011 if (EsrtManagement != NULL) {\r
2012 EsrtManagement->SyncEsrtFmp();\r
2013 }\r
3cbfba02
DW
2014 //\r
2015 // Close boot script and install ready to lock\r
2016 //\r
2017 InstallReadyToLock ();\r
2018\r
69a99d0b
MG
2019 //\r
2020 // Here we have enough time to do the enumeration of boot device\r
2021 //\r
2022 PlatformBdsLibEnumerateAllBootOption (BootOptionList);\r
2023\r
3cbfba02
DW
2024 //\r
2025 // Give one chance to enter the setup if we\r
2026 // have the time out\r
2027 //\r
2028 PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE);\r
2029\r
2030 //\r
04d8d883 2031 // Give one chance to enter the setup if we\r
3cbfba02
DW
2032 // select Gummiboot "Reboot Into Firmware Interface"\r
2033 //\r
2034 BootIntoFirmwareInterface();\r
2035\r
2036 //\r
2037 // In default boot mode, always find all boot\r
2038 // option and do enumerate all the default boot option\r
2039 //\r
2040 if (Timeout == 0) {\r
2041 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
2042 if (IsListEmpty(BootOptionList)) {\r
2043 PlatformBdsPredictBootOption (BootOptionList);\r
2044 }\r
2045\r
2046 return;\r
2047 }\r
2048\r
04d8d883 2049\r
3cbfba02
DW
2050 break;\r
2051 }\r
2052\r
2053\r
2054 IsFirstBoot = PcdGetBool(PcdBootState);\r
2055 if (IsFirstBoot) {\r
2056 PcdSetBool(PcdBootState, FALSE);\r
2057 }\r
2058 return;\r
2059\r
2060}\r
2061\r
2062/**\r
2063 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
2064 return, so the UEFI 2.0 specification defines that you will default to an\r
2065 interactive mode and stop processing the BootOrder list in this case. This\r
2066 is alos a platform implementation and can be customized by IBV/OEM.\r
2067\r
2068 @param Option Pointer to Boot Option that succeeded to boot.\r
2069\r
2070 @retval None.\r
2071\r
2072**/\r
2073VOID\r
2074EFIAPI\r
2075PlatformBdsBootSuccess (\r
2076 IN BDS_COMMON_OPTION *Option\r
2077 )\r
2078{\r
2079 CHAR16 *TmpStr;\r
2080\r
2081 //\r
2082 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
2083 // select loop then we need to pop up a UI and wait for user input.\r
2084 //\r
2085 TmpStr = Option->StatusString;\r
2086 if (TmpStr != NULL) {\r
2087 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
2088 FreePool(TmpStr);\r
2089 }\r
2090}\r
2091\r
2092/**\r
2093 Hook point after a boot attempt fails.\r
2094\r
2095 @param Option - Pointer to Boot Option that failed to boot.\r
2096 @param Status - Status returned from failed boot.\r
2097 @param ExitData - Exit data returned from failed boot.\r
2098 @param ExitDataSize - Exit data size returned from failed boot.\r
2099\r
2100 @retval None.\r
2101\r
2102**/\r
2103VOID\r
2104EFIAPI\r
2105PlatformBdsBootFail (\r
2106 IN BDS_COMMON_OPTION *Option,\r
2107 IN EFI_STATUS Status,\r
2108 IN CHAR16 *ExitData,\r
2109 IN UINTN ExitDataSize\r
2110 )\r
2111{\r
2112 CHAR16 *TmpStr;\r
2113 EFI_HANDLE FvProtocolHandle;\r
2114\r
2115 //\r
2116 // If Boot returned with failed status then we need to pop up a UI and wait\r
2117 // for user input.\r
2118 //\r
2119 TmpStr = Option->StatusString;\r
2120 if (TmpStr != NULL) {\r
2121 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
2122 FreePool(TmpStr);\r
2123 }\r
2124 if (PcdGet32(PcdFlashFvShellSize) > 0){\r
2125 gDS->ProcessFirmwareVolume (\r
2126 (VOID *)(UINTN)PcdGet32(PcdFlashFvShellBase),\r
2127 PcdGet32(PcdFlashFvShellSize),\r
2128 &FvProtocolHandle\r
2129 );\r
2130 }\r
2131 PlatformBdsConnectSequence ();\r
2132}\r
2133\r
2134/**\r
2135 This function is remained for IBV/OEM to do some platform action,\r
2136 if there no console device can be connected.\r
2137\r
2138 @param None.\r
2139\r
2140 @retval EFI_SUCCESS Direct return success now.\r
2141\r
2142**/\r
2143EFI_STATUS\r
2144PlatformBdsNoConsoleAction (\r
2145 VOID\r
2146 )\r
2147{\r
2148 return EFI_SUCCESS;\r
2149}\r
2150\r
2151/**\r
2152 This function locks the block\r
2153\r
2154 @param Base The base address flash region to be locked.\r
2155\r
2156**/\r
2157VOID\r
2158BdsLockFv (\r
2159 IN EFI_PHYSICAL_ADDRESS Base\r
2160 )\r
2161{\r
2162 EFI_FV_BLOCK_MAP_ENTRY *BlockMap;\r
2163 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
2164 EFI_PHYSICAL_ADDRESS BaseAddress;\r
3cbfba02
DW
2165 UINT32 BlockLength;\r
2166 UINTN Index;\r
2167\r
2168 BaseAddress = Base - 0x400000 + 2;\r
2169 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) (Base));\r
2170 BlockMap = &(FvHeader->BlockMap[0]);\r
2171\r
2172 while ((BlockMap->NumBlocks != 0) && (BlockMap->Length != 0)) {\r
2173 BlockLength = BlockMap->Length;\r
2174 for (Index = 0; Index < BlockMap->NumBlocks; Index++) {\r
5fc1373d 2175 MmioOr8 ((UINTN) BaseAddress, 0x03);\r
3cbfba02
DW
2176 BaseAddress += BlockLength;\r
2177 }\r
2178 BlockMap++;\r
2179 }\r
2180}\r
2181\r
2182VOID\r
2183EFIAPI\r
2184PlatformBdsLockNonUpdatableFlash (\r
2185 VOID\r
2186 )\r
2187{\r
2188 EFI_PHYSICAL_ADDRESS Base;\r
2189\r
2190 Base = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashFvMainBase);\r
2191 if (Base > 0) {\r
2192 BdsLockFv (Base);\r
2193 }\r
2194\r
2195 Base = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashFvRecoveryBase);\r
2196 if (Base > 0) {\r
2197 BdsLockFv (Base);\r
2198 }\r
2199}\r
2200\r
2201/**\r
2202 Lock the ConsoleIn device in system table. All key\r
2203 presses will be ignored until the Password is typed in. The only way to\r
2204 disable the password is to type it in to a ConIn device.\r
2205\r
2206 @param Password Password used to lock ConIn device.\r
2207\r
2208 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
2209 @retval EFI_UNSUPPORTED Password not found\r
2210\r
2211**/\r
2212EFI_STATUS\r
2213EFIAPI\r
2214LockKeyboards (\r
2215 IN CHAR16 *Password\r
2216 )\r
2217{\r
2218 return EFI_UNSUPPORTED;\r
2219}\r
2220\r
2221/**\r
2222 Connect the predefined platform default authentication devices.\r
2223\r
2224 This function connects the predefined device path for authentication device,\r
2225 and if the predefined device path has child device path, the child handle will\r
2226 be connected too. But the child handle of the child will not be connected.\r
2227\r
2228**/\r
2229VOID\r
2230EFIAPI\r
2231PlatformBdsConnectAuthDevice (\r
2232 VOID\r
2233 )\r
2234{\r
2235 EFI_STATUS Status;\r
2236 UINTN Index;\r
2237 UINTN HandleIndex;\r
2238 UINTN HandleCount;\r
2239 EFI_HANDLE *HandleBuffer;\r
2240 EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;\r
2241 EFI_USER_MANAGER_PROTOCOL *Manager;\r
2242\r
2243 Status = gBS->LocateProtocol (\r
2244 &gEfiUserManagerProtocolGuid,\r
2245 NULL,\r
2246 (VOID **) &Manager\r
2247 );\r
2248 if (EFI_ERROR (Status)) {\r
2249 //\r
2250 // As user manager protocol is not installed, the authentication devices\r
2251 // should not be connected.\r
2252 //\r
2253 return ;\r
2254 }\r
2255\r
2256 Index = 0;\r
2257 while (gUserAuthenticationDevice[Index] != NULL) {\r
2258 //\r
2259 // Connect the platform customized device paths\r
2260 //\r
2261 BdsLibConnectDevicePath (gUserAuthenticationDevice[Index]);\r
2262 Index++;\r
2263 }\r
2264\r
2265 //\r
2266 // Find and connect the child device paths of the platform customized device paths\r
2267 //\r
2268 HandleBuffer = NULL;\r
2269 for (Index = 0; gUserAuthenticationDevice[Index] != NULL; Index++) {\r
2270 HandleCount = 0;\r
2271 Status = gBS->LocateHandleBuffer (\r
2272 AllHandles,\r
2273 NULL,\r
2274 NULL,\r
2275 &HandleCount,\r
2276 &HandleBuffer\r
2277 );\r
2278 ASSERT (!EFI_ERROR (Status));\r
2279\r
2280 //\r
2281 // Find and connect the child device paths of gUserIdentificationDevice[Index]\r
2282 //\r
2283 for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r
2284 ChildDevicePath = NULL;\r
2285 Status = gBS->HandleProtocol (\r
2286 HandleBuffer[HandleIndex],\r
2287 &gEfiDevicePathProtocolGuid,\r
2288 (VOID **) &ChildDevicePath\r
2289 );\r
2290 if (EFI_ERROR (Status) || ChildDevicePath == NULL) {\r
2291 continue;\r
2292 }\r
2293\r
2294 if (CompareMem (\r
2295 ChildDevicePath,\r
2296 gUserAuthenticationDevice[Index],\r
2297 (GetDevicePathSize (gUserAuthenticationDevice[Index]) - sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
2298 ) != 0) {\r
2299 continue;\r
2300 }\r
2301 gBS->ConnectController (\r
2302 HandleBuffer[HandleIndex],\r
2303 NULL,\r
2304 NULL,\r
2305 TRUE\r
2306 );\r
2307 }\r
2308 }\r
2309\r
2310 if (HandleBuffer != NULL) {\r
2311 FreePool (HandleBuffer);\r
2312 }\r
2313}\r
2314\r
2315/**\r
2316 This function is to identify a user, and return whether deferred images exist.\r
2317\r
2318 @param[out] User Point to user profile handle.\r
2319 @param[out] DeferredImageExist On return, points to TRUE if the deferred image\r
2320 exist or FALSE if it did not exist.\r
2321\r
2322**/\r
2323VOID\r
2324EFIAPI\r
2325PlatformBdsUserIdentify (\r
2326 OUT EFI_USER_PROFILE_HANDLE *User,\r
2327 OUT BOOLEAN *DeferredImageExist\r
2328 )\r
2329{\r
2330 EFI_STATUS Status;\r
2331 EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;\r
2332 UINTN HandleCount;\r
2333 EFI_HANDLE *HandleBuf;\r
2334 UINTN Index;\r
2335 UINTN DriverIndex;\r
2336 EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;\r
2337 VOID *DriverImage;\r
2338 UINTN ImageSize;\r
2339 BOOLEAN BootOption;\r
2340\r
2341 //\r
2342 // Perform user identification\r
2343 //\r
2344 do {\r
2345 Status = BdsLibUserIdentify (User);\r
2346 } while (EFI_ERROR (Status));\r
2347\r
2348 //\r
2349 // After user authentication now, try to find whether deferred image exists\r
2350 //\r
2351 HandleCount = 0;\r
2352 HandleBuf = NULL;\r
2353 *DeferredImageExist = FALSE;\r
2354 Status = gBS->LocateHandleBuffer (\r
2355 ByProtocol,\r
2356 &gEfiDeferredImageLoadProtocolGuid,\r
2357 NULL,\r
2358 &HandleCount,\r
2359 &HandleBuf\r
2360 );\r
2361 if (EFI_ERROR (Status)) {\r
2362 return ;\r
2363 }\r
2364\r
2365 for (Index = 0; Index < HandleCount; Index++) {\r
2366 Status = gBS->HandleProtocol (\r
2367 HandleBuf[Index],\r
2368 &gEfiDeferredImageLoadProtocolGuid,\r
2369 (VOID **) &DeferredImage\r
2370 );\r
2371 if (!EFI_ERROR (Status)) {\r
2372 //\r
2373 // Find whether deferred image exists in this instance.\r
2374 //\r
2375 DriverIndex = 0;\r
2376 Status = DeferredImage->GetImageInfo(\r
2377 DeferredImage,\r
2378 DriverIndex,\r
2379 &ImageDevicePath,\r
2380 (VOID **) &DriverImage,\r
2381 &ImageSize,\r
2382 &BootOption\r
2383 );\r
2384 if (!EFI_ERROR (Status)) {\r
2385 //\r
2386 // The deferred image is found.\r
2387 //\r
2388 FreePool (HandleBuf);\r
2389 *DeferredImageExist = TRUE;\r
2390 return ;\r
2391 }\r
2392 }\r
2393 }\r
2394\r
2395 FreePool (HandleBuf);\r
2396}\r
2397\r
2398UINTN gHotKey = 0;\r
2399\r
2400\r
2401EFI_STATUS\r
2402ShowProgressHotKey (\r
2403 IN UINT16 TimeoutDefault\r
2404 )\r
2405{\r
2406 CHAR16 *TmpStr;\r
2407 UINT16 TimeoutRemain;\r
2408 EFI_STATUS Status;\r
2409 EFI_INPUT_KEY Key;\r
2410 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
2411 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
2412 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
2413 UINT32 GpioValue;\r
1ed0b254
JY
2414 CHAR16 *TmpStr1;\r
2415 CHAR16 *TmpStr2;\r
2416 CHAR16 *TmpStr3;\r
2417 UINTN TmpStrSize;\r
2418 VOID *Buffer;\r
2419 UINTN Size;\r
3cbfba02
DW
2420\r
2421 if (TimeoutDefault == 0) {\r
2422 return EFI_TIMEOUT;\r
2423 }\r
2424\r
c7d161de
DW
2425 gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
2426 \r
3cbfba02
DW
2427 if (DebugAssertEnabled())\r
2428 {\r
2429 DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it, or press <F2> or <DEL> to enter setup page! ...Zzz....\n"));\r
2430 }\r
2431 else\r
2432 { \r
2433 #ifdef __GNUC__\r
2434 SerialPortWrite((UINT8 *)"\n\n>>>>Start boot option, Press <F2> or <DEL> to enter setup page(5 Sec)[GCC]", 76);\r
2435 #else\r
2436 SerialPortWrite((UINT8 *)"\n\n>>>>Start boot option, Press <F2> or <DEL> to enter setup page(5 Sec)", 71);\r
2437 #endif\r
2438 } \r
2439 SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
2440 SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
2441 SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
2442\r
1ed0b254
JY
2443 TmpStr2 = NULL;\r
2444 TmpStr3 = NULL;\r
2445\r
2446 //\r
2447 // Check if the platform is using test key.\r
2448 //\r
2449 Status = GetSectionFromAnyFv(\r
2450 PcdGetPtr(PcdEdkiiRsa2048Sha256TestPublicKeyFileGuid),\r
2451 EFI_SECTION_RAW,\r
2452 0,\r
2453 &Buffer,\r
2454 &Size\r
2455 );\r
2456 if (!EFI_ERROR(Status)) {\r
2457 if ((Size == PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer)) &&\r
2458 (CompareMem(Buffer, PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer), Size) == 0)) {\r
2459 TmpStr2 = L"WARNING: Recovery Test Key is used.\r\n";\r
2460 if (DebugAssertEnabled()) {\r
2461 DEBUG ((DEBUG_INFO, "\n\nWARNING: Recovery Test Key is used.\n"));\r
2462 } else {\r
2463 SerialPortWrite((UINT8 *)"\n\nWARNING: Recovery Test Key is used.", sizeof("\n\nWARNING: Recovery Test Key is used."));\r
2464 }\r
2465 PcdSetBoolS(PcdTestKeyUsed, TRUE);\r
2466 }\r
2467 FreePool(Buffer);\r
2468 }\r
2469 Status = GetSectionFromAnyFv(\r
2470 PcdGetPtr(PcdEdkiiPkcs7TestPublicKeyFileGuid),\r
2471 EFI_SECTION_RAW,\r
2472 0,\r
2473 &Buffer,\r
2474 &Size\r
2475 );\r
2476 if (!EFI_ERROR(Status)) {\r
2477 if ((Size == PcdGetSize(PcdPkcs7CertBuffer)) &&\r
2478 (CompareMem(Buffer, PcdGetPtr(PcdPkcs7CertBuffer), Size) == 0)) {\r
2479 TmpStr3 = L"WARNING: Capsule Test Key is used.\r\n";\r
2480 if (DebugAssertEnabled()) {\r
2481 DEBUG ((DEBUG_INFO, "\n\nWARNING: Capsule Test Key is used.\r\n"));\r
2482 } else {\r
2483 SerialPortWrite((UINT8 *)"\n\nWARNING: Capsule Test Key is used.", sizeof("\n\nWARNING: Capsule Test Key is used."));\r
2484 }\r
2485 PcdSetBoolS(PcdTestKeyUsed, TRUE);\r
2486 }\r
2487 FreePool(Buffer);\r
2488 }\r
2489\r
3cbfba02
DW
2490 //\r
2491 // Clear the progress status bar first\r
2492 //\r
1ed0b254
JY
2493 TmpStr1 = L"Start boot option, Press <F2> or <DEL> to enter setup page.\r\n";\r
2494 TmpStrSize = StrSize(TmpStr1);\r
2495 if (TmpStr2 != NULL) {\r
2496 TmpStrSize += StrSize(TmpStr2);\r
2497 }\r
2498 if (TmpStr3 != NULL) {\r
2499 TmpStrSize += StrSize(TmpStr3);\r
2500 }\r
2501 TmpStr = AllocatePool (TmpStrSize);\r
2502 if (TmpStr == NULL) {\r
2503 TmpStr = TmpStr1;\r
2504 } else {\r
2505 StrCpyS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr1);\r
2506 if (TmpStr2 != NULL) {\r
2507 StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr2);\r
2508 }\r
2509 if (TmpStr3 != NULL) {\r
2510 StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr3);\r
2511 }\r
2512 }\r
3cbfba02
DW
2513 PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
2514\r
2515 TimeoutRemain = TimeoutDefault;\r
2516 while (TimeoutRemain != 0) {\r
2517 if (DebugAssertEnabled())\r
2518 {\r
2519 DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain));\r
2520 }\r
2521 else\r
2522 { \r
2523 SerialPortWrite ((UINT8 *)".", 1);\r
2524 }\r
2525 Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);\r
2526 if (Status != EFI_TIMEOUT) {\r
2527 break;\r
2528 }\r
2529 TimeoutRemain--;\r
2530\r
2531 //\r
2532 // Show progress\r
2533 //\r
2534 if (TmpStr != NULL) {\r
2535 PlatformBdsShowProgress (\r
2536 Foreground,\r
2537 Background,\r
2538 TmpStr,\r
2539 Color,\r
2540 ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),\r
2541 0\r
2542 );\r
2543 }\r
2544 }\r
2545\r
2546 //\r
2547 // Timeout expired\r
2548 //\r
2549 if (TimeoutRemain == 0) {\r
2550 if (DebugAssertEnabled())\r
2551 {\r
2552 }\r
2553 else\r
2554 { \r
2555 SerialPortWrite ((UINT8 *)"\r\n", 2);\r
2556 }\r
2557 return EFI_TIMEOUT;\r
2558 }\r
2559\r
2560 //\r
2561 // User pressed some key\r
2562 //\r
2563 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
2564 if (EFI_ERROR (Status)) {\r
2565 return Status;\r
2566 }\r
2567\r
2568 //\r
2569 // Check Volume Up Key to enter Setup\r
2570 //\r
2571 GpioValue = MmioRead32 (IO_BASE_ADDRESS + 0x0668); // The value of GPIOC_5\r
2572 if (((GpioValue & BIT0) == 0) && (Key.ScanCode == SCAN_UP)) {\r
2573 gHotKey = 0;\r
2574 return EFI_SUCCESS;\r
2575 }\r
2576\r
2577 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
2578 //\r
2579 // User pressed enter, equivalent to select "continue"\r
2580 //\r
2581 return EFI_TIMEOUT;\r
2582 }\r
2583\r
2584 //\r
2585 //F2 -- Front Page\r
2586 //F5 -- Device Manager\r
2587 //F7 -- Boot Manager\r
2588 // do not use F8. generally people assume it is windows safe mode key.\r
2589 //F9 -- Boot order\r
2590 //\r
2591 DEBUG ((EFI_D_INFO, "[Key Pressed]: ScanCode 0x%x\n", Key.ScanCode));\r
2592 switch(Key.ScanCode) {\r
2593 case SCAN_F2:\r
2594 gHotKey = 0;\r
2595 break;\r
2596\r
2597 case SCAN_DELETE:\r
2598 gHotKey = 0;\r
2599 break;\r
2600\r
2601 case SCAN_F5:\r
2602 gHotKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
2603 break;\r
2604\r
2605 case SCAN_F7:\r
2606 gHotKey = FRONT_PAGE_KEY_BOOT_MANAGER;\r
2607 break;\r
2608\r
2609 case SCAN_F9:\r
2610 gHotKey = FRONT_PAGE_KEY_BOOT_MAINTAIN;\r
2611 break;\r
2612\r
2613 default:\r
2614 //set gHotKey to continue so that flow will not go into CallFrontPage\r
2615 gHotKey = FRONT_PAGE_KEY_CONTINUE;\r
2616 return EFI_TIMEOUT;\r
2617 break;\r
2618 }\r
2619\r
2620 return EFI_SUCCESS;\r
2621}\r
2622\r
2623\r
2624\r
2625/**\r
2626 This function is the main entry of the platform setup entry.\r
2627 The function will present the main menu of the system setup,\r
2628 this is the platform reference part and can be customize.\r
2629\r
2630\r
2631 @param TimeoutDefault The fault time out value before the system\r
2632 continue to boot.\r
2633 @param ConnectAllHappened The indicater to check if the connect all have\r
2634 already happened.\r
2635\r
2636**/\r
2637VOID\r
2638PlatformBdsEnterFrontPageWithHotKey (\r
2639 IN UINT16 TimeoutDefault,\r
2640 IN BOOLEAN ConnectAllHappened\r
2641 )\r
2642{\r
2643 EFI_STATUS Status;\r
2644\r
2645 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
2646 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
2647 UINTN BootTextColumn;\r
2648 UINTN BootTextRow;\r
2649\r
2650 GraphicsOutput = NULL;\r
2651 SimpleTextOut = NULL;\r
2652\r
2653 PERF_START (NULL, "BdsTimeOut", "BDS", 0);\r
2654\r
2655 //\r
2656 // Indicate if we need connect all in the platform setup\r
2657 //\r
2658 if (ConnectAllHappened) {\r
2659 gConnectAllHappened = TRUE;\r
2660 }\r
2661\r
2662 if (!mModeInitialized) {\r
2663 //\r
2664 // After the console is ready, get current video resolution\r
2665 // and text mode before launching setup at first time.\r
2666 //\r
2667 Status = gBS->HandleProtocol (\r
2668 gST->ConsoleOutHandle,\r
2669 &gEfiGraphicsOutputProtocolGuid,\r
2670 (VOID**)&GraphicsOutput\r
2671 );\r
2672 if (EFI_ERROR (Status)) {\r
2673 GraphicsOutput = NULL;\r
2674 }\r
2675\r
2676 Status = gBS->HandleProtocol (\r
2677 gST->ConsoleOutHandle,\r
2678 &gEfiSimpleTextOutProtocolGuid,\r
2679 (VOID**)&SimpleTextOut\r
2680 );\r
2681 if (EFI_ERROR (Status)) {\r
2682 SimpleTextOut = NULL;\r
2683 }\r
2684\r
2685 if (GraphicsOutput != NULL) {\r
2686 //\r
2687 // Get current video resolution and text mode.\r
2688 //\r
2689 mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
2690 mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
2691 }\r
2692\r
2693 if (SimpleTextOut != NULL) {\r
2694 Status = SimpleTextOut->QueryMode (\r
2695 SimpleTextOut,\r
2696 SimpleTextOut->Mode->Mode,\r
2697 &BootTextColumn,\r
2698 &BootTextRow\r
2699 );\r
2700 mBootTextModeColumn = (UINT32)BootTextColumn;\r
2701 mBootTextModeRow = (UINT32)BootTextRow;\r
2702 }\r
2703\r
2704 //\r
2705 // Get user defined text mode for setup.\r
2706 //\r
2707 mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
2708 mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);\r
2709 mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);\r
2710 mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);\r
2711\r
2712 mModeInitialized = TRUE;\r
2713 }\r
2714\r
2715 if (TimeoutDefault != 0xffff) {\r
2716 Status = ShowProgressHotKey (TimeoutDefault);\r
2717\r
2718 //\r
2719 // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
2720 //\r
2721 gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
2722 gST->ConOut->ClearScreen (gST->ConOut);\r
2723\r
2724 if (EFI_ERROR (Status)) {\r
2725 //\r
2726 // Timeout or user press enter to continue\r
2727 //\r
2728 goto Exit;\r
2729 }\r
2730 }\r
4139580d
SL
2731 //\r
2732 // Install BM HiiPackages. \r
2733 // Keep BootMaint HiiPackage, so that it can be covered by global setting. \r
2734 //\r
2735 InitBMPackage ();\r
3cbfba02
DW
2736 do {\r
2737\r
2738 BdsSetConsoleMode (TRUE);\r
2739\r
2740 InitializeFrontPage (FALSE);\r
2741\r
2742 //\r
2743 // Update Front Page strings\r
2744 //\r
2745 UpdateFrontPageStrings ();\r
2746\r
2747 Status = EFI_SUCCESS;\r
2748 gCallbackKey = 0;\r
2749 if (gHotKey == 0) {\r
2750 Status = CallFrontPage ();\r
2751 } else {\r
2752 gCallbackKey = gHotKey;\r
2753 gHotKey = 0;\r
2754 }\r
2755\r
2756 //\r
2757 // If gCallbackKey is greater than 1 and less or equal to 5,\r
2758 // it will launch configuration utilities.\r
2759 // 2 = set language\r
2760 // 3 = boot manager\r
2761 // 4 = device manager\r
2762 // 5 = boot maintenance manager\r
2763 //\r
2764 if (gCallbackKey != 0) {\r
2765 REPORT_STATUS_CODE (\r
2766 EFI_PROGRESS_CODE,\r
2767 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
2768 );\r
2769 }\r
2770\r
2771 //\r
2772 // Based on the key that was set, we can determine what to do\r
2773 //\r
2774 switch (gCallbackKey) {\r
2775 //\r
2776 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
2777 // describe to their customers in documentation how to find their setup information (namely\r
2778 // under the device manager and specific buckets)\r
2779 //\r
2780 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager\r
2781 //\r
2782 case FRONT_PAGE_KEY_CONTINUE:\r
2783\r
2784 //\r
2785 // User hit continue\r
2786 //\r
2787 break;\r
2788\r
2789 case FRONT_PAGE_KEY_LANGUAGE:\r
2790\r
2791 //\r
2792 // User made a language setting change - display front page again\r
2793 //\r
2794 break;\r
2795\r
2796 case FRONT_PAGE_KEY_BOOT_MANAGER:\r
4139580d
SL
2797 //\r
2798 // Remove the installed BootMaint HiiPackages when exit.\r
2799 //\r
2800 FreeBMPackage ();\r
3cbfba02
DW
2801\r
2802 //\r
2803 // User chose to run the Boot Manager\r
2804 //\r
2805 CallBootManager ();\r
4139580d
SL
2806 \r
2807 //\r
2808 // Reinstall BootMaint HiiPackages after exiting from Boot Manager.\r
2809 //\r
2810 InitBMPackage ();\r
3cbfba02
DW
2811 break;\r
2812\r
2813 case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
2814\r
2815 //\r
2816 // Display the Device Manager\r
2817 //\r
2818 do {\r
2819 CallDeviceManager ();\r
2820 } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);\r
2821 break;\r
2822\r
2823 case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
2824\r
2825 //\r
2826 // Display the Boot Maintenance Manager\r
2827 //\r
2828 BdsStartBootMaint ();\r
2829 break;\r
2830 }\r
2831\r
2832 } while (((UINTN)gCallbackKey) != FRONT_PAGE_KEY_CONTINUE);\r
2833\r
2834 //\r
2835 //Will leave browser, check any reset required change is applied? if yes, reset system\r
2836 //\r
2837 SetupResetReminder ();\r
4139580d
SL
2838 //\r
2839 // Remove the installed BootMaint HiiPackages when exit.\r
2840 //\r
2841 FreeBMPackage ();\r
3cbfba02
DW
2842\r
2843Exit:\r
2844 //\r
2845 // Automatically load current entry\r
2846 // Note: The following lines of code only execute when Auto boot\r
2847 // takes affect\r
2848 //\r
2849 PERF_END (NULL, "BdsTimeOut", "BDS", 0);\r
2850}\r
2851\r
2852\r
2853VOID \r
2854BootIntoFirmwareInterface(\r
2855VOID\r
2856)\r
2857{\r
2858 EFI_STATUS Status;\r
2859 UINTN DataSize;\r
2860 UINT16 Timeout; \r
2861 UINT64 OsIndication;\r
2862\r
2863 \r
2864 OsIndication = 0;\r
2865 DataSize = sizeof(UINT64);\r
2866 Status = gRT->GetVariable (\r
2867 L"OsIndications",\r
2868 &gEfiGlobalVariableGuid,\r
2869 NULL,\r
2870 &DataSize,\r
2871 &OsIndication\r
2872 );\r
2873 \r
2874 DEBUG ((EFI_D_INFO, "OSIndication Variable Value %d\n", OsIndication));\r
2875 //\r
2876 //Goto FrontPage directly when bit EFI_OS_INDICATIONS_BOOT_TO_FW_UI in OSIndication Variable is setted.\r
2877 // \r
2878 if (!EFI_ERROR(Status) && (OsIndication != 0)) { \r
2879 Timeout = 0xffff;\r
2880 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
2881 }\r
2882}\r
2883\r
2884\r
2885EFI_STATUS\r
2886PlatformBdsConnectSimpleConsole (\r
2887 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
2888)\r
2889{\r
2890 EFI_STATUS Status;\r
2891 UINTN Index;\r
2892 EFI_DEVICE_PATH_PROTOCOL *VarConout;\r
2893 EFI_DEVICE_PATH_PROTOCOL *VarConin;\r
2894 UINTN DevicePathSize;\r
2895\r
2896\r
2897 Index = 0;\r
2898 Status = EFI_SUCCESS;\r
2899 DevicePathSize = 0;\r
2900 VarConout = BdsLibGetVariableAndSize (\r
2901 L"ConOut",\r
2902 &gEfiGlobalVariableGuid,\r
2903 &DevicePathSize\r
2904 );\r
2905 VarConin = BdsLibGetVariableAndSize (\r
2906 L"ConIn",\r
2907 &gEfiGlobalVariableGuid,\r
2908 &DevicePathSize\r
2909 );\r
2910 if (VarConout == NULL || VarConin == NULL) {\r
2911 //\r
2912 // Have chance to connect the platform default console,\r
2e182e30 2913 // the platform default console is the minimum device group\r
3cbfba02
DW
2914 // the platform should support\r
2915 //\r
2916 while (PlatformConsole[Index].DevicePath != NULL) {\r
2917\r
2918 //\r
2919 // Update the console variable with the connect type\r
2920 //\r
2921 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
2922 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
2923 }\r
2924\r
2925 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
2926 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
2927 }\r
2928\r
2929 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
2930 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
2931 }\r
2932\r
2933 Index ++;\r
2934 }\r
2935 }\r
2936\r
2937 //\r
2938 // Connect ConIn first to give keyboard time to parse hot key event.\r
2939 //\r
2940 Status = BdsLibConnectConsoleVariable (L"ConIn");\r
2941 if (EFI_ERROR (Status)) {\r
2942 return Status;\r
2943 }\r
2944\r
2945 //\r
2946 // Make sure we have at least one active VGA, and have the right\r
2947 // active VGA in console variable\r
2948 //\r
2949 Status = PlatformBdsForceActiveVga ();\r
2950\r
2951 //\r
2952 // It seems impossible not to have any ConOut device on platform,\r
2953 // so we check the status here.\r
2954 //\r
2955 Status = BdsLibConnectConsoleVariable (L"ConOut");\r
2956 if (EFI_ERROR (Status)) {\r
2957 return Status;\r
2958 }\r
2959\r
2960 return EFI_SUCCESS;\r
2961}\r
2962\r
2963\r
2964/**\r
2965 Timer handler to convert the key from USB.\r
2966\r
2967 @param Event Indicates the event that invoke this function.\r
2968 @param Context Indicates the calling context.\r
2969**/\r
2970VOID\r
2971EFIAPI\r
2972HotKeyTimerHandler (\r
2973 IN EFI_EVENT Event,\r
2974 IN VOID *Context\r
2975 )\r
2976{\r
2977 EFI_STATUS Status;\r
2978 EFI_INPUT_KEY Key;\r
2979\r
2980 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
2981 if (EFI_ERROR (Status)) {\r
2982 return;\r
2983 }\r
2984\r
2985 switch(Key.ScanCode) {\r
2986 case SCAN_F2:\r
2987 gHotKey = 0;\r
2988 mHotKeyPressed = TRUE;\r
2989 break;\r
2990\r
2991 case SCAN_F5:\r
2992 gHotKey = FRONT_PAGE_KEY_DEVICE_MANAGER;\r
2993 mHotKeyPressed = TRUE;\r
2994 break;\r
2995\r
2996 case SCAN_F7:\r
2997 gHotKey = FRONT_PAGE_KEY_BOOT_MANAGER;\r
2998 mHotKeyPressed = TRUE;\r
2999 break;\r
3000\r
3001 case SCAN_F9:\r
3002 gHotKey = FRONT_PAGE_KEY_BOOT_MAINTAIN;\r
3003 mHotKeyPressed = TRUE;\r
3004 break;\r
3005 }\r
3006\r
3007 if (mHotKeyPressed) {\r
3008 gBS->SetTimer (\r
3009 mHotKeyTimerEvent,\r
3010 TimerCancel,\r
3011 0\r
3012 );\r
3013 gBS->CloseEvent (mHotKeyTimerEvent);\r
3014 mHotKeyTimerEvent = NULL;\r
3015 }\r
3016\r
3017 return;\r
3018}\r
3019\r
3020\r
3021/**\r
3022 Callback function for SimpleTextInEx protocol install events\r
3023\r
3024 @param Event the event that is signaled.\r
3025 @param Context not used here.\r
3026\r
3027**/\r
3028VOID\r
3029EFIAPI\r
3030HitHotkeyEvent (\r
3031 IN EFI_EVENT Event,\r
3032 IN VOID *Context\r
3033 )\r
3034{\r
3035 EFI_STATUS Status;\r
3036\r
3037 Status = gBS->CloseEvent(mHitHotkeyEvent);\r
3038 if (EFI_ERROR (Status)) {\r
3039 return;\r
3040 }\r
3041 Status = gBS->CreateEvent (\r
3042 EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
3043 TPL_NOTIFY,\r
3044 HotKeyTimerHandler,\r
3045 NULL,\r
3046 &mHotKeyTimerEvent\r
3047 );\r
3048 if (EFI_ERROR (Status)) {\r
3049 return;\r
3050 }\r
3051 Status = gBS->SetTimer (\r
3052 mHotKeyTimerEvent,\r
3053 TimerPeriodic,\r
3054 KEYBOARD_TIMER_INTERVAL\r
3055 );\r
3056 if (EFI_ERROR (Status)) {\r
3057 return;\r
3058 }\r
3059\r
3060 return;\r
3061}\r
3062\r
3063\r
3064VOID\r
3065EFIAPI\r
3066PlatformBdsInitHotKeyEvent (\r
3067 VOID\r
3068 )\r
3069{\r
3070 EFI_STATUS Status;\r
3071\r
3072 //\r
3073 // Register Protocol notify for Hotkey service\r
3074 //\r
3075 Status = gBS->CreateEvent (\r
3076 EVT_NOTIFY_SIGNAL,\r
3077 TPL_CALLBACK,\r
3078 HitHotkeyEvent,\r
3079 NULL,\r
3080 &mHitHotkeyEvent\r
3081 );\r
3082 ASSERT_EFI_ERROR (Status);\r
3083\r
3084 //\r
3085 // Register for protocol notifications on this event\r
3086 //\r
3087 Status = gBS->RegisterProtocolNotify (\r
3088 &gEfiSimpleTextInputExProtocolGuid,\r
3089 mHitHotkeyEvent,\r
3090 &mHitHotkeyRegistration\r
3091 );\r
3092 ASSERT_EFI_ERROR (Status);\r
3093}\r