• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/** @file
2*  Generic Timer Description Table (GTDT)
3*
4*  Copyright (c) 2012 - 2014, ARM Limited. All rights reserved.
5*  Copyright (c) 2016, Linaro Ltd. All rights reserved
6*
7*  This program and the accompanying materials
8*  are licensed and made available under the terms and conditions of the BSD License
9*  which accompanies this distribution.  The full text of the license may be found at
10*  http://opensource.org/licenses/bsd-license.php
11*
12*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14*
15**/
16
17#include "FvpPlatform.h"
18#include <Library/AcpiLib.h>
19#include <Library/PcdLib.h>
20#include <IndustryStandard/Acpi61.h>
21
22#define FVP_SYSTEM_TIMER_BASE_ADDRESS   0x000000002a430000
23#define FVP_CNT_READ_BASE_ADDRESS       0x000000002a800000
24
25#define FVP_SECURE_TIMER_EL1_GSIV       0x1D
26#define FVP_NON_SECURE_TIMER_EL1_GSIV   0x1E
27#define FVP_VIRTUAL_TIMER_GSIV          0x1B
28#define FVP_NON_SECURE_EL2_GSIV         0x1A
29
30#define GTDT_TIMER_EDGE_TRIGGERED   EFI_ACPI_6_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_MODE
31#define GTDT_TIMER_LEVEL_TRIGGERED  0
32#define GTDT_TIMER_ACTIVE_LOW       EFI_ACPI_6_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
33#define GTDT_TIMER_ACTIVE_HIGH      0
34#define GTDT_TIMER_SAVE_CONTEXT     EFI_ACPI_6_1_GTDT_TIMER_FLAG_ALWAYS_ON_CAPABILITY
35#define GTDT_TIMER_LOSE_CONTEXT     0
36
37#define FVP_GTDT_GTIMER_FLAGS       (GTDT_TIMER_LOSE_CONTEXT | GTDT_TIMER_ACTIVE_HIGH | GTDT_TIMER_EDGE_TRIGGERED)
38
39#define FVP_PLATFORM_TIMER_COUNT    2
40#define FVP_TIMER_FRAMES_COUNT      2
41#define FVP_WATCHDOG_COUNT          1
42
43#define FVP_GT_BLOCK_CTL_BASE           0x000000002A810000
44#define FVP_GT_BLOCK_FRAME0_CTL_BASE    0x000000002A820000
45#define FVP_GT_BLOCK_FRAME0_CTL_EL0_BASE  0xFFFFFFFFFFFFFFFF
46#define FVP_GT_BLOCK_FRAME0_GSIV        0x39
47
48#define FVP_GT_BLOCK_FRAME1_CTL_BASE    0x000000002A830000
49#define FVP_GT_BLOCK_FRAME1_CTL_EL0_BASE  0xFFFFFFFFFFFFFFFF
50#define FVP_GT_BLOCK_FRAME1_GSIV        0x3A
51
52#define GTX_TIMER_EDGE_TRIGGERED    EFI_ACPI_6_1_GTDT_GT_BLOCK_TIMER_FLAG_TIMER_INTERRUPT_MODE
53#define GTX_TIMER_LEVEL_TRIGGERED   0
54#define GTX_TIMER_ACTIVE_LOW        EFI_ACPI_6_1_GTDT_GT_BLOCK_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
55#define GTX_TIMER_ACTIVE_HIGH       0
56
57#define FVP_GTX_TIMER_FLAGS         (GTX_TIMER_ACTIVE_HIGH | GTX_TIMER_LEVEL_TRIGGERED)
58
59#define GTX_TIMER_SECURE            EFI_ACPI_6_1_GTDT_GT_BLOCK_COMMON_FLAG_SECURE_TIMER
60#define GTX_TIMER_NON_SECURE        0
61#define GTX_TIMER_SAVE_CONTEXT      EFI_ACPI_6_1_GTDT_GT_BLOCK_COMMON_FLAG_ALWAYS_ON_CAPABILITY
62#define GTX_TIMER_LOSE_CONTEXT      0
63
64#define FVP_GTX_COMMON_FLAGS        (GTX_TIMER_SAVE_CONTEXT | GTX_TIMER_SECURE)
65
66#define FVP_SBSA_WATCHDOG_REFRESH_BASE     0x000000002a450000
67#define FVP_SBSA_WATCHDOG_CONTROL_BASE     0x000000002a440000
68#define FVP_SBSA_WATCHDOG_GSIV             0x3B
69
70#define SBSA_WATCHDOG_EDGE_TRIGGERED   EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_TIMER_INTERRUPT_MODE
71#define SBSA_WATCHDOG_LEVEL_TRIGGERED  0
72#define SBSA_WATCHDOG_ACTIVE_LOW       EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_TIMER_INTERRUPT_POLARITY
73#define SBSA_WATCHDOG_ACTIVE_HIGH      0
74#define SBSA_WATCHDOG_SECURE           EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_SECURE_TIMER
75#define SBSA_WATCHDOG_NON_SECURE       0
76
77#define FVP_SBSA_WATCHDOG_FLAGS            (SBSA_WATCHDOG_NON_SECURE | SBSA_WATCHDOG_ACTIVE_HIGH | SBSA_WATCHDOG_LEVEL_TRIGGERED)
78
79#pragma pack (1)
80
81typedef struct {
82  EFI_ACPI_6_1_GENERIC_TIMER_DESCRIPTION_TABLE          Gtdt;
83  EFI_ACPI_6_1_GTDT_GT_BLOCK_STRUCTURE                  GtBlock;
84  EFI_ACPI_6_1_GTDT_GT_BLOCK_TIMER_STRUCTURE            Frames[FVP_TIMER_FRAMES_COUNT];
85  EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE     Watchdogs[FVP_WATCHDOG_COUNT];
86} FVP_GENERIC_TIMER_DESCRIPTION_TABLES;
87
88#pragma pack ()
89
90FVP_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
91  {
92    ARM_ACPI_HEADER(
93      EFI_ACPI_6_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
94      FVP_GENERIC_TIMER_DESCRIPTION_TABLES,
95      EFI_ACPI_6_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
96    ),
97    FVP_SYSTEM_TIMER_BASE_ADDRESS,                        // UINT64  PhysicalAddress
98    EFI_ACPI_RESERVED_DWORD,                              // UINT32  Reserved
99    FVP_SECURE_TIMER_EL1_GSIV,                            // UINT32  SecurePL1TimerGSIV
100    FVP_GTDT_GTIMER_FLAGS,                                // UINT32  SecurePL1TimerFlags
101    FVP_NON_SECURE_TIMER_EL1_GSIV,                        // UINT32  NonSecurePL1TimerGSIV
102    FVP_GTDT_GTIMER_FLAGS,                                // UINT32  NonSecurePL1TimerFlags
103    FVP_VIRTUAL_TIMER_GSIV,                               // UINT32  VirtualTimerGSIV
104    FVP_GTDT_GTIMER_FLAGS,                                // UINT32  VirtualTimerFlags
105    FVP_NON_SECURE_EL2_GSIV,                              // UINT32  NonSecurePL2TimerGSIV
106    FVP_GTDT_GTIMER_FLAGS,                                // UINT32  NonSecurePL2TimerFlags
107    FVP_CNT_READ_BASE_ADDRESS,                            // UINT64  CntReadBasePhysicalAddress
108    FVP_PLATFORM_TIMER_COUNT,                             // UINT32  PlatformTimerCount
109    sizeof (EFI_ACPI_6_1_GENERIC_TIMER_DESCRIPTION_TABLE) // UINT32  PlatfromTimerOffset
110  },
111  {
112    EFI_ACPI_6_1_GTDT_GT_BLOCK,                           // UINT8 Type
113    sizeof(EFI_ACPI_6_1_GTDT_GT_BLOCK_STRUCTURE)          // UINT16 Length
114      + sizeof(EFI_ACPI_6_1_GTDT_GT_BLOCK_TIMER_STRUCTURE) *
115        FVP_TIMER_FRAMES_COUNT,
116    EFI_ACPI_RESERVED_BYTE,                               // UINT8 Reserved
117    FVP_GT_BLOCK_CTL_BASE,                                // UINT64 CntCtlBase
118    FVP_TIMER_FRAMES_COUNT,                               // UINT32 GTBlockTimerCount
119    sizeof(EFI_ACPI_6_1_GTDT_GT_BLOCK_STRUCTURE)          // UINT32 GTBlockTimerOffset
120  },
121  {
122    {
123      0,                                                    // UINT8 GTFrameNumber
124      {EFI_ACPI_RESERVED_BYTE,
125       EFI_ACPI_RESERVED_BYTE,
126       EFI_ACPI_RESERVED_BYTE},                             // UINT8 Reserved[3]
127      FVP_GT_BLOCK_FRAME0_CTL_BASE,                         // UINT64 CntBaseX
128      FVP_GT_BLOCK_FRAME0_CTL_EL0_BASE,                     // UINT64 CntEL0BaseX
129      FVP_GT_BLOCK_FRAME0_GSIV,                             // UINT32 GTxPhysicalTimerGSIV
130      FVP_GTX_TIMER_FLAGS,                                  // UINT32 GTxPhysicalTimerFlags
131      0,                                                    // UINT32 GTxVirtualTimerGSIV
132      0,                                                    // UINT32 GTxVirtualTimerFlags
133      FVP_GTX_COMMON_FLAGS                                  // UINT32 GTxCommonFlags
134    },
135    {
136      1,                                                    // UINT8 GTFrameNumber
137      {EFI_ACPI_RESERVED_BYTE,
138       EFI_ACPI_RESERVED_BYTE,
139       EFI_ACPI_RESERVED_BYTE},                             // UINT8 Reserved[3]
140      FVP_GT_BLOCK_FRAME1_CTL_BASE,                         // UINT64 CntBaseX
141      FVP_GT_BLOCK_FRAME1_CTL_EL0_BASE,                     // UINT64 CntEL0BaseX
142      FVP_GT_BLOCK_FRAME1_GSIV,                             // UINT32 GTxPhysicalTimerGSIV
143      FVP_GTX_TIMER_FLAGS,                                  // UINT32 GTxPhysicalTimerFlags
144      0,                                                    // UINT32 GTxVirtualTimerGSIV
145      0,                                                    // UINT32 GTxVirtualTimerFlags
146      FVP_GTX_COMMON_FLAGS                                  // UINT32 GTxCommonFlags
147    }
148  },
149  {
150    {
151      EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG,                // UINT8 Type
152      sizeof(EFI_ACPI_6_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), // UINT16 Length
153      EFI_ACPI_RESERVED_BYTE,                                 // UINT8 Reserved
154      FVP_SBSA_WATCHDOG_REFRESH_BASE,                         // UINT64 RefreshFramePhysicalAddress
155      FVP_SBSA_WATCHDOG_CONTROL_BASE,                         // UINT64 WatchdogControlFramePhysicalAddress
156      FVP_SBSA_WATCHDOG_GSIV,                                 // UINT32 WatchdogTimerGSIV
157      FVP_SBSA_WATCHDOG_FLAGS                                 // UINT32 WatchdogTimerFlags
158    }
159  }
160};
161
162//
163// Reference the table being generated to prevent the optimizer from removing the
164// data structure from the executable
165//
166VOID* CONST ReferenceAcpiTable = &Gtdt;
167