X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FAcpiPlatformDxe%2FAcpiPlatform.c;h=61166c65c33cd2c366b4b8d11df95f522bff5a43;hb=821807bcefb9a36e598d71a8004fae5aab2052a0;hp=44bdd94fa8db68b16caced77f4165429ef4bd9cb;hpb=7d2bd1505b93135947045e24b6a1313799d44738;p=mirror_edk2.git diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c index 44bdd94fa8..61166c65c3 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c @@ -1,7 +1,7 @@ /** @file - Sample ACPI Platform Driver + OVMF ACPI Platform Driver - Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2012, 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 @@ -10,19 +10,27 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include +**/ -#include -#include +#include "AcpiPlatform.h" -#include -#include -#include -#include +EFI_STATUS +EFIAPI +InstallAcpiTable ( + IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, + IN VOID *AcpiTableBuffer, + IN UINTN AcpiTableBufferSize, + OUT UINTN *TableKey + ) +{ + return AcpiProtocol->InstallAcpiTable ( + AcpiProtocol, + AcpiTableBuffer, + AcpiTableBufferSize, + TableKey + ); +} -#include /** Locate the first instance of a protocol. If the protocol requested is an @@ -70,12 +78,9 @@ LocateFvInstanceWithTables ( return Status; } - - // // Looking for FV with ACPI storage file // - for (Index = 0; Index < NumberOfHandles; Index++) { // // Get the protocol on this handle @@ -125,72 +130,41 @@ LocateFvInstanceWithTables ( /** - This function calculates and updates an UINT8 checksum. - - @param Buffer Pointer to buffer to checksum - @param Size Number of bytes to checksum - -**/ -VOID -AcpiPlatformChecksum ( - IN UINT8 *Buffer, - IN UINTN Size - ) -{ - UINTN ChecksumOffset; + Find ACPI tables in an FV and install them. - ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum); + This is now a fall-back path. Normally, we will search for tables provided + by the VMM first. - // - // Set checksum to 0 first - // - Buffer[ChecksumOffset] = 0; - - // - // Update checksum value - // - Buffer[ChecksumOffset] = CalculateCheckSum8(Buffer, Size); -} + If that fails, we use this function to load the ACPI tables from an FV. The + sources for the FV based tables is located under OvmfPkg/AcpiTables. - -/** - Entrypoint of Acpi Platform driver. - - @param ImageHandle - @param SystemTable - - @return EFI_SUCCESS - @return EFI_LOAD_ERROR - @return EFI_OUT_OF_RESOURCES + @param AcpiTable Protocol instance pointer **/ EFI_STATUS EFIAPI -AcpiPlatformEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +InstallOvmfFvTables ( + IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable ) { - EFI_STATUS Status; - EFI_ACPI_TABLE_PROTOCOL *AcpiTable; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; - INTN Instance; - EFI_ACPI_COMMON_HEADER *CurrentTable; - UINTN TableHandle; - UINT32 FvStatus; - UINTN TableSize; - UINTN Size; + EFI_STATUS Status; + EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; + INTN Instance; + EFI_ACPI_COMMON_HEADER *CurrentTable; + UINTN TableHandle; + UINT32 FvStatus; + UINTN TableSize; + UINTN Size; + EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction; Instance = 0; CurrentTable = NULL; TableHandle = 0; - // - // Find the AcpiTable protocol - // - Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable); - if (EFI_ERROR (Status)) { - return EFI_ABORTED; + if (QemuDetected ()) { + TableInstallFunction = QemuInstallAcpiTable; + } else { + TableInstallFunction = InstallAcpiTable; } // @@ -214,7 +188,7 @@ AcpiPlatformEntryPoint ( &Size, &FvStatus ); - if (!EFI_ERROR(Status)) { + if (!EFI_ERROR (Status)) { // // Add the table // @@ -223,27 +197,22 @@ AcpiPlatformEntryPoint ( TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length; ASSERT (Size >= TableSize); - // - // Checksum ACPI table - // - AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize); - // // Install ACPI table // - Status = AcpiTable->InstallAcpiTable ( - AcpiTable, - CurrentTable, - TableSize, - &TableHandle - ); + Status = TableInstallFunction ( + AcpiTable, + CurrentTable, + TableSize, + &TableHandle + ); // // Free memory allocated by ReadSection // gBS->FreePool (CurrentTable); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { return EFI_ABORTED; } @@ -258,3 +227,35 @@ AcpiPlatformEntryPoint ( return EFI_SUCCESS; } +/** + Effective entrypoint of Acpi Platform driver. + + @param ImageHandle + @param SystemTable + + @return EFI_SUCCESS + @return EFI_LOAD_ERROR + @return EFI_OUT_OF_RESOURCES + +**/ +EFI_STATUS +EFIAPI +InstallAcpiTables ( + IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable + ) +{ + EFI_STATUS Status; + + if (XenDetected ()) { + Status = InstallXenTables (AcpiTable); + } else { + Status = InstallQemuFwCfgTables (AcpiTable); + } + + if (EFI_ERROR (Status)) { + Status = InstallOvmfFvTables (AcpiTable); + } + + return Status; +} +