X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FLibrary%2FPlatformBdsLib%2FBdsPlatform.c;h=ab9c93eaf8711a051222f67367710305a0aa2555;hb=489c314207bb083ed107a5f2249fbb2f2615c0e0;hp=a2a8f35a7361ee253a73d79b0d76d5e324acc9ef;hpb=8861fc792ce90cb7ab18a91bd3d6596d77ee0170;p=mirror_edk2.git diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c index a2a8f35a73..ab9c93eaf8 100644 --- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c @@ -1,8 +1,8 @@ /** @file Platform BDS customizations. - Copyright (c) 2004 - 2009, Intel Corporation.
- All rights reserved. This program and the accompanying materials + Copyright (c) 2004 - 2013, 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 http://opensource.org/licenses/bsd-license.php @@ -13,6 +13,7 @@ **/ #include "BdsPlatform.h" +#include "QemuBootOrder.h" // @@ -73,19 +74,6 @@ InstallDevicePathCallback ( VOID ); -STATIC -VOID -LoadVideoRom ( - VOID - ); - -STATIC -EFI_STATUS -PciRomLoadEfiDriversFromRomImage ( - IN EFI_PHYSICAL_ADDRESS Rom, - IN UINTN RomSize - ); - // // BDS Platform Functions // @@ -111,7 +99,6 @@ Returns: { DEBUG ((EFI_D_INFO, "PlatformBdsInit\n")); InstallDevicePathCallback (); - LoadVideoRom (); } @@ -222,14 +209,16 @@ Returns: // Print Device Path // DevPathStr = DevicePathToStr(DevicePath); - DEBUG(( - EFI_D_INFO, - "BdsPlatform.c+%d: COM%d DevPath: %s\n", - __LINE__, - gPnp16550ComPortDeviceNode.UID + 1, - DevPathStr - )); - FreePool(DevPathStr); + if (DevPathStr != NULL) { + DEBUG(( + EFI_D_INFO, + "BdsPlatform.c+%d: COM%d DevPath: %s\n", + __LINE__, + gPnp16550ComPortDeviceNode.UID + 1, + DevPathStr + )); + FreePool(DevPathStr); + } BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL); BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL); @@ -249,14 +238,16 @@ Returns: // Print Device Path // DevPathStr = DevicePathToStr(DevicePath); - DEBUG(( - EFI_D_INFO, - "BdsPlatform.c+%d: COM%d DevPath: %s\n", - __LINE__, - gPnp16550ComPortDeviceNode.UID + 1, - DevPathStr - )); - FreePool(DevPathStr); + if (DevPathStr != NULL) { + DEBUG(( + EFI_D_INFO, + "BdsPlatform.c+%d: COM%d DevPath: %s\n", + __LINE__, + gPnp16550ComPortDeviceNode.UID + 1, + DevPathStr + )); + FreePool(DevPathStr); + } BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL); BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL); @@ -737,10 +728,10 @@ PciInitialization ( // Bus 0, Device 1, Function 0 - PCI to ISA Bridge // PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00); - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x09); - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0b); - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x09); + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // LNKA routing target + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // LNKB routing target + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // LNKC routing target + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // LNKD routing target // // Bus 0, Device 1, Function 1 - IDE Controller @@ -751,8 +742,8 @@ PciInitialization ( // // Bus 0, Device 1, Function 3 - Power Managment Controller // - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x0b); - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x09); + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); // INTA // // Bus 0, Device 2, Function 0 - Video Controller @@ -762,14 +753,26 @@ PciInitialization ( // // Bus 0, Device 3, Function 0 - Network Controller // - PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0b); - PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); + PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0a); + PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); // INTA (-> LNKC) // - // Bus 0, Device 4, Function 0 - RAM Memory + // Bus 0, Device 5, Function 0 - RAM Memory // - PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3c), 0x09); - PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3d), 0x01); + PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0b); + PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3d), 0x01); // INTA (-> LNKA) +} + + +VOID +AcpiInitialization ( + VOID + ) +{ + // + // Set ACPI SCI_EN bit in PMCNTRL + // + IoOr16 ((PciRead32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40)) & ~BIT0) + 4, BIT0); } @@ -800,12 +803,14 @@ ConnectRecursivelyIfPciMassStorage ( // Print Device Path // DevPathStr = DevicePathToStr (DevicePath); - DEBUG(( - EFI_D_INFO, - "Found Mass Storage device: %s\n", - DevPathStr - )); - FreePool(DevPathStr); + if (DevPathStr != NULL) { + DEBUG(( + EFI_D_INFO, + "Found Mass Storage device: %s\n", + DevPathStr + )); + FreePool(DevPathStr); + } Status = gBS->ConnectController (Handle, NULL, NULL, TRUE); if (EFI_ERROR (Status)) { @@ -883,7 +888,7 @@ PlatformBdsRestoreNvVarsFromHardDisk ( VisitingFileSystemInstance, NULL ); - + } @@ -933,6 +938,7 @@ Returns: BdsLibConnectAll (); PciInitialization (); + AcpiInitialization (); // // Clear the logo after all devices are connected. @@ -1067,11 +1073,16 @@ Returns: ConnectRootBridge (); - // - // Try to restore variables from the hard disk early so - // they can be used for the other BDS connect operations. - // - PlatformBdsRestoreNvVarsFromHardDisk (); + if (PcdGetBool (PcdOvmfFlashVariablesEnable)) { + DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars " + "from disk since flash variables appear to be supported.\n")); + } else { + // + // Try to restore variables from the hard disk early so + // they can be used for the other BDS connect operations. + // + PlatformBdsRestoreNvVarsFromHardDisk (); + } // // Init the time out value @@ -1127,6 +1138,11 @@ Returns: // PlatformBdsConnectSequence (); + // + // Process QEMU's -kernel command line option + // + TryRunningQemuKernel (); + // // Give one chance to enter the setup if we // have the time out @@ -1139,6 +1155,8 @@ Returns: BdsLibConnectAll (); BdsLibEnumerateAllBootOption (BootOptionList); + SetBootOrderFromQemu (BootOptionList); + // // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot // checking code in real production tip. @@ -1442,175 +1460,3 @@ LockKeyboards ( return EFI_UNSUPPORTED; } - -STATIC -VOID -LoadVideoRom ( - VOID - ) -{ - PCI_DATA_STRUCTURE *Pcir; - UINTN RomSize; - - // - // The virtual machines sometimes load the video rom image - // directly at the legacy video BIOS location of C000:0000, - // and do not implement the PCI expansion ROM feature. - // - Pcir = (PCI_DATA_STRUCTURE *) (UINTN) 0xc0000; - RomSize = Pcir->ImageLength * 512; - PciRomLoadEfiDriversFromRomImage (0xc0000, RomSize); -} - - -STATIC -EFI_STATUS -PciRomLoadEfiDriversFromRomImage ( - IN EFI_PHYSICAL_ADDRESS Rom, - IN UINTN RomSize - ) -{ - CHAR16 *FileName; - EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader; - PCI_DATA_STRUCTURE *Pcir; - UINTN ImageIndex; - UINTN RomOffset; - UINT32 ImageSize; - UINT16 ImageOffset; - EFI_HANDLE ImageHandle; - EFI_STATUS Status; - EFI_STATUS retStatus; - EFI_DEVICE_PATH_PROTOCOL *FilePath; - BOOLEAN SkipImage; - UINT32 DestinationSize; - UINT32 ScratchSize; - UINT8 *Scratch; - VOID *ImageBuffer; - VOID *DecompressedImageBuffer; - UINT32 ImageLength; - EFI_DECOMPRESS_PROTOCOL *Decompress; - - FileName = L"PciRomInMemory"; - - //FileName = L"PciRom Addr=0000000000000000"; - //HexToString (&FileName[12], Rom, 16); - - ImageIndex = 0; - retStatus = EFI_NOT_FOUND; - RomOffset = (UINTN) Rom; - - do { - - EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomOffset; - - if (EfiRomHeader->Signature != 0xaa55) { - return retStatus; - } - - Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomOffset + EfiRomHeader->PcirOffset); - ImageSize = Pcir->ImageLength * 512; - - if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) && - (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) ) { - - if ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) || - (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) ) { - - ImageOffset = EfiRomHeader->EfiImageHeaderOffset; - ImageSize = EfiRomHeader->InitializationSize * 512; - - ImageBuffer = (VOID *) (UINTN) (RomOffset + ImageOffset); - ImageLength = ImageSize - ImageOffset; - DecompressedImageBuffer = NULL; - - // - // decompress here if needed - // - SkipImage = FALSE; - if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { - SkipImage = TRUE; - } - - if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { - Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **) &Decompress); - if (EFI_ERROR (Status)) { - SkipImage = TRUE; - } else { - SkipImage = TRUE; - Status = Decompress->GetInfo ( - Decompress, - ImageBuffer, - ImageLength, - &DestinationSize, - &ScratchSize - ); - if (!EFI_ERROR (Status)) { - DecompressedImageBuffer = NULL; - DecompressedImageBuffer = AllocatePool (DestinationSize); - if (DecompressedImageBuffer != NULL) { - Scratch = AllocatePool (ScratchSize); - if (Scratch != NULL) { - Status = Decompress->Decompress ( - Decompress, - ImageBuffer, - ImageLength, - DecompressedImageBuffer, - DestinationSize, - Scratch, - ScratchSize - ); - if (!EFI_ERROR (Status)) { - ImageBuffer = DecompressedImageBuffer; - ImageLength = DestinationSize; - SkipImage = FALSE; - } - - gBS->FreePool (Scratch); - } - } - } - } - } - - if (!SkipImage) { - - // - // load image and start image - // - - FilePath = FileDevicePath (NULL, FileName); - - Status = gBS->LoadImage ( - FALSE, - gImageHandle, - FilePath, - ImageBuffer, - ImageLength, - &ImageHandle - ); - if (!EFI_ERROR (Status)) { - Status = gBS->StartImage (ImageHandle, NULL, NULL); - if (!EFI_ERROR (Status)) { - retStatus = Status; - } - } - if (FilePath != NULL) { - gBS->FreePool (FilePath); - } - } - - if (DecompressedImageBuffer != NULL) { - gBS->FreePool (DecompressedImageBuffer); - } - - } - } - - RomOffset = RomOffset + ImageSize; - ImageIndex++; - } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomOffset - (UINTN) Rom) < RomSize)); - - return retStatus; -} - -