DynamicTablesPkg: GTDT updates for ACPI 6.3
authorPierre Gondois <pierre.gondois@arm.com>
Tue, 19 Mar 2019 17:46:50 +0000 (17:46 +0000)
committerSami Mujawar <sami.mujawar@arm.com>
Tue, 11 Jun 2019 08:25:46 +0000 (09:25 +0100)
The ACPI 6.3 specification adds support for describing
ARMv8.1 EL2 virtual timers. Update GTDT Generator
to extend this support.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
DynamicTablesPkg/Include/ArmNameSpaceObjects.h
DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c

index 19c47ef..ac451b3 100644 (file)
@@ -301,6 +301,12 @@ typedef struct CmArmGenericTimerInfo {
 \r
   /// The non-secure PL2 timer flags\r
   UINT32  NonSecurePL2TimerFlags;\r
+\r
+  /// GSIV for the virtual EL2 timer\r
+  UINT32  VirtualPL2TimerGSIV;\r
+\r
+  /// Flags for the virtual EL2 timer\r
+  UINT32  VirtualPL2TimerFlags;\r
 } CM_ARM_GENERIC_TIMER_INFO;\r
 \r
 /** A structure that describes the\r
index 10cf16c..a308708 100644 (file)
@@ -5,7 +5,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Reference(s):\r
-  - ACPI 6.2 Specification - Errata A, September 2017\r
+  - ACPI 6.3 Specification - January 2019\r
 \r
 **/\r
 \r
@@ -77,6 +77,7 @@ GET_OBJECT_LIST (
                                   Protocol Interface.\r
   @param [in]  Gtdt               Pointer to the GTDT Table.\r
   @param [in]  PlatformTimerCount Platform timer count.\r
+  @param [in]  AcpiTableRevision  Acpi Revision targeted by the platform.\r
 \r
   @retval EFI_SUCCESS           Success.\r
   @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
@@ -90,8 +91,9 @@ EFI_STATUS
 EFIAPI\r
 AddGenericTimerInfo (\r
   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL         * CONST CfgMgrProtocol,\r
-  IN        EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt,\r
-  IN  CONST UINT32                                               PlatformTimerCount\r
+  IN        EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt,\r
+  IN  CONST UINT32                                               PlatformTimerCount,\r
+  IN  CONST UINT32                                               AcpiTableRevision\r
 )\r
 {\r
   EFI_STATUS                   Status;\r
@@ -131,9 +133,14 @@ AddGenericTimerInfo (
     GenericTimerInfo->CounterReadBaseAddress;\r
   Gtdt->PlatformTimerCount = PlatformTimerCount;\r
   Gtdt->PlatformTimerOffset = (PlatformTimerCount == 0) ? 0 :\r
-    sizeof (EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE);\r
+    sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE);\r
 \r
-  return EFI_SUCCESS;\r
+  if (AcpiTableRevision > EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION) {\r
+    Gtdt->VirtualPL2TimerGSIV = GenericTimerInfo->VirtualPL2TimerGSIV;\r
+    Gtdt->VirtualPL2TimerFlags = GenericTimerInfo->VirtualPL2TimerFlags;\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 /** Add the SBSA Generic Watchdog Timers to the GTDT table.\r
@@ -147,26 +154,26 @@ AddGenericTimerInfo (
 STATIC\r
 VOID\r
 AddGenericWatchdogList (\r
-  IN EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE  * CONST Gtdt,\r
+  IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE  * CONST Gtdt,\r
   IN CONST UINT32                                          WatchdogOffset,\r
   IN CONST CM_ARM_GENERIC_WATCHDOG_INFO            *       WatchdogInfoList,\r
   IN       UINT32                                          WatchdogCount\r
   )\r
 {\r
-  EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE  * Watchdog;\r
+  EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE  * Watchdog;\r
 \r
   ASSERT (Gtdt != NULL);\r
   ASSERT (WatchdogInfoList != NULL);\r
 \r
-  Watchdog = (EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE *)\r
+  Watchdog = (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE *)\r
              ((UINT8*)Gtdt + WatchdogOffset);\r
 \r
   while (WatchdogCount-- != 0) {\r
     // Add watchdog entry\r
     DEBUG ((DEBUG_INFO, "GTDT: Watchdog = 0x%p\n", Watchdog));\r
-    Watchdog->Type = EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG;\r
+    Watchdog->Type = EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG;\r
     Watchdog->Length =\r
-      sizeof (EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE);\r
+      sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE);\r
     Watchdog->Reserved = EFI_ACPI_RESERVED_BYTE;\r
     Watchdog->RefreshFramePhysicalAddress =\r
       WatchdogInfoList->RefreshFrameAddress;\r
@@ -242,7 +249,7 @@ IsGtFrameNumberEqual (
 STATIC\r
 EFI_STATUS\r
 AddGTBlockTimerFrames (\r
-  IN       EFI_ACPI_6_2_GTDT_GT_BLOCK_TIMER_STRUCTURE *       GtBlockFrame,\r
+  IN       EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE *       GtBlockFrame,\r
   IN CONST CM_ARM_GTBLOCK_TIMER_FRAME_INFO            *       GTBlockTimerFrameList,\r
   IN       UINT32                                             GTBlockFrameCount\r
 )\r
@@ -332,22 +339,22 @@ STATIC
 EFI_STATUS\r
 AddGTBlockList (\r
   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL     * CONST CfgMgrProtocol,\r
-  IN EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE    * CONST Gtdt,\r
+  IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE    * CONST Gtdt,\r
   IN CONST UINT32                                            GTBlockOffset,\r
   IN CONST CM_ARM_GTBLOCK_INFO                       *       GTBlockInfo,\r
   IN       UINT32                                            BlockTimerCount\r
 )\r
 {\r
   EFI_STATUS                                    Status;\r
-  EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE        * GTBlock;\r
-  EFI_ACPI_6_2_GTDT_GT_BLOCK_TIMER_STRUCTURE  * GtBlockFrame;\r
+  EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE        * GTBlock;\r
+  EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE  * GtBlockFrame;\r
   CM_ARM_GTBLOCK_TIMER_FRAME_INFO             * GTBlockTimerFrameList;\r
   UINT32                                        GTBlockTimerFrameCount;\r
 \r
   ASSERT (Gtdt != NULL);\r
   ASSERT (GTBlockInfo != NULL);\r
 \r
-  GTBlock = (EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE *)((UINT8*)Gtdt +\r
+  GTBlock = (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE *)((UINT8*)Gtdt +\r
               GTBlockOffset);\r
 \r
   while (BlockTimerCount-- != 0) {\r
@@ -369,18 +376,18 @@ AddGTBlockList (
       return Status;\r
     }\r
 \r
-    GTBlock->Type = EFI_ACPI_6_2_GTDT_GT_BLOCK;\r
-    GTBlock->Length = sizeof (EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE) +\r
-                        (sizeof (EFI_ACPI_6_2_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
+    GTBlock->Type = EFI_ACPI_6_3_GTDT_GT_BLOCK;\r
+    GTBlock->Length = sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) +\r
+                        (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
                           GTBlockInfo->GTBlockTimerFrameCount);\r
 \r
     GTBlock->Reserved = EFI_ACPI_RESERVED_BYTE;\r
     GTBlock->CntCtlBase = GTBlockInfo->GTBlockPhysicalAddress;\r
     GTBlock->GTBlockTimerCount = GTBlockInfo->GTBlockTimerFrameCount;\r
     GTBlock->GTBlockTimerOffset =\r
-      sizeof (EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE);\r
+      sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE);\r
 \r
-    GtBlockFrame = (EFI_ACPI_6_2_GTDT_GT_BLOCK_TIMER_STRUCTURE*)\r
+    GtBlockFrame = (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE*)\r
       ((UINT8*)GTBlock + GTBlock->GTBlockTimerOffset);\r
 \r
     // Add GT Block Timer frames\r
@@ -399,7 +406,7 @@ AddGTBlockList (
     }\r
 \r
     // Next GTBlock\r
-    GTBlock = (EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE *)((UINT8*)GTBlock +\r
+    GTBlock = (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE *)((UINT8*)GTBlock +\r
                GTBlock->Length);\r
     GTBlockInfo++;\r
   }// for\r
@@ -446,7 +453,7 @@ BuildGtdtTable (
   UINT32                                          BlockTimerCount;\r
   CM_ARM_GENERIC_WATCHDOG_INFO                  * WatchdogInfoList;\r
   CM_ARM_GTBLOCK_INFO                           * GTBlockInfo;\r
-  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE  * Gtdt;\r
+  EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE  * Gtdt;\r
   UINT32                                          Idx;\r
   UINT32                                          GTBlockOffset;\r
   UINT32                                          WatchdogOffset;\r
@@ -513,11 +520,11 @@ BuildGtdtTable (
 \r
   // Calculate the GTDT Table Size\r
   PlatformTimerCount = 0;\r
-  TableSize = sizeof (EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE);\r
+  TableSize = sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE);\r
   if (BlockTimerCount != 0) {\r
     GTBlockOffset = TableSize;\r
     PlatformTimerCount += BlockTimerCount;\r
-    TableSize += (sizeof (EFI_ACPI_6_2_GTDT_GT_BLOCK_STRUCTURE) *\r
+    TableSize += (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) *\r
                   BlockTimerCount);\r
 \r
     for (Idx = 0; Idx < BlockTimerCount; Idx++) {\r
@@ -532,7 +539,7 @@ BuildGtdtTable (
           ));\r
         goto error_handler;\r
       }\r
-      TableSize += (sizeof (EFI_ACPI_6_2_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
+      TableSize += (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
         GTBlockInfo[Idx].GTBlockTimerFrameCount);\r
     }\r
 \r
@@ -548,7 +555,7 @@ BuildGtdtTable (
   if (WatchdogCount != 0) {\r
     WatchdogOffset = TableSize;\r
     PlatformTimerCount += WatchdogCount;\r
-    TableSize += (sizeof (EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE) *\r
+    TableSize += (sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE) *\r
                   WatchdogCount);\r
     DEBUG ((\r
       DEBUG_INFO,\r
@@ -571,7 +578,7 @@ BuildGtdtTable (
     goto error_handler;\r
   }\r
 \r
-  Gtdt = (EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE*)*Table;\r
+  Gtdt = (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE*)*Table;\r
   DEBUG ((\r
     DEBUG_INFO,\r
     "GTDT: Gtdt = 0x%p TableSize = 0x%x\n",\r
@@ -598,7 +605,8 @@ BuildGtdtTable (
   Status = AddGenericTimerInfo (\r
              CfgMgrProtocol,\r
              Gtdt,\r
-             PlatformTimerCount\r
+             PlatformTimerCount,\r
+             AcpiTableInfo->AcpiTableRevision\r
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((\r
@@ -697,9 +705,9 @@ ACPI_TABLE_GENERATOR GtdtGenerator = {
   // Generator Description\r
   L"ACPI.STD.GTDT.GENERATOR",\r
   // ACPI Table Signature\r
-  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,\r
+  EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,\r
   // ACPI Table Revision supported by this Generator\r
-  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION,\r
+  EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION,\r
   // Minimum ACPI Table Revision supported by this Generator\r
   EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION,\r
   // Creator ID\r