1/** @file 2* Generic Timer Description Table (GTDT) 3* 4* Copyright (c) 2012 - 2014, ARM Limited. All rights reserved. 5* Copyright (c) 2015, Hisilicon Limited. All rights reserved. 6* Copyright (c) 2015, 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 "Pv660Platform.h" 21 22#include <Library/AcpiLib.h> 23#include <Library/PcdLib.h> 24#include <IndustryStandard/Acpi.h> 25 26#define GTDT_GLOBAL_FLAGS_MAPPED EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_MEMORY_MAPPED_BLOCK_PRESENT 27#define GTDT_GLOBAL_FLAGS_NOT_MAPPED 0 28#define GTDT_GLOBAL_FLAGS_EDGE EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_INTERRUPT_MODE 29#define GTDT_GLOBAL_FLAGS_LEVEL 0 30 31// Note: We could have a build flag that switches between memory mapped/non-memory mapped timer 32#ifdef SYSTEM_TIMER_BASE_ADDRESS 33 #define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL) 34#else 35 #define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_NOT_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL) 36 #define SYSTEM_TIMER_BASE_ADDRESS 0xFFFFFFFFFFFFFFFF 37#endif 38 39#define GTDT_TIMER_EDGE_TRIGGERED EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_MODE 40#define GTDT_TIMER_LEVEL_TRIGGERED 0 41#define GTDT_TIMER_ACTIVE_LOW EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY 42#define GTDT_TIMER_ACTIVE_HIGH 0 43 44#define GTDT_GTIMER_FLAGS (GTDT_TIMER_ACTIVE_LOW | GTDT_TIMER_LEVEL_TRIGGERED) 45 46#pragma pack (1) 47 48typedef struct { 49 EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt; 50 EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE Watchdogs[PV660_WATCHDOG_COUNT]; 51} EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES; 52 53#pragma pack () 54 55EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = { 56 { 57 ARM_ACPI_HEADER( 58 EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, 59 EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES, 60 EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION 61 ), 62 SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddress 63 0, // UINT32 Reserved 64 FixedPcdGet32 (PcdArmArchTimerSecIntrNum), // UINT32 SecurePL1TimerGSIV 65 GTDT_GTIMER_FLAGS, // UINT32 SecurePL1TimerFlags 66 FixedPcdGet32 (PcdArmArchTimerIntrNum), // UINT32 NonSecurePL1TimerGSIV 67 GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1TimerFlags 68 FixedPcdGet32 (PcdArmArchTimerVirtIntrNum), // UINT32 VirtualTimerGSIV 69 GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerFlags 70 FixedPcdGet32 (PcdArmArchTimerHypIntrNum), // UINT32 NonSecurePL2TimerGSIV 71 GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2TimerFlags 72 0xFFFFFFFFFFFFFFFF, // UINT64 CntReadBasePhysicalAddress 73#ifdef notyet 74 PV660_WATCHDOG_COUNT, // UINT32 PlatformTimerCount 75 sizeof (EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE) // UINT32 PlatfromTimerOffset 76 }, 77 { 78 EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT( 79 //FixedPcdGet32 (PcdGenericWatchdogRefreshBase), FixedPcdGet32 (PcdGenericWatchdogControlBase), 93, 0), 80 0, 0, 0, 0), 81 EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT( 82 //FixedPcdGet32 (PcdGenericWatchdogRefreshBase), FixedPcdGet32 (PcdGenericWatchdogControlBase), 94, EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_SECURE_TIMER) 83 0, 0, 0, 0) 84 } 85#else /* !notyet */ 86 0, 0 87 } 88#endif 89 }; 90 91// 92// Reference the table being generated to prevent the optimizer from removing the 93// data structure from the executable 94// 95VOID* CONST ReferenceAcpiTable = &Gtdt; 96 97