2 OVMF ACPI Platform Driver
4 Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "AcpiPlatform.h"
14 IN EFI_ACPI_TABLE_PROTOCOL
*AcpiProtocol
,
15 IN VOID
*AcpiTableBuffer
,
16 IN UINTN AcpiTableBufferSize
,
20 return AcpiProtocol
->InstallAcpiTable (
30 Locate the first instance of a protocol. If the protocol requested is an
31 FV protocol, then it will return the first FV that contains the ACPI table
34 @param Instance Return pointer to the first instance of the protocol
36 @return EFI_SUCCESS The function completed successfully.
37 @return EFI_NOT_FOUND The protocol could not be located.
38 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
42 LocateFvInstanceWithTables (
43 OUT EFI_FIRMWARE_VOLUME2_PROTOCOL
**Instance
47 EFI_HANDLE
*HandleBuffer
;
48 UINTN NumberOfHandles
;
49 EFI_FV_FILETYPE FileType
;
51 EFI_FV_FILE_ATTRIBUTES Attributes
;
54 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FvInstance
;
61 Status
= gBS
->LocateHandleBuffer (
63 &gEfiFirmwareVolume2ProtocolGuid
,
68 if (EFI_ERROR (Status
)) {
70 // Defined errors at this time are not found and out of resources.
76 // Looking for FV with ACPI storage file
78 for (Index
= 0; Index
< NumberOfHandles
; Index
++) {
80 // Get the protocol on this handle
81 // This should not fail because of LocateHandleBuffer
83 Status
= gBS
->HandleProtocol (
85 &gEfiFirmwareVolume2ProtocolGuid
,
88 ASSERT_EFI_ERROR (Status
);
91 // See if it has the ACPI storage file
93 Status
= FvInstance
->ReadFile (
95 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
104 // If we found it, then we are done
106 if (Status
== EFI_SUCCESS
) {
107 *Instance
= FvInstance
;
113 // Our exit status is determined by the success of the previous operations
114 // If the protocol was found, Instance already points to it.
118 // Free any allocated buffers
120 gBS
->FreePool (HandleBuffer
);
127 Find ACPI tables in an FV and install them.
129 This is now a fall-back path. Normally, we will search for tables provided
132 If that fails, we use this function to load the ACPI tables from an FV. The
133 sources for the FV based tables is located under OvmfPkg/AcpiTables.
135 @param AcpiTable Protocol instance pointer
140 InstallOvmfFvTables (
141 IN EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
145 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FwVol
;
147 EFI_ACPI_COMMON_HEADER
*CurrentTable
;
152 EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction
;
158 if (QemuDetected ()) {
159 TableInstallFunction
= QemuInstallAcpiTable
;
161 TableInstallFunction
= InstallAcpiTable
;
165 // set FwVol (and use an ASSERT() below) to suppress incorrect
166 // compiler/analyzer warnings
170 // Locate the firmware volume protocol
172 Status
= LocateFvInstanceWithTables (&FwVol
);
173 if (EFI_ERROR (Status
)) {
176 ASSERT (FwVol
!= NULL
);
179 // Read tables from the storage file.
181 while (Status
== EFI_SUCCESS
) {
183 Status
= FwVol
->ReadSection (
185 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
188 (VOID
**) &CurrentTable
,
192 if (!EFI_ERROR (Status
)) {
198 TableSize
= ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
)->Length
;
199 ASSERT (Size
>= TableSize
);
202 // Install ACPI table
204 Status
= TableInstallFunction (
212 // Free memory allocated by ReadSection
214 gBS
->FreePool (CurrentTable
);
216 if (EFI_ERROR (Status
)) {
221 // Increment the instance
232 Effective entrypoint of Acpi Platform driver.
238 @return EFI_LOAD_ERROR
239 @return EFI_OUT_OF_RESOURCES
245 IN EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
250 if (XenDetected ()) {
251 Status
= InstallXenTables (AcpiTable
);
253 Status
= InstallQemuFwCfgTables (AcpiTable
);
256 if (EFI_ERROR (Status
)) {
257 Status
= InstallOvmfFvTables (AcpiTable
);