]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
OvmfPkg: BDS: remove historic (now defunct) boot mode hack
[mirror_edk2.git] / OvmfPkg / Library / PlatformBdsLib / BdsPlatform.c
CommitLineData
49ba9447 1/** @file\r
2 Platform BDS customizations.\r
3\r
863986b3 4 Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
56d7640a 5 This program and the accompanying materials\r
49ba9447 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. 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
13**/\r
14\r
15#include "BdsPlatform.h"\r
2cd086a6 16#include "QemuBootOrder.h"\r
49ba9447 17\r
18\r
40f2c454 19//\r
20// Global data\r
21//\r
22\r
23VOID *mEfiDevPathNotifyReg;\r
24EFI_EVENT mEfiDevPathEvent;\r
9607962d 25VOID *mEmuVariableEventReg;\r
26EFI_EVENT mEmuVariableEvent;\r
e955462b 27BOOLEAN mDetectVgaOnly;\r
28\r
29\r
30//\r
31// Type definitions\r
32//\r
33\r
34typedef\r
35EFI_STATUS\r
36(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(\r
37 IN EFI_HANDLE Handle,\r
38 IN VOID *Instance,\r
39 IN VOID *Context\r
40 );\r
41\r
42/**\r
43 @param[in] Handle - Handle of PCI device instance\r
44 @param[in] PciIo - PCI IO protocol instance\r
45 @param[in] Pci - PCI Header register block\r
46**/\r
47typedef\r
48EFI_STATUS\r
49(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(\r
50 IN EFI_HANDLE Handle,\r
51 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
52 IN PCI_TYPE00 *Pci\r
53 );\r
40f2c454 54\r
55\r
56//\r
57// Function prototypes\r
58//\r
59\r
e955462b 60EFI_STATUS\r
61VisitAllInstancesOfProtocol (\r
62 IN EFI_GUID *Id,\r
63 IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
64 IN VOID *Context\r
65 );\r
66\r
67EFI_STATUS\r
68VisitAllPciInstancesOfProtocol (\r
69 IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
70 );\r
71\r
40f2c454 72VOID\r
73InstallDevicePathCallback (\r
74 VOID\r
75 );\r
76\r
49ba9447 77//\r
78// BDS Platform Functions\r
79//\r
80VOID\r
81EFIAPI\r
82PlatformBdsInit (\r
370ec7f1 83 VOID\r
49ba9447 84 )\r
85/*++\r
86\r
87Routine Description:\r
88\r
89 Platform Bds init. Incude the platform firmware vendor, revision\r
90 and so crc check.\r
91\r
92Arguments:\r
93\r
49ba9447 94Returns:\r
95\r
96 None.\r
97\r
98--*/\r
99{\r
100 DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));\r
40f2c454 101 InstallDevicePathCallback ();\r
49ba9447 102}\r
103\r
104\r
105EFI_STATUS\r
106ConnectRootBridge (\r
107 VOID\r
108 )\r
109/*++\r
110\r
111Routine Description:\r
112\r
113 Connect RootBridge\r
114\r
115Arguments:\r
116\r
117 None.\r
118\r
119Returns:\r
120\r
121 EFI_SUCCESS - Connect RootBridge successfully.\r
122 EFI_STATUS - Connect RootBridge fail.\r
123\r
124--*/\r
125{\r
126 EFI_STATUS Status;\r
127 EFI_HANDLE RootHandle;\r
128\r
129 //\r
130 // Make all the PCI_IO protocols on PCI Seg 0 show up\r
131 //\r
132 BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r
133\r
134 Status = gBS->LocateDevicePath (\r
135 &gEfiDevicePathProtocolGuid,\r
136 &gPlatformRootBridges[0],\r
137 &RootHandle\r
138 );\r
139 if (EFI_ERROR (Status)) {\r
140 return Status;\r
141 }\r
142\r
143 Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r
144 if (EFI_ERROR (Status)) {\r
145 return Status;\r
146 }\r
147\r
148 return EFI_SUCCESS;\r
149}\r
150\r
151\r
152EFI_STATUS\r
153PrepareLpcBridgeDevicePath (\r
154 IN EFI_HANDLE DeviceHandle\r
155 )\r
156/*++\r
157\r
158Routine Description:\r
159\r
160 Add IsaKeyboard to ConIn,\r
161 add IsaSerial to ConOut, ConIn, ErrOut.\r
162 LPC Bridge: 06 01 00\r
163\r
164Arguments:\r
165\r
166 DeviceHandle - Handle of PCIIO protocol.\r
167\r
168Returns:\r
169\r
170 EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.\r
171 EFI_STATUS - No LPC bridge is added.\r
172\r
173--*/\r
174{\r
175 EFI_STATUS Status;\r
176 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
177 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
178 CHAR16 *DevPathStr;\r
179\r
180 DevicePath = NULL;\r
181 Status = gBS->HandleProtocol (\r
182 DeviceHandle,\r
183 &gEfiDevicePathProtocolGuid,\r
184 (VOID*)&DevicePath\r
185 );\r
186 if (EFI_ERROR (Status)) {\r
187 return Status;\r
188 }\r
189 TempDevicePath = DevicePath;\r
190\r
191 //\r
192 // Register Keyboard\r
193 //\r
194 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
195\r
196 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
197\r
198 //\r
199 // Register COM1\r
200 //\r
201 DevicePath = TempDevicePath;\r
202 gPnp16550ComPortDeviceNode.UID = 0;\r
203\r
204 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
205 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
206 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
207\r
208 //\r
209 // Print Device Path\r
210 //\r
211 DevPathStr = DevicePathToStr(DevicePath);\r
863986b3
RN
212 if (DevPathStr != NULL) {\r
213 DEBUG((\r
214 EFI_D_INFO,\r
215 "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r
216 __LINE__,\r
217 gPnp16550ComPortDeviceNode.UID + 1,\r
218 DevPathStr\r
219 ));\r
220 FreePool(DevPathStr);\r
221 }\r
49ba9447 222\r
223 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
224 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
225 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
226\r
227 //\r
228 // Register COM2\r
229 //\r
230 DevicePath = TempDevicePath;\r
231 gPnp16550ComPortDeviceNode.UID = 1;\r
232\r
233 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
234 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
235 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
236\r
237 //\r
238 // Print Device Path\r
239 //\r
240 DevPathStr = DevicePathToStr(DevicePath);\r
863986b3
RN
241 if (DevPathStr != NULL) {\r
242 DEBUG((\r
243 EFI_D_INFO,\r
244 "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r
245 __LINE__,\r
246 gPnp16550ComPortDeviceNode.UID + 1,\r
247 DevPathStr\r
248 ));\r
249 FreePool(DevPathStr);\r
250 }\r
49ba9447 251\r
252 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
253 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
254 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
255\r
256 return EFI_SUCCESS;\r
257}\r
258\r
259EFI_STATUS\r
260GetGopDevicePath (\r
261 IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
262 OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
263 )\r
264{\r
265 UINTN Index;\r
266 EFI_STATUS Status;\r
267 EFI_HANDLE PciDeviceHandle;\r
268 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
269 EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r
270 UINTN GopHandleCount;\r
271 EFI_HANDLE *GopHandleBuffer;\r
272\r
273 if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
274 return EFI_INVALID_PARAMETER;\r
275 }\r
276\r
277 //\r
278 // Initialize the GopDevicePath to be PciDevicePath\r
279 //\r
280 *GopDevicePath = PciDevicePath;\r
281 TempPciDevicePath = PciDevicePath;\r
282\r
283 Status = gBS->LocateDevicePath (\r
284 &gEfiDevicePathProtocolGuid,\r
285 &TempPciDevicePath,\r
286 &PciDeviceHandle\r
287 );\r
288 if (EFI_ERROR (Status)) {\r
289 return Status;\r
290 }\r
291\r
292 //\r
293 // Try to connect this handle, so that GOP dirver could start on this\r
294 // device and create child handles with GraphicsOutput Protocol installed\r
295 // on them, then we get device paths of these child handles and select\r
296 // them as possible console device.\r
297 //\r
298 gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r
299\r
300 Status = gBS->LocateHandleBuffer (\r
301 ByProtocol,\r
302 &gEfiGraphicsOutputProtocolGuid,\r
303 NULL,\r
304 &GopHandleCount,\r
305 &GopHandleBuffer\r
306 );\r
307 if (!EFI_ERROR (Status)) {\r
308 //\r
309 // Add all the child handles as possible Console Device\r
310 //\r
311 for (Index = 0; Index < GopHandleCount; Index++) {\r
312 Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
313 if (EFI_ERROR (Status)) {\r
314 continue;\r
315 }\r
316 if (CompareMem (\r
317 PciDevicePath,\r
318 TempDevicePath,\r
319 GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
320 ) == 0) {\r
321 //\r
322 // In current implementation, we only enable one of the child handles\r
323 // as console device, i.e. sotre one of the child handle's device\r
324 // path to variable "ConOut"\r
325 // In futhure, we could select all child handles to be console device\r
326 //\r
327\r
328 *GopDevicePath = TempDevicePath;\r
329\r
330 //\r
331 // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
332 // Add the integrity GOP device path.\r
333 //\r
334 BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r
335 BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r
336 }\r
337 }\r
338 gBS->FreePool (GopHandleBuffer);\r
339 }\r
340\r
341 return EFI_SUCCESS;\r
342}\r
343\r
344EFI_STATUS\r
345PreparePciVgaDevicePath (\r
346 IN EFI_HANDLE DeviceHandle\r
347 )\r
348/*++\r
349\r
350Routine Description:\r
351\r
352 Add PCI VGA to ConOut.\r
353 PCI VGA: 03 00 00\r
354\r
355Arguments:\r
356\r
357 DeviceHandle - Handle of PCIIO protocol.\r
358\r
359Returns:\r
360\r
361 EFI_SUCCESS - PCI VGA is added to ConOut.\r
362 EFI_STATUS - No PCI VGA device is added.\r
363\r
364--*/\r
365{\r
366 EFI_STATUS Status;\r
367 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
368 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
369\r
370 DevicePath = NULL;\r
371 Status = gBS->HandleProtocol (\r
372 DeviceHandle,\r
373 &gEfiDevicePathProtocolGuid,\r
374 (VOID*)&DevicePath\r
375 );\r
376 if (EFI_ERROR (Status)) {\r
377 return Status;\r
378 }\r
379\r
380 GetGopDevicePath (DevicePath, &GopDevicePath);\r
381 DevicePath = GopDevicePath;\r
382\r
383 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
384\r
385 return EFI_SUCCESS;\r
386}\r
387\r
388EFI_STATUS\r
389PreparePciSerialDevicePath (\r
390 IN EFI_HANDLE DeviceHandle\r
391 )\r
392/*++\r
393\r
394Routine Description:\r
395\r
396 Add PCI Serial to ConOut, ConIn, ErrOut.\r
397 PCI Serial: 07 00 02\r
398\r
399Arguments:\r
400\r
401 DeviceHandle - Handle of PCIIO protocol.\r
402\r
403Returns:\r
404\r
405 EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
406 EFI_STATUS - No PCI Serial device is added.\r
407\r
408--*/\r
409{\r
410 EFI_STATUS Status;\r
411 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
412\r
413 DevicePath = NULL;\r
414 Status = gBS->HandleProtocol (\r
415 DeviceHandle,\r
416 &gEfiDevicePathProtocolGuid,\r
417 (VOID*)&DevicePath\r
418 );\r
419 if (EFI_ERROR (Status)) {\r
420 return Status;\r
421 }\r
422\r
423 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
424 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
425\r
426 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
427 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
428 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
429\r
430 return EFI_SUCCESS;\r
431}\r
432\r
433EFI_STATUS\r
e955462b 434VisitAllInstancesOfProtocol (\r
435 IN EFI_GUID *Id,\r
436 IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
437 IN VOID *Context\r
49ba9447 438 )\r
49ba9447 439{\r
440 EFI_STATUS Status;\r
441 UINTN HandleCount;\r
442 EFI_HANDLE *HandleBuffer;\r
443 UINTN Index;\r
e955462b 444 VOID *Instance;\r
49ba9447 445\r
446 //\r
447 // Start to check all the PciIo to find all possible device\r
448 //\r
449 HandleCount = 0;\r
450 HandleBuffer = NULL;\r
451 Status = gBS->LocateHandleBuffer (\r
452 ByProtocol,\r
e955462b 453 Id,\r
49ba9447 454 NULL,\r
455 &HandleCount,\r
456 &HandleBuffer\r
457 );\r
458 if (EFI_ERROR (Status)) {\r
459 return Status;\r
460 }\r
461\r
462 for (Index = 0; Index < HandleCount; Index++) {\r
e955462b 463 Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);\r
49ba9447 464 if (EFI_ERROR (Status)) {\r
465 continue;\r
466 }\r
467\r
e955462b 468 Status = (*CallBackFunction) (\r
469 HandleBuffer[Index],\r
470 Instance,\r
471 Context\r
472 );\r
473 }\r
49ba9447 474\r
e955462b 475 gBS->FreePool (HandleBuffer);\r
607ca510 476\r
e955462b 477 return EFI_SUCCESS;\r
478}\r
479\r
480\r
481EFI_STATUS\r
482EFIAPI\r
483VisitingAPciInstance (\r
484 IN EFI_HANDLE Handle,\r
485 IN VOID *Instance,\r
486 IN VOID *Context\r
487 )\r
488{\r
489 EFI_STATUS Status;\r
490 EFI_PCI_IO_PROTOCOL *PciIo;\r
491 PCI_TYPE00 Pci;\r
492\r
493 PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;\r
494\r
495 //\r
496 // Check for all PCI device\r
497 //\r
498 Status = PciIo->Pci.Read (\r
499 PciIo,\r
500 EfiPciIoWidthUint32,\r
501 0,\r
502 sizeof (Pci) / sizeof (UINT32),\r
503 &Pci\r
504 );\r
505 if (EFI_ERROR (Status)) {\r
506 return Status;\r
507 }\r
508\r
7d9cf3f2 509 return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (\r
e955462b 510 Handle,\r
511 PciIo,\r
512 &Pci\r
513 );\r
514\r
515}\r
516\r
517\r
518\r
519EFI_STATUS\r
520VisitAllPciInstances (\r
521 IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
522 )\r
523{\r
524 return VisitAllInstancesOfProtocol (\r
525 &gEfiPciIoProtocolGuid,\r
526 VisitingAPciInstance,\r
7d9cf3f2 527 (VOID*)(UINTN) CallBackFunction\r
e955462b 528 );\r
529}\r
530\r
531\r
532/**\r
533 Do platform specific PCI Device check and add them to\r
534 ConOut, ConIn, ErrOut.\r
535\r
536 @param[in] Handle - Handle of PCI device instance\r
537 @param[in] PciIo - PCI IO protocol instance\r
538 @param[in] Pci - PCI Header register block\r
539\r
540 @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
541 @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
542\r
543**/\r
544EFI_STATUS\r
8861fc79 545EFIAPI\r
e955462b 546DetectAndPreparePlatformPciDevicePath (\r
547 IN EFI_HANDLE Handle,\r
548 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
549 IN PCI_TYPE00 *Pci\r
550 )\r
551{\r
552 EFI_STATUS Status;\r
553\r
554 Status = PciIo->Attributes (\r
555 PciIo,\r
556 EfiPciIoAttributeOperationEnable,\r
557 EFI_PCI_DEVICE_ENABLE,\r
558 NULL\r
559 );\r
560 ASSERT_EFI_ERROR (Status);\r
561\r
562 if (!mDetectVgaOnly) {\r
563 //\r
564 // Here we decide whether it is LPC Bridge\r
565 //\r
566 if ((IS_PCI_LPC (Pci)) ||\r
567 ((IS_PCI_ISA_PDECODE (Pci)) &&\r
568 (Pci->Hdr.VendorId == 0x8086) &&\r
569 (Pci->Hdr.DeviceId == 0x7000)\r
570 )\r
571 ) {\r
49ba9447 572 //\r
e955462b 573 // Add IsaKeyboard to ConIn,\r
574 // add IsaSerial to ConOut, ConIn, ErrOut\r
49ba9447 575 //\r
e955462b 576 DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));\r
577 PrepareLpcBridgeDevicePath (Handle);\r
578 return EFI_SUCCESS;\r
49ba9447 579 }\r
49ba9447 580 //\r
e955462b 581 // Here we decide which Serial device to enable in PCI bus\r
49ba9447 582 //\r
e955462b 583 if (IS_PCI_16550SERIAL (Pci)) {\r
49ba9447 584 //\r
e955462b 585 // Add them to ConOut, ConIn, ErrOut.\r
49ba9447 586 //\r
e955462b 587 DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));\r
588 PreparePciSerialDevicePath (Handle);\r
589 return EFI_SUCCESS;\r
49ba9447 590 }\r
591 }\r
592\r
e955462b 593 //\r
594 // Here we decide which VGA device to enable in PCI bus\r
595 //\r
596 if (IS_PCI_VGA (Pci)) {\r
597 //\r
598 // Add them to ConOut.\r
599 //\r
600 DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));\r
601 PreparePciVgaDevicePath (Handle);\r
602 return EFI_SUCCESS;\r
603 }\r
49ba9447 604\r
e955462b 605 return Status;\r
606}\r
607\r
608\r
609/**\r
610 Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
611\r
612 @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.\r
613\r
614 @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
615 @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
616\r
617**/\r
618EFI_STATUS\r
619DetectAndPreparePlatformPciDevicePaths (\r
620 BOOLEAN DetectVgaOnly\r
621 )\r
622{\r
623 mDetectVgaOnly = DetectVgaOnly;\r
624 return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r
49ba9447 625}\r
626\r
627\r
628EFI_STATUS\r
629PlatformBdsConnectConsole (\r
630 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
631 )\r
632/*++\r
633\r
634Routine Description:\r
635\r
636 Connect the predefined platform default console device. Always try to find\r
637 and enable the vga device if have.\r
638\r
639Arguments:\r
640\r
641 PlatformConsole - Predfined platform default console device array.\r
642\r
643Returns:\r
644\r
645 EFI_SUCCESS - Success connect at least one ConIn and ConOut\r
646 device, there must have one ConOut device is\r
647 active vga device.\r
648\r
649 EFI_STATUS - Return the status of\r
650 BdsLibConnectAllDefaultConsoles ()\r
651\r
652--*/\r
653{\r
654 EFI_STATUS Status;\r
655 UINTN Index;\r
656 EFI_DEVICE_PATH_PROTOCOL *VarConout;\r
657 EFI_DEVICE_PATH_PROTOCOL *VarConin;\r
658 UINTN DevicePathSize;\r
659\r
660 //\r
661 // Connect RootBridge\r
662 //\r
49ba9447 663 VarConout = BdsLibGetVariableAndSize (\r
664 VarConsoleOut,\r
665 &gEfiGlobalVariableGuid,\r
666 &DevicePathSize\r
667 );\r
668 VarConin = BdsLibGetVariableAndSize (\r
669 VarConsoleInp,\r
670 &gEfiGlobalVariableGuid,\r
671 &DevicePathSize\r
672 );\r
673\r
674 if (VarConout == NULL || VarConin == NULL) {\r
675 //\r
676 // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
677 //\r
e955462b 678 DetectAndPreparePlatformPciDevicePaths (FALSE);\r
49ba9447 679\r
680 //\r
681 // Have chance to connect the platform default console,\r
682 // the platform default console is the minimue device group\r
683 // the platform should support\r
684 //\r
685 for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r
686 //\r
687 // Update the console variable with the connect type\r
688 //\r
689 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
690 BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r
691 }\r
692 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
693 BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r
694 }\r
695 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
696 BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r
697 }\r
698 }\r
699 } else {\r
700 //\r
701 // Only detect VGA device and add them to ConOut\r
702 //\r
e955462b 703 DetectAndPreparePlatformPciDevicePaths (TRUE);\r
49ba9447 704 }\r
705\r
706 //\r
707 // Connect the all the default console with current cosole variable\r
708 //\r
709 Status = BdsLibConnectAllDefaultConsoles ();\r
710 if (EFI_ERROR (Status)) {\r
711 return Status;\r
712 }\r
713\r
714 return EFI_SUCCESS;\r
715}\r
716\r
717\r
718VOID\r
719PciInitialization (\r
720 )\r
721{\r
722 //\r
40f2c454 723 // Bus 0, Device 0, Function 0 - Host to PCI Bridge\r
724 //\r
725 PciWrite8 (PCI_LIB_ADDRESS (0, 0, 0, 0x3c), 0x00);\r
726\r
727 //\r
728 // Bus 0, Device 1, Function 0 - PCI to ISA Bridge\r
49ba9447 729 //\r
40f2c454 730 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00);\r
05c89c7f 731 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // LNKA routing target\r
732 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // LNKB routing target\r
733 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // LNKC routing target\r
734 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // LNKD routing target\r
49ba9447 735\r
736 //\r
40f2c454 737 // Bus 0, Device 1, Function 1 - IDE Controller\r
49ba9447 738 //\r
40f2c454 739 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x3c), 0x00);\r
740 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x0d), 0x40);\r
49ba9447 741\r
742 //\r
40f2c454 743 // Bus 0, Device 1, Function 3 - Power Managment Controller\r
49ba9447 744 //\r
05c89c7f 745 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x09);\r
746 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); // INTA\r
49ba9447 747\r
748 //\r
40f2c454 749 // Bus 0, Device 2, Function 0 - Video Controller\r
49ba9447 750 //\r
40f2c454 751 PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x00);\r
49ba9447 752\r
753 //\r
40f2c454 754 // Bus 0, Device 3, Function 0 - Network Controller\r
49ba9447 755 //\r
05c89c7f 756 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0a);\r
757 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); // INTA (-> LNKC)\r
49ba9447 758\r
759 //\r
a5595b1e 760 // Bus 0, Device 5, Function 0 - RAM Memory\r
49ba9447 761 //\r
05c89c7f 762 PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0b);\r
763 PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3d), 0x01); // INTA (-> LNKA)\r
49ba9447 764}\r
765\r
766\r
9b167857 767VOID\r
768AcpiInitialization (\r
769 VOID\r
770 )\r
771{\r
772 //\r
773 // Set ACPI SCI_EN bit in PMCNTRL\r
774 //\r
775 IoOr16 ((PciRead32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40)) & ~BIT0) + 4, BIT0);\r
776}\r
777\r
778\r
14b21de9 779EFI_STATUS\r
780EFIAPI\r
781ConnectRecursivelyIfPciMassStorage (\r
782 IN EFI_HANDLE Handle,\r
783 IN EFI_PCI_IO_PROTOCOL *Instance,\r
784 IN PCI_TYPE00 *PciHeader\r
785 )\r
786{\r
787 EFI_STATUS Status;\r
788 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
789 CHAR16 *DevPathStr;\r
790\r
791 if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {\r
792 DevicePath = NULL;\r
793 Status = gBS->HandleProtocol (\r
794 Handle,\r
795 &gEfiDevicePathProtocolGuid,\r
796 (VOID*)&DevicePath\r
797 );\r
798 if (EFI_ERROR (Status)) {\r
799 return Status;\r
800 }\r
801\r
802 //\r
803 // Print Device Path\r
804 //\r
805 DevPathStr = DevicePathToStr (DevicePath);\r
863986b3
RN
806 if (DevPathStr != NULL) {\r
807 DEBUG((\r
808 EFI_D_INFO,\r
809 "Found Mass Storage device: %s\n",\r
810 DevPathStr\r
811 ));\r
812 FreePool(DevPathStr);\r
813 }\r
14b21de9 814\r
815 Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
816 if (EFI_ERROR (Status)) {\r
817 return Status;\r
818 }\r
819\r
820 }\r
821\r
822 return EFI_SUCCESS;\r
823}\r
824\r
825\r
9607962d 826/**\r
827 This notification function is invoked when the\r
828 EMU Variable FVB has been changed.\r
829\r
830 @param Event The event that occured\r
831 @param Context For EFI compatiblity. Not used.\r
832\r
833**/\r
834VOID\r
835EFIAPI\r
836EmuVariablesUpdatedCallback (\r
837 IN EFI_EVENT Event,\r
838 IN VOID *Context\r
839 )\r
840{\r
841 DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));\r
842 UpdateNvVarsOnFileSystem ();\r
843}\r
844\r
845\r
14b21de9 846EFI_STATUS\r
847EFIAPI\r
848VisitingFileSystemInstance (\r
849 IN EFI_HANDLE Handle,\r
850 IN VOID *Instance,\r
851 IN VOID *Context\r
852 )\r
853{\r
854 EFI_STATUS Status;\r
855 STATIC BOOLEAN ConnectedToFileSystem = FALSE;\r
856\r
857 if (ConnectedToFileSystem) {\r
858 return EFI_ALREADY_STARTED;\r
859 }\r
860\r
861 Status = ConnectNvVarsToFileSystem (Handle);\r
862 if (EFI_ERROR (Status)) {\r
863 return Status;\r
864 }\r
865\r
866 ConnectedToFileSystem = TRUE;\r
9607962d 867 mEmuVariableEvent =\r
868 EfiCreateProtocolNotifyEvent (\r
869 &gEfiDevicePathProtocolGuid,\r
870 TPL_CALLBACK,\r
871 EmuVariablesUpdatedCallback,\r
872 NULL,\r
873 &mEmuVariableEventReg\r
874 );\r
875 PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);\r
876\r
14b21de9 877 return EFI_SUCCESS;\r
878}\r
879\r
880\r
881VOID\r
882PlatformBdsRestoreNvVarsFromHardDisk (\r
883 )\r
884{\r
885 VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);\r
886 VisitAllInstancesOfProtocol (\r
887 &gEfiSimpleFileSystemProtocolGuid,\r
888 VisitingFileSystemInstance,\r
889 NULL\r
890 );\r
3d131d1a 891\r
14b21de9 892}\r
893\r
894\r
49ba9447 895VOID\r
896PlatformBdsConnectSequence (\r
897 VOID\r
898 )\r
899/*++\r
900\r
901Routine Description:\r
902\r
903 Connect with predeined platform connect sequence,\r
904 the OEM/IBV can customize with their own connect sequence.\r
905\r
906Arguments:\r
907\r
908 None.\r
909\r
910Returns:\r
911\r
912 None.\r
913\r
914--*/\r
915{\r
916 UINTN Index;\r
917\r
918 DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r
919\r
920 Index = 0;\r
921\r
922 //\r
923 // Here we can get the customized platform connect sequence\r
924 // Notes: we can connect with new variable which record the\r
925 // last time boots connect device path sequence\r
926 //\r
927 while (gPlatformConnectSequence[Index] != NULL) {\r
928 //\r
929 // Build the platform boot option\r
930 //\r
931 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
932 Index++;\r
933 }\r
934\r
935 //\r
936 // Just use the simple policy to connect all devices\r
937 //\r
938 BdsLibConnectAll ();\r
939\r
940 PciInitialization ();\r
9b167857 941 AcpiInitialization ();\r
40f2c454 942\r
943 //\r
944 // Clear the logo after all devices are connected.\r
945 //\r
946 gST->ConOut->ClearScreen (gST->ConOut);\r
49ba9447 947}\r
948\r
949VOID\r
950PlatformBdsGetDriverOption (\r
951 IN OUT LIST_ENTRY *BdsDriverLists\r
952 )\r
953/*++\r
954\r
955Routine Description:\r
956\r
957 Load the predefined driver option, OEM/IBV can customize this\r
958 to load their own drivers\r
959\r
960Arguments:\r
961\r
962 BdsDriverLists - The header of the driver option link list.\r
963\r
964Returns:\r
965\r
966 None.\r
967\r
968--*/\r
969{\r
970 DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));\r
971 return;\r
972}\r
973\r
974VOID\r
975PlatformBdsDiagnostics (\r
976 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
d18476d0 977 IN BOOLEAN QuietBoot,\r
978 IN BASEM_MEMORY_TEST BaseMemoryTest\r
49ba9447 979 )\r
980/*++\r
981\r
982Routine Description:\r
983\r
984 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
985 can customize this fuction to support specific platform diagnostic.\r
986\r
987Arguments:\r
988\r
989 MemoryTestLevel - The memory test intensive level\r
990\r
991 QuietBoot - Indicate if need to enable the quiet boot\r
992\r
d18476d0 993 BaseMemoryTest - A pointer to BaseMemoryTest()\r
994\r
49ba9447 995Returns:\r
996\r
997 None.\r
998\r
999--*/\r
1000{\r
1001 EFI_STATUS Status;\r
1002\r
1003 DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));\r
1004\r
1005 //\r
1006 // Here we can decide if we need to show\r
1007 // the diagnostics screen\r
1008 // Notes: this quiet boot code should be remove\r
1009 // from the graphic lib\r
1010 //\r
1011 if (QuietBoot) {\r
d46f3632 1012 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
49ba9447 1013 //\r
1014 // Perform system diagnostic\r
1015 //\r
d18476d0 1016 Status = BaseMemoryTest (MemoryTestLevel);\r
49ba9447 1017 if (EFI_ERROR (Status)) {\r
1018 DisableQuietBoot ();\r
1019 }\r
1020\r
1021 return ;\r
1022 }\r
1023 //\r
1024 // Perform system diagnostic\r
1025 //\r
d18476d0 1026 Status = BaseMemoryTest (MemoryTestLevel);\r
49ba9447 1027}\r
1028\r
1029\r
1030VOID\r
1031EFIAPI\r
1032PlatformBdsPolicyBehavior (\r
49ba9447 1033 IN OUT LIST_ENTRY *DriverOptionList,\r
d18476d0 1034 IN OUT LIST_ENTRY *BootOptionList,\r
1035 IN PROCESS_CAPSULES ProcessCapsules,\r
1036 IN BASEM_MEMORY_TEST BaseMemoryTest\r
49ba9447 1037 )\r
1038/*++\r
1039\r
1040Routine Description:\r
1041\r
1042 The function will excute with as the platform policy, current policy\r
1043 is driven by boot mode. IBV/OEM can customize this code for their specific\r
1044 policy action.\r
1045\r
1046Arguments:\r
1047\r
49ba9447 1048 DriverOptionList - The header of the driver option link list\r
1049\r
1050 BootOptionList - The header of the boot option link list\r
1051\r
d18476d0 1052 ProcessCapsules - A pointer to ProcessCapsules()\r
1053\r
1054 BaseMemoryTest - A pointer to BaseMemoryTest()\r
1055\r
49ba9447 1056Returns:\r
1057\r
1058 None.\r
1059\r
1060--*/\r
1061{\r
1062 EFI_STATUS Status;\r
1063 UINT16 Timeout;\r
1064 EFI_EVENT UserInputDurationTime;\r
1065 LIST_ENTRY *Link;\r
1066 BDS_COMMON_OPTION *BootOption;\r
1067 UINTN Index;\r
1068 EFI_INPUT_KEY Key;\r
1069 EFI_TPL OldTpl;\r
370ec7f1 1070 EFI_BOOT_MODE BootMode;\r
49ba9447 1071\r
1072 DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r
1073\r
14b21de9 1074 ConnectRootBridge ();\r
1075\r
2590861a
LE
1076 if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {\r
1077 DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "\r
1078 "from disk since flash variables appear to be supported.\n"));\r
1079 } else {\r
1080 //\r
1081 // Try to restore variables from the hard disk early so\r
1082 // they can be used for the other BDS connect operations.\r
1083 //\r
1084 PlatformBdsRestoreNvVarsFromHardDisk ();\r
1085 }\r
14b21de9 1086\r
49ba9447 1087 //\r
1088 // Init the time out value\r
1089 //\r
1090 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
1091\r
1092 //\r
1093 // Load the driver option as the driver option list\r
1094 //\r
1095 PlatformBdsGetDriverOption (DriverOptionList);\r
1096\r
1097 //\r
1098 // Get current Boot Mode\r
1099 //\r
370ec7f1 1100 Status = BdsLibGetBootMode (&BootMode);\r
1101 DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r
49ba9447 1102\r
1103 //\r
1104 // Go the different platform policy with different boot mode\r
1105 // Notes: this part code can be change with the table policy\r
1106 //\r
370ec7f1 1107 ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r
49ba9447 1108 //\r
1109 // Connect platform console\r
1110 //\r
1111 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
1112 if (EFI_ERROR (Status)) {\r
1113 //\r
1114 // Here OEM/IBV can customize with defined action\r
1115 //\r
1116 PlatformBdsNoConsoleAction ();\r
1117 }\r
1118 //\r
1119 // Create a 300ms duration event to ensure user has enough input time to enter Setup\r
1120 //\r
1121 Status = gBS->CreateEvent (\r
1122 EVT_TIMER,\r
1123 0,\r
1124 NULL,\r
1125 NULL,\r
1126 &UserInputDurationTime\r
1127 );\r
1128 ASSERT (Status == EFI_SUCCESS);\r
1129 Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r
1130 ASSERT (Status == EFI_SUCCESS);\r
1131 //\r
1132 // Memory test and Logo show\r
1133 //\r
d18476d0 1134 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
49ba9447 1135\r
1136 //\r
1137 // Perform some platform specific connect sequence\r
1138 //\r
1139 PlatformBdsConnectSequence ();\r
1140\r
52fba289 1141 //\r
1142 // Process QEMU's -kernel command line option\r
1143 //\r
1144 TryRunningQemuKernel ();\r
1145\r
49ba9447 1146 //\r
1147 // Give one chance to enter the setup if we\r
1148 // have the time out\r
1149 //\r
1150 if (Timeout != 0) {\r
1151 //PlatformBdsEnterFrontPage (Timeout, FALSE);\r
1152 }\r
1153\r
1154 DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));\r
1155 BdsLibConnectAll ();\r
1156 BdsLibEnumerateAllBootOption (BootOptionList);\r
1157\r
2cd086a6 1158 SetBootOrderFromQemu (BootOptionList);\r
49ba9447 1159 //\r
de5ae37b
LE
1160 // The BootOrder variable may have changed, reload the in-memory list with\r
1161 // it.\r
49ba9447 1162 //\r
de5ae37b 1163 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
49ba9447 1164\r
1165 //\r
1166 // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r
1167 // BDS should still give user a chance to enter Setup\r
1168 //\r
1169 // Connect first boot option, and then check user input before exit\r
1170 //\r
1171 for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r
1172 BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
1173 if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
1174 //\r
1175 // skip the header of the link list, becuase it has no boot option\r
1176 //\r
1177 continue;\r
1178 } else {\r
1179 //\r
1180 // Make sure the boot option device path connected, but ignore the BBS device path\r
1181 //\r
1182 if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
1183 BdsLibConnectDevicePath (BootOption->DevicePath);\r
1184 }\r
1185 break;\r
1186 }\r
1187 }\r
1188\r
1189 //\r
1190 // Check whether the user input after the duration time has expired\r
1191 //\r
1192 OldTpl = EfiGetCurrentTpl();\r
1193 gBS->RestoreTPL (TPL_APPLICATION);\r
1194 gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r
1195 gBS->CloseEvent (UserInputDurationTime);\r
1196 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
1197 gBS->RaiseTPL (OldTpl);\r
1198\r
1199 if (!EFI_ERROR (Status)) {\r
1200 //\r
1201 // Enter Setup if user input\r
1202 //\r
1203 Timeout = 0xffff;\r
1204 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
1205 }\r
1206\r
1207 return ;\r
1208}\r
1209\r
1210VOID\r
1211EFIAPI\r
1212PlatformBdsBootSuccess (\r
1213 IN BDS_COMMON_OPTION *Option\r
1214 )\r
1215/*++\r
1216\r
1217Routine Description:\r
1218\r
1219 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
1220 return, so the EFI 1.0 specification defines that you will default to an\r
1221 interactive mode and stop processing the BootOrder list in this case. This\r
1222 is alos a platform implementation and can be customized by IBV/OEM.\r
1223\r
1224Arguments:\r
1225\r
1226 Option - Pointer to Boot Option that succeeded to boot.\r
1227\r
1228Returns:\r
1229\r
1230 None.\r
1231\r
1232--*/\r
1233{\r
1234 CHAR16 *TmpStr;\r
1235\r
1236 DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));\r
1237 //\r
1238 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
1239 // select loop then we need to pop up a UI and wait for user input.\r
1240 //\r
1241 TmpStr = Option->StatusString;\r
1242 if (TmpStr != NULL) {\r
1243 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
1244 FreePool (TmpStr);\r
1245 }\r
1246}\r
1247\r
1248VOID\r
1249EFIAPI\r
1250PlatformBdsBootFail (\r
1251 IN BDS_COMMON_OPTION *Option,\r
1252 IN EFI_STATUS Status,\r
1253 IN CHAR16 *ExitData,\r
1254 IN UINTN ExitDataSize\r
1255 )\r
1256/*++\r
1257\r
1258Routine Description:\r
1259\r
1260 Hook point after a boot attempt fails.\r
1261\r
1262Arguments:\r
1263\r
1264 Option - Pointer to Boot Option that failed to boot.\r
1265\r
1266 Status - Status returned from failed boot.\r
1267\r
1268 ExitData - Exit data returned from failed boot.\r
1269\r
1270 ExitDataSize - Exit data size returned from failed boot.\r
1271\r
1272Returns:\r
1273\r
1274 None.\r
1275\r
1276--*/\r
1277{\r
1278 CHAR16 *TmpStr;\r
1279\r
1280 DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));\r
1281\r
1282 //\r
1283 // If Boot returned with failed status then we need to pop up a UI and wait\r
1284 // for user input.\r
1285 //\r
1286 TmpStr = Option->StatusString;\r
1287 if (TmpStr != NULL) {\r
1288 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
1289 FreePool (TmpStr);\r
1290 }\r
1291}\r
1292\r
1293EFI_STATUS\r
1294PlatformBdsNoConsoleAction (\r
1295 VOID\r
1296 )\r
1297/*++\r
1298\r
1299Routine Description:\r
1300\r
1301 This function is remained for IBV/OEM to do some platform action,\r
1302 if there no console device can be connected.\r
1303\r
1304Arguments:\r
1305\r
1306 None.\r
1307\r
1308Returns:\r
1309\r
1310 EFI_SUCCESS - Direct return success now.\r
1311\r
1312--*/\r
1313{\r
1314 DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));\r
1315 return EFI_SUCCESS;\r
1316}\r
1317\r
24cdd14e 1318VOID\r
49ba9447 1319EFIAPI\r
1320PlatformBdsLockNonUpdatableFlash (\r
1321 VOID\r
1322 )\r
1323{\r
1324 DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));\r
24cdd14e 1325 return;\r
49ba9447 1326}\r
40f2c454 1327\r
1328\r
1329/**\r
1330 This notification function is invoked when an instance of the\r
1331 EFI_DEVICE_PATH_PROTOCOL is produced.\r
1332\r
1333 @param Event The event that occured\r
1334 @param Context For EFI compatiblity. Not used.\r
1335\r
1336**/\r
1337VOID\r
1338EFIAPI\r
1339NotifyDevPath (\r
1340 IN EFI_EVENT Event,\r
1341 IN VOID *Context\r
1342 )\r
1343{\r
1344 EFI_HANDLE Handle;\r
1345 EFI_STATUS Status;\r
1346 UINTN BufferSize;\r
1347 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1348 ATAPI_DEVICE_PATH *Atapi;\r
1349\r
1350 //\r
1351 // Examine all new handles\r
1352 //\r
1353 for (;;) {\r
1354 //\r
1355 // Get the next handle\r
1356 //\r
1357 BufferSize = sizeof (Handle);\r
1358 Status = gBS->LocateHandle (\r
1359 ByRegisterNotify,\r
1360 NULL,\r
1361 mEfiDevPathNotifyReg,\r
1362 &BufferSize,\r
1363 &Handle\r
1364 );\r
1365\r
1366 //\r
1367 // If not found, we're done\r
1368 //\r
1369 if (EFI_NOT_FOUND == Status) {\r
1370 break;\r
1371 }\r
1372\r
1373 if (EFI_ERROR (Status)) {\r
1374 continue;\r
1375 }\r
1376\r
1377 //\r
1378 // Get the DevicePath protocol on that handle\r
1379 //\r
1380 Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);\r
1381 ASSERT_EFI_ERROR (Status);\r
1382\r
1383 while (!IsDevicePathEnd (DevPathNode)) {\r
1384 //\r
1385 // Find the handler to dump this device path node\r
1386 //\r
1387 if (\r
1388 (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&\r
1389 (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)\r
1390 ) {\r
1391 Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;\r
1392 PciOr16 (\r
1393 PCI_LIB_ADDRESS (\r
1394 0,\r
1395 1,\r
1396 1,\r
1397 (Atapi->PrimarySecondary == 1) ? 0x42: 0x40\r
1398 ),\r
1399 BIT15\r
1400 );\r
1401 }\r
1402\r
1403 //\r
1404 // Next device path node\r
1405 //\r
1406 DevPathNode = NextDevicePathNode (DevPathNode);\r
1407 }\r
1408 }\r
1409\r
1410 return;\r
1411}\r
1412\r
1413\r
1414VOID\r
1415InstallDevicePathCallback (\r
1416 VOID\r
1417 )\r
1418{\r
1419 DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));\r
1420 mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (\r
1421 &gEfiDevicePathProtocolGuid,\r
1422 TPL_CALLBACK,\r
1423 NotifyDevPath,\r
1424 NULL,\r
1425 &mEfiDevPathNotifyReg\r
1426 );\r
1427}\r
1428\r
24cdd14e
LG
1429/**\r
1430 Lock the ConsoleIn device in system table. All key\r
1431 presses will be ignored until the Password is typed in. The only way to\r
1432 disable the password is to type it in to a ConIn device.\r
1433\r
1434 @param Password Password used to lock ConIn device.\r
1435\r
1436 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
1437 @retval EFI_UNSUPPORTED Password not found\r
1438\r
1439**/\r
1440EFI_STATUS\r
1441EFIAPI\r
1442LockKeyboards (\r
1443 IN CHAR16 *Password\r
1444 )\r
1445{\r
1446 return EFI_UNSUPPORTED;\r
1447}\r
5106d422 1448\r