Home | History | Annotate | Download | only in D05AcpiTables
      1 /** @file
      2 *  Generic Timer Description Table (GTDT)
      3 *
      4 *  Copyright (c) 2012 - 2014, ARM Limited. All rights reserved.
      5 *  Copyright (c) 2015 - 2016, Hisilicon Limited. All rights reserved.
      6 *  Copyright (c) 2015 - 2016, Linaro Limited. All rights reserved.
      7 *
      8 *  This program and the accompanying materials
      9 *  are licensed and made available under the terms and conditions of the BSD License
     10 *  which accompanies this distribution.  The full text of the license may be found at
     11 *  http://opensource.org/licenses/bsd-license.php
     12 *
     13 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     14 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     15 *
     16 *  Based on the files under ArmPlatformPkg/ArmJunoPkg/AcpiTables/
     17 *
     18 **/
     19 
     20 #include <IndustryStandard/Acpi.h>
     21 #include <Library/AcpiLib.h>
     22 #include <Library/PcdLib.h>
     23 #include "Hi1616Platform.h"
     24 
     25 #define GTDT_GLOBAL_FLAGS_MAPPED      EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_MEMORY_MAPPED_BLOCK_PRESENT
     26 #define GTDT_GLOBAL_FLAGS_NOT_MAPPED  0
     27 #define GTDT_GLOBAL_FLAGS_EDGE        EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_INTERRUPT_MODE
     28 #define GTDT_GLOBAL_FLAGS_LEVEL       0
     29 
     30 // Note: We could have a build flag that switches between memory mapped/non-memory mapped timer
     31 #ifdef SYSTEM_TIMER_BASE_ADDRESS
     32   #define GTDT_GLOBAL_FLAGS             (GTDT_GLOBAL_FLAGS_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
     33 #else
     34   #define GTDT_GLOBAL_FLAGS             (GTDT_GLOBAL_FLAGS_NOT_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
     35   #define SYSTEM_TIMER_BASE_ADDRESS     0xFFFFFFFFFFFFFFFF
     36 #endif
     37 
     38 #define GTDT_TIMER_EDGE_TRIGGERED   EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_MODE
     39 #define GTDT_TIMER_LEVEL_TRIGGERED  0
     40 #define GTDT_TIMER_ACTIVE_LOW       EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
     41 #define GTDT_TIMER_ACTIVE_HIGH      0
     42 
     43 #define GTDT_GTIMER_FLAGS           (GTDT_TIMER_ACTIVE_LOW | GTDT_TIMER_LEVEL_TRIGGERED)
     44 
     45 #pragma pack (1)
     46 
     47 typedef struct {
     48   EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE          Gtdt;
     49   EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE     Watchdogs[HI1616_WATCHDOG_COUNT];
     50 } EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES;
     51 
     52 #pragma pack ()
     53 
     54 EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
     55   {
     56     ARM_ACPI_HEADER(
     57       EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
     58       EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES,
     59       EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
     60     ),
     61     SYSTEM_TIMER_BASE_ADDRESS,                    // UINT64  PhysicalAddress
     62     0,                                            // UINT32  Reserved
     63     FixedPcdGet32 (PcdArmArchTimerSecIntrNum),    // UINT32  SecurePL1TimerGSIV
     64     GTDT_GTIMER_FLAGS,                            // UINT32  SecurePL1TimerFlags
     65     FixedPcdGet32 (PcdArmArchTimerIntrNum),       // UINT32  NonSecurePL1TimerGSIV
     66     GTDT_GTIMER_FLAGS,                            // UINT32  NonSecurePL1TimerFlags
     67     FixedPcdGet32 (PcdArmArchTimerVirtIntrNum),   // UINT32  VirtualTimerGSIV
     68     GTDT_GTIMER_FLAGS,                            // UINT32  VirtualTimerFlags
     69     FixedPcdGet32 (PcdArmArchTimerHypIntrNum),    // UINT32  NonSecurePL2TimerGSIV
     70     GTDT_GTIMER_FLAGS,                            // UINT32  NonSecurePL2TimerFlags
     71     0xFFFFFFFFFFFFFFFF,                           // UINT64  CntReadBasePhysicalAddress
     72 #ifdef notyet
     73     PV660_WATCHDOG_COUNT,                          // UINT32  PlatformTimerCount
     74     sizeof (EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE) // UINT32 PlatfromTimerOffset
     75   },
     76   {
     77     EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(
     78         //FixedPcdGet32 (PcdGenericWatchdogRefreshBase), FixedPcdGet32 (PcdGenericWatchdogControlBase), 93, 0),
     79         0, 0, 0, 0),
     80     EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(
     81         //FixedPcdGet32 (PcdGenericWatchdogRefreshBase), FixedPcdGet32 (PcdGenericWatchdogControlBase), 94, EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_SECURE_TIMER)
     82         0, 0, 0, 0)
     83   }
     84 #else /* !notyet */
     85   0, 0
     86   }
     87 #endif
     88   };
     89 
     90 //
     91 // Reference the table being generated to prevent the optimizer from removing the
     92 // data structure from the executable
     93 //
     94 VOID* CONST ReferenceAcpiTable = &Gtdt;
     95 
     96