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