Revision: 17540
http://sourceforge.net/p/edk2/code/17540
Author: oliviermartin
Date: 2015-05-29 14:39:41 +0000 (Fri, 29 May 2015)
Log Message:
-----------
EmbeddedPkg/AcpiLib: Introduced LocateAndInstallAcpiFromFvConditional()
This new helper function allows to install ACPI Table on condition.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>
Reviewed-by: Ronald Cron <[email protected]>
Modified Paths:
--------------
trunk/edk2/EmbeddedPkg/Include/Library/AcpiLib.h
trunk/edk2/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
Modified: trunk/edk2/EmbeddedPkg/Include/Library/AcpiLib.h
===================================================================
--- trunk/edk2/EmbeddedPkg/Include/Library/AcpiLib.h 2015-05-29 14:00:39 UTC
(rev 17539)
+++ trunk/edk2/EmbeddedPkg/Include/Library/AcpiLib.h 2015-05-29 14:39:41 UTC
(rev 17540)
@@ -1,7 +1,7 @@
/** @file
Helper Library for ACPI
- Copyright (c) 2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2014-2015, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
@@ -18,6 +18,8 @@
#include <Uefi.h>
+#include <IndustryStandard/Acpi10.h>
+
//
// Macros for the Generic Address Space
//
@@ -69,7 +71,31 @@
WatchdogTimerGSIV, WatchdogTimerFlags
\
}
+typedef
+BOOLEAN
+(EFIAPI *EFI_LOCATE_ACPI_CHECK) (
+ IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
+ );
+
/**
+ Locate and Install the ACPI tables from the Firmware Volume if it verifies
+ the function condition.
+
+ @param AcpiFile Guid of the ACPI file into the Firmware
Volume
+ @param CheckAcpiTableFunction Function that checks if the ACPI table
should be installed
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the
protocol.
+
+**/
+EFI_STATUS
+LocateAndInstallAcpiFromFvConditional (
+ IN CONST EFI_GUID* AcpiFile,
+ IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
+ );
+
+/**
Locate and Install the ACPI tables from the Firmware Volume
@param AcpiFile Guid of the ACPI file into the Firmware Volume
Modified: trunk/edk2/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
===================================================================
--- trunk/edk2/EmbeddedPkg/Library/AcpiLib/AcpiLib.c 2015-05-29 14:00:39 UTC
(rev 17539)
+++ trunk/edk2/EmbeddedPkg/Library/AcpiLib/AcpiLib.c 2015-05-29 14:39:41 UTC
(rev 17540)
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2014, ARM Limited. All rights reserved.
+* Copyright (c) 2014-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD
License
@@ -24,18 +24,21 @@
#include <IndustryStandard/Acpi.h>
/**
- Locate and Install the ACPI tables from the Firmware Volume
+ Locate and Install the ACPI tables from the Firmware Volume if it verifies
+ the function condition.
- @param AcpiFile Guid of the ACPI file into the Firmware Volume
+ @param AcpiFile Guid of the ACPI file into the Firmware
Volume
+ @param CheckAcpiTableFunction Function that checks if the ACPI table
should be installed
- @return EFI_SUCCESS The function completed successfully.
- @return EFI_NOT_FOUND The protocol could not be located.
- @return EFI_OUT_OF_RESOURCES There are not enough resources to find the
protocol.
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the
protocol.
**/
EFI_STATUS
-LocateAndInstallAcpiFromFv (
- IN CONST EFI_GUID* AcpiFile
+LocateAndInstallAcpiFromFvConditional (
+ IN CONST EFI_GUID* AcpiFile,
+ IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
)
{
EFI_STATUS Status;
@@ -50,6 +53,7 @@
EFI_ACPI_COMMON_HEADER *AcpiTable;
UINTN AcpiTableSize;
UINTN AcpiTableKey;
+ BOOLEAN Valid;
// Ensure the ACPI Table is present
Status = gBS->LocateProtocol (
@@ -116,13 +120,23 @@
((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 16) &
0xFF),
((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 24) &
0xFF)));
+ // Is the ACPI table valid?
+ if (CheckAcpiTableFunction) {
+ Valid = CheckAcpiTableFunction ((EFI_ACPI_DESCRIPTION_HEADER
*)AcpiTable);
+ } else {
+ Valid = TRUE;
+ }
+
// Install the ACPI Table
- Status = AcpiProtocol->InstallAcpiTable (
- AcpiProtocol,
- AcpiTable,
- AcpiTableSize,
- &AcpiTableKey
- );
+ if (Valid) {
+ Status = AcpiProtocol->InstallAcpiTable (
+ AcpiProtocol,
+ AcpiTable,
+ AcpiTableSize,
+ &AcpiTableKey
+ );
+ }
+
// Free memory allocated by ReadSection
gBS->FreePool (AcpiTable);
@@ -144,3 +158,21 @@
return EFI_SUCCESS;
}
+
+/**
+ Locate and Install the ACPI tables from the Firmware Volume
+
+ @param AcpiFile Guid of the ACPI file into the Firmware Volume
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The protocol could not be located.
+ @return EFI_OUT_OF_RESOURCES There are not enough resources to find the
protocol.
+
+**/
+EFI_STATUS
+LocateAndInstallAcpiFromFv (
+ IN CONST EFI_GUID* AcpiFile
+ )
+{
+ return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);
+}
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits