2 OVMF ACPI Platform Driver
4 Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "AcpiPlatform.h"
20 IN EFI_ACPI_TABLE_PROTOCOL
*AcpiProtocol
,
21 IN VOID
*AcpiTableBuffer
,
22 IN UINTN AcpiTableBufferSize
,
26 return AcpiProtocol
->InstallAcpiTable (
36 Locate the first instance of a protocol. If the protocol requested is an
37 FV protocol, then it will return the first FV that contains the ACPI table
40 @param Instance Return pointer to the first instance of the protocol
42 @return EFI_SUCCESS The function completed successfully.
43 @return EFI_NOT_FOUND The protocol could not be located.
44 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
48 LocateFvInstanceWithTables (
49 OUT EFI_FIRMWARE_VOLUME2_PROTOCOL
**Instance
53 EFI_HANDLE
*HandleBuffer
;
54 UINTN NumberOfHandles
;
55 EFI_FV_FILETYPE FileType
;
57 EFI_FV_FILE_ATTRIBUTES Attributes
;
60 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FvInstance
;
67 Status
= gBS
->LocateHandleBuffer (
69 &gEfiFirmwareVolume2ProtocolGuid
,
74 if (EFI_ERROR (Status
)) {
76 // Defined errors at this time are not found and out of resources.
82 // Looking for FV with ACPI storage file
84 for (Index
= 0; Index
< NumberOfHandles
; Index
++) {
86 // Get the protocol on this handle
87 // This should not fail because of LocateHandleBuffer
89 Status
= gBS
->HandleProtocol (
91 &gEfiFirmwareVolume2ProtocolGuid
,
94 ASSERT_EFI_ERROR (Status
);
97 // See if it has the ACPI storage file
99 Status
= FvInstance
->ReadFile (
101 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
110 // If we found it, then we are done
112 if (Status
== EFI_SUCCESS
) {
113 *Instance
= FvInstance
;
119 // Our exit status is determined by the success of the previous operations
120 // If the protocol was found, Instance already points to it.
124 // Free any allocated buffers
126 gBS
->FreePool (HandleBuffer
);
133 Find ACPI tables in an FV and parses them. This function is useful for QEMU and KVM.
135 @param AcpiTable Protocol instance pointer
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 Entrypoint of Acpi Platform driver.
231 @return EFI_LOAD_ERROR
232 @return EFI_OUT_OF_RESOURCES
237 AcpiPlatformEntryPoint (
238 IN EFI_HANDLE ImageHandle
,
239 IN EFI_SYSTEM_TABLE
*SystemTable
243 EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
;
246 // Find the AcpiTable protocol
248 Status
= gBS
->LocateProtocol (
249 &gEfiAcpiTableProtocolGuid
,
253 if (EFI_ERROR (Status
)) {
257 if (XenDetected ()) {
258 Status
= InstallXenTables (AcpiTable
);
260 Status
= InstallQemuLinkedTables (AcpiTable
);
263 if (EFI_ERROR (Status
)) {
264 Status
= FindAcpiTablesInFv (AcpiTable
);