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 // Locate the firmware volume protocol
167 Status
= LocateFvInstanceWithTables (&FwVol
);
168 if (EFI_ERROR (Status
)) {
172 // Read tables from the storage file.
174 while (Status
== EFI_SUCCESS
) {
176 Status
= FwVol
->ReadSection (
178 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
181 (VOID
**) &CurrentTable
,
185 if (!EFI_ERROR (Status
)) {
191 TableSize
= ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
)->Length
;
192 ASSERT (Size
>= TableSize
);
195 // Install ACPI table
197 Status
= TableInstallFunction (
205 // Free memory allocated by ReadSection
207 gBS
->FreePool (CurrentTable
);
209 if (EFI_ERROR (Status
)) {
214 // Increment the instance
225 Effective entrypoint of Acpi Platform driver.
231 @return EFI_LOAD_ERROR
232 @return EFI_OUT_OF_RESOURCES
238 IN EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
243 if (XenDetected ()) {
244 Status
= InstallXenTables (AcpiTable
);
246 Status
= InstallQemuFwCfgTables (AcpiTable
);
249 if (EFI_ERROR (Status
)) {
250 Status
= InstallOvmfFvTables (AcpiTable
);