]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
OvmfPkg/PlatformBootManagerLib: rejuvenate old-style function comments
[mirror_edk2.git] / OvmfPkg / Library / PlatformBootManagerLib / BdsPlatform.c
index 16618a8f57f08636ba62ce5f68cbb8d0d8219092..b155639f3c97096c3a80a40e0c82d1a867ed7f10 100644 (file)
@@ -2,13 +2,13 @@
   Platform BDS customizations.\r
 \r
   Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -37,13 +37,6 @@ CONST UINT8 PciHostIrqs[] = {
   0x0a, 0x0a, 0x0b, 0x0b\r
 };\r
 \r
-//\r
-// Array Size macro\r
-//\r
-#ifndef ARRAY_SIZE\r
-#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))\r
-#endif\r
-\r
 //\r
 // Type definitions\r
 //\r
@@ -335,25 +328,24 @@ SaveS3BootScript (
 //\r
 // BDS Platform Functions\r
 //\r
+/**\r
+  Do the platform init, can be customized by OEM/IBV\r
+\r
+  Possible things that can be done in PlatformBootManagerBeforeConsole:\r
+\r
+  > Update console variable: 1. include hot-plug devices;\r
+  >                          2. Clear ConIn and add SOL for AMT\r
+  > Register new Driver#### or Boot####\r
+  > Register new Key####: e.g.: F12\r
+  > Signal ReadyToLock event\r
+  > Authentication action: 1. connect Auth devices;\r
+  >                        2. Identify auto logon user.\r
+**/\r
 VOID\r
 EFIAPI\r
 PlatformBootManagerBeforeConsole (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Platform Bds init. Include the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   EFI_HANDLE    Handle;\r
   EFI_STATUS    Status;\r
@@ -396,6 +388,12 @@ Returns:
                   NULL);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Dispatch deferred images after EndOfDxe event and ReadyToLock\r
+  // installation.\r
+  //\r
+  EfiBootManagerDispatchDeferredImages ();\r
+\r
   PlatformInitializeConsole (gPlatformConsole);\r
   PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,\r
                 GetFrontPageTimeoutFromQemu ());\r
@@ -430,28 +428,21 @@ ConnectRootBridge (
 }\r
 \r
 \r
+/**\r
+  Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.\r
+\r
+  @param[in] DeviceHandle  Handle of the LPC Bridge device.\r
+\r
+  @retval EFI_SUCCESS  Console devices on the LPC bridge have been added to\r
+                       ConOut, ConIn, and ErrOut.\r
+\r
+  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing\r
+                       from DeviceHandle.\r
+**/\r
 EFI_STATUS\r
 PrepareLpcBridgeDevicePath (\r
   IN EFI_HANDLE                DeviceHandle\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add IsaKeyboard to ConIn,\r
-  add IsaSerial to ConOut, ConIn, ErrOut.\r
-  LPC Bridge: 06 01 00\r
-\r
-Arguments:\r
-\r
-  DeviceHandle            - Handle of PCIIO protocol.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - LPC bridge is added to ConOut, ConIn, and ErrOut.\r
-  EFI_STATUS              - No LPC bridge is added.\r
-\r
---*/\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
@@ -472,7 +463,8 @@ Returns:
   //\r
   // Register Keyboard\r
   //\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
 \r
   EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
 \r
@@ -482,9 +474,12 @@ Returns:
   DevicePath = TempDevicePath;\r
   gPnp16550ComPortDeviceNode.UID = 0;\r
 \r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
 \r
   //\r
   // Print Device Path\r
@@ -511,9 +506,12 @@ Returns:
   DevicePath = TempDevicePath;\r
   gPnp16550ComPortDeviceNode.UID = 1;\r
 \r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
 \r
   //\r
   // Print Device Path\r
@@ -590,7 +588,8 @@ GetGopDevicePath (
     // Add all the child handles as possible Console Device\r
     //\r
     for (Index = 0; Index < GopHandleCount; Index++) {\r
-      Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
+      Status = gBS->HandleProtocol (GopHandleBuffer[Index],\r
+                      &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
       if (EFI_ERROR (Status)) {\r
         continue;\r
       }\r
@@ -609,8 +608,8 @@ GetGopDevicePath (
         *GopDevicePath = TempDevicePath;\r
 \r
         //\r
-        // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
-        // Add the integrity GOP device path.\r
+        // Delete the PCI device's path that added by\r
+        // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.\r
         //\r
         EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL, PciDevicePath);\r
         EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);\r
@@ -622,27 +621,20 @@ GetGopDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Add PCI display to ConOut.\r
+\r
+  @param[in] DeviceHandle  Handle of the PCI display device.\r
+\r
+  @retval EFI_SUCCESS  The PCI display device has been added to ConOut.\r
+\r
+  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing\r
+                       from DeviceHandle.\r
+**/\r
 EFI_STATUS\r
 PreparePciDisplayDevicePath (\r
   IN EFI_HANDLE                DeviceHandle\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add PCI VGA to ConOut.\r
-  PCI VGA: 03 00 00\r
-\r
-Arguments:\r
-\r
-  DeviceHandle            - Handle of PCIIO protocol.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS             - PCI VGA is added to ConOut.\r
-  EFI_STATUS              - No PCI VGA device is added.\r
-\r
---*/\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
@@ -667,27 +659,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-PreparePciSerialDevicePath (\r
-  IN EFI_HANDLE                DeviceHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Add PCI Serial to ConOut, ConIn, ErrOut.\r
-  PCI Serial: 07 00 02\r
-\r
-Arguments:\r
 \r
-  DeviceHandle            - Handle of PCIIO protocol.\r
+  @param[in] DeviceHandle  Handle of the PCI serial device.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS  The PCI serial device has been added to ConOut, ConIn,\r
+                       ErrOut.\r
 \r
-  EFI_SUCCESS             - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
-  EFI_STATUS              - No PCI Serial device is added.\r
-\r
---*/\r
+  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing\r
+                       from DeviceHandle.\r
+**/\r
+EFI_STATUS\r
+PreparePciSerialDevicePath (\r
+  IN EFI_HANDLE                DeviceHandle\r
+  )\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
@@ -702,8 +688,10 @@ Returns:
     return Status;\r
   }\r
 \r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
 \r
   EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
   EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
@@ -819,7 +807,8 @@ VisitAllPciInstances (
   @param[in]  PciIo - PCI IO protocol instance\r
   @param[in]  Pci - PCI Header register block\r
 \r
-  @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+  @retval EFI_SUCCESS - PCI Device check and Console variable update\r
+                        successfully.\r
   @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
 \r
 **/\r
@@ -893,7 +882,8 @@ DetectAndPreparePlatformPciDevicePath (
 \r
   @param[in]  DetectVgaOnly - Only detect VGA device if it's TRUE.\r
 \r
-  @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+  @retval EFI_SUCCESS - PCI Device check and Console variable update\r
+                        successfully.\r
   @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
 \r
 **/\r
@@ -907,21 +897,17 @@ DetectAndPreparePlatformPciDevicePaths (
 }\r
 \r
 \r
+/**\r
+  Connect the predefined platform default console device.\r
+\r
+  Always try to find and enable PCI display devices.\r
+\r
+  @param[in] PlatformConsole  Predefined platform default console device array.\r
+**/\r
 VOID\r
 PlatformInitializeConsole (\r
   IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect the predefined platform default console device. Always try to find\r
-  and enable the vga device if have.\r
-\r
-Arguments:\r
-\r
-  PlatformConsole         - Predefined platform default console device array.\r
---*/\r
 {\r
   UINTN                              Index;\r
   EFI_DEVICE_PATH_PROTOCOL           *VarConout;\r
@@ -930,12 +916,14 @@ Arguments:
   //\r
   // Connect RootBridge\r
   //\r
-  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL);\r
+  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout,\r
+    NULL);\r
   GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);\r
 \r
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
-    // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
+    // Do platform specific PCI Device check and add them to ConOut, ConIn,\r
+    // ErrOut\r
     //\r
     DetectAndPreparePlatformPciDevicePaths (FALSE);\r
 \r
@@ -949,13 +937,16 @@ Arguments:
       // Update the console variable with the connect type\r
       //\r
       if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
-        EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);\r
+        EfiBootManagerUpdateConsoleVariable (ConIn,\r
+          PlatformConsole[Index].DevicePath, NULL);\r
       }\r
       if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
-        EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);\r
+        EfiBootManagerUpdateConsoleVariable (ConOut,\r
+          PlatformConsole[Index].DevicePath, NULL);\r
       }\r
       if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
-        EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);\r
+        EfiBootManagerUpdateConsoleVariable (ErrOut,\r
+          PlatformConsole[Index].DevicePath, NULL);\r
       }\r
     }\r
   } else {\r
@@ -1239,7 +1230,10 @@ ConnectRecursivelyIfPciMassStorage (
       DEBUG((\r
         EFI_D_INFO,\r
         "Found %s device: %s\n",\r
-        IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ? L"Mass Storage" : L"Xen",\r
+        (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ?\r
+         L"Mass Storage" :\r
+         L"Xen"\r
+         ),\r
         DevPathStr\r
         ));\r
       FreePool(DevPathStr);\r
@@ -1327,28 +1321,18 @@ PlatformBdsRestoreNvVarsFromHardDisk (
 \r
 }\r
 \r
+/**\r
+  Connect with predefined platform connect sequence.\r
+\r
+  The OEM/IBV can customize with their own connect sequence.\r
+**/\r
 VOID\r
 PlatformBdsConnectSequence (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect with predefined platform connect sequence,\r
-  the OEM/IBV can customize with their own connect sequence.\r
-\r
-Arguments:\r
-\r
-  None.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
-  UINTN Index;\r
+  UINTN         Index;\r
+  RETURN_STATUS Status;\r
 \r
   DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r
 \r
@@ -1367,11 +1351,14 @@ Returns:
     Index++;\r
   }\r
 \r
-  //\r
-  // Just use the simple policy to connect all devices\r
-  //\r
-  DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n"));\r
-  EfiBootManagerConnectAll ();\r
+  Status = ConnectDevicesFromQemu ();\r
+  if (RETURN_ERROR (Status)) {\r
+    //\r
+    // Just use the simple policy to connect all devices\r
+    //\r
+    DEBUG ((DEBUG_INFO, "EfiBootManagerConnectAll\n"));\r
+    EfiBootManagerConnectAll ();\r
+  }\r
 \r
   PciAcpiInitialization ();\r
 }\r
@@ -1408,20 +1395,24 @@ SaveS3BootScript (
 }\r
 \r
 \r
+/**\r
+  Do the platform specific action after the console is ready\r
+\r
+  Possible things that can be done in PlatformBootManagerAfterConsole:\r
+\r
+  > Console post action:\r
+    > Dynamically switch output mode from 100x31 to 80x25 for certain senarino\r
+    > Signal console ready platform customized event\r
+  > Run diagnostics like memory testing\r
+  > Connect certain devices\r
+  > Dispatch aditional option roms\r
+  > Special boot: e.g.: USB boot, enter UI\r
+**/\r
 VOID\r
 EFIAPI\r
 PlatformBootManagerAfterConsole (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function will execute with as the platform policy, current policy\r
-  is driven by boot mode. IBV/OEM can customize this code for their specific\r
-  policy action.\r
-\r
---*/\r
 {\r
   EFI_BOOT_MODE                      BootMode;\r
 \r
@@ -1442,7 +1433,7 @@ Routine Description:
   // Get current Boot Mode\r
   //\r
   BootMode = GetBootModeHob ();\r
-  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r
+  DEBUG ((DEBUG_INFO, "Boot Mode:%x\n", BootMode));\r
 \r
   //\r
   // Go the different platform policy with different boot mode\r
@@ -1529,7 +1520,8 @@ NotifyDevPath (
     //\r
     // Get the DevicePath protocol on that handle\r
     //\r
-    Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);\r
+    Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,\r
+                    (VOID **)&DevPathNode);\r
     ASSERT_EFI_ERROR (Status);\r
 \r
     while (!IsDevicePathEnd (DevPathNode)) {\r
@@ -1579,7 +1571,8 @@ InstallDevicePathCallback (
 }\r
 \r
 /**\r
-  This function is called each second during the boot manager waits the timeout.\r
+  This function is called each second during the boot manager waits the\r
+  timeout.\r
 \r
   @param TimeoutRemain  The remaining timeout.\r
 **/\r