]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/AcpiLib: Introduced LocateAndInstallAcpiFromFvConditional()
authorOlivier Martin <Olivier.Martin@arm.com>
Fri, 29 May 2015 14:39:41 +0000 (14:39 +0000)
committeroliviermartin <oliviermartin@Edk2>
Fri, 29 May 2015 14:39:41 +0000 (14:39 +0000)
This new helper function allows to install ACPI Table on condition.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <Olivier.Martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17540 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Include/Library/AcpiLib.h
EmbeddedPkg/Library/AcpiLib/AcpiLib.c

index b0cde9aed447a2b0ecca89769785697716172f10..42710fd1fd62f477c560b98922ceae59c4ccccaa 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper Library for ACPI\r
 \r
-  Copyright (c) 2014, ARM Ltd. All rights reserved.\r
+  Copyright (c) 2014-2015, ARM Ltd. All rights reserved.\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -18,6 +18,8 @@
 \r
 #include <Uefi.h>\r
 \r
+#include <IndustryStandard/Acpi10.h>\r
+\r
 //\r
 // Macros for the Generic Address Space\r
 //\r
     WatchdogTimerGSIV, WatchdogTimerFlags                                                               \\r
   }\r
 \r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_LOCATE_ACPI_CHECK) (\r
+  IN  EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader\r
+  );\r
+\r
+/**\r
+  Locate and Install the ACPI tables from the Firmware Volume if it verifies\r
+  the function condition.\r
+\r
+  @param  AcpiFile                Guid of the ACPI file into the Firmware Volume\r
+  @param  CheckAcpiTableFunction  Function that checks if the ACPI table should be installed\r
+\r
+  @return EFI_SUCCESS             The function completed successfully.\r
+  @return EFI_NOT_FOUND           The protocol could not be located.\r
+  @return EFI_OUT_OF_RESOURCES    There are not enough resources to find the protocol.\r
+\r
+**/\r
+EFI_STATUS\r
+LocateAndInstallAcpiFromFvConditional (\r
+  IN CONST EFI_GUID*        AcpiFile,\r
+  IN EFI_LOCATE_ACPI_CHECK  CheckAcpiTableFunction\r
+  );\r
+\r
 /**\r
   Locate and Install the ACPI tables from the Firmware Volume\r
 \r
index 4090055928d44cd3f846da9bcc74f39c714e0c80..0e27276c22ef4053916990b004c7f081c184ad88 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2014, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2014-2015, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
 #include <IndustryStandard/Acpi.h>\r
 \r
 /**\r
-  Locate and Install the ACPI tables from the Firmware Volume\r
+  Locate and Install the ACPI tables from the Firmware Volume if it verifies\r
+  the function condition.\r
 \r
-  @param  AcpiFile              Guid of the ACPI file into the Firmware Volume\r
+  @param  AcpiFile                Guid of the ACPI file into the Firmware Volume\r
+  @param  CheckAcpiTableFunction  Function that checks if the ACPI table should be installed\r
 \r
-  @return EFI_SUCCESS           The function completed successfully.\r
-  @return EFI_NOT_FOUND         The protocol could not be located.\r
-  @return EFI_OUT_OF_RESOURCES  There are not enough resources to find the protocol.\r
+  @return EFI_SUCCESS             The function completed successfully.\r
+  @return EFI_NOT_FOUND           The protocol could not be located.\r
+  @return EFI_OUT_OF_RESOURCES    There are not enough resources to find the protocol.\r
 \r
 **/\r
 EFI_STATUS\r
-LocateAndInstallAcpiFromFv (\r
-  IN CONST EFI_GUID* AcpiFile\r
+LocateAndInstallAcpiFromFvConditional (\r
+  IN CONST EFI_GUID*        AcpiFile,\r
+  IN EFI_LOCATE_ACPI_CHECK  CheckAcpiTableFunction\r
   )\r
 {\r
   EFI_STATUS                    Status;\r
@@ -50,6 +53,7 @@ LocateAndInstallAcpiFromFv (
   EFI_ACPI_COMMON_HEADER       *AcpiTable;\r
   UINTN                         AcpiTableSize;\r
   UINTN                         AcpiTableKey;\r
+  BOOLEAN                       Valid;\r
 \r
   // Ensure the ACPI Table is present\r
   Status = gBS->LocateProtocol (\r
@@ -116,13 +120,23 @@ LocateAndInstallAcpiFromFv (
             ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 16) & 0xFF),\r
             ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 24) & 0xFF)));\r
 \r
+        // Is the ACPI table valid?\r
+        if (CheckAcpiTableFunction) {\r
+          Valid = CheckAcpiTableFunction ((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable);\r
+        } else {\r
+          Valid = TRUE;\r
+        }\r
+\r
         // Install the ACPI Table\r
-        Status = AcpiProtocol->InstallAcpiTable (\r
-                               AcpiProtocol,\r
-                               AcpiTable,\r
-                               AcpiTableSize,\r
-                               &AcpiTableKey\r
-                               );\r
+        if (Valid) {\r
+          Status = AcpiProtocol->InstallAcpiTable (\r
+                                 AcpiProtocol,\r
+                                 AcpiTable,\r
+                                 AcpiTableSize,\r
+                                 &AcpiTableKey\r
+                                 );\r
+        }\r
+\r
         // Free memory allocated by ReadSection\r
         gBS->FreePool (AcpiTable);\r
 \r
@@ -144,3 +158,21 @@ FREE_HANDLE_BUFFER:
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  Locate and Install the ACPI tables from the Firmware Volume\r
+\r
+  @param  AcpiFile              Guid of the ACPI file into the Firmware Volume\r
+\r
+  @return EFI_SUCCESS           The function completed successfully.\r
+  @return EFI_NOT_FOUND         The protocol could not be located.\r
+  @return EFI_OUT_OF_RESOURCES  There are not enough resources to find the protocol.\r
+\r
+**/\r
+EFI_STATUS\r
+LocateAndInstallAcpiFromFv (\r
+  IN CONST EFI_GUID* AcpiFile\r
+  )\r
+{\r
+  return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);\r
+}\r