* [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer
@ 2023-09-20 14:33 Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SbsaQemu: move IORT structures to header file Marcin Juszkiewicz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-09-20 14:33 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Graeme Gregory, Marcin Juszkiewicz
Arm BSA (Base System Architecture) specification requires Armv8.1+ cpus
to have non-secure EL2 virtual timer. Which we lacked.
In previous week I wrote a small patch to QEMU which enabled it for SBSA
Reference Platform. Leif Lindholm refactored code around timers to make
it more readable.
Then he added missing timer into EDK2 ArmPkg and to "virt" platform.
This patchset enables NS EL2 virtual timer on SBSA Reference Platform.
changes since v1:
- GTDT generated from C
- NS EL2 virtual timer is disabled for Arm v8.0 cpus
Marcin Juszkiewicz (2):
Silicon/SbsaQemu: move IORT structures to header file
Silicon/SbsaQemu: generate GTDT from C
.../Qemu/SbsaQemu/AcpiTables/AcpiTables.inf | 1 -
.../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 6 +
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 66 +++++++++
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 125 ++++++++++++++----
Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc | 107 ---------------
5 files changed, 174 insertions(+), 131 deletions(-)
create mode 100644 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
delete mode 100644 Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc
--
2.41.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108913): https://edk2.groups.io/g/devel/message/108913
Mute This Topic: https://groups.io/mt/101479611/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
* [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SbsaQemu: move IORT structures to header file
2023-09-20 14:33 [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Marcin Juszkiewicz
@ 2023-09-20 14:33 ` Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 2/2] Silicon/SbsaQemu: generate GTDT from C Marcin Juszkiewicz
2023-09-22 15:22 ` [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-09-20 14:33 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Graeme Gregory, Marcin Juszkiewicz
There are more and more things in SbsaQemuAcpiDxe.c file which
should be elsewhere.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 37 +++++++++++++++++++
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 24 +-----------
2 files changed, 38 insertions(+), 23 deletions(-)
create mode 100644 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
new file mode 100644
index 000000000000..f13ee3f738c2
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
@@ -0,0 +1,37 @@
+/** @file
+* This file is an ACPI driver for the Qemu SBSA platform.
+*
+* Copyright (c) Linaro Ltd. All rights reserved.
+*
+* SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#ifndef SBSAQEMU_ACPI_DXE_H
+#define SBSAQEMU_ACPI_DXE_H
+
+typedef struct {
+ EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE Node;
+ UINT32 Identifiers;
+} SBSA_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE;
+
+typedef struct
+{
+ EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE SmmuNode;
+ EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE SmmuIdMap;
+} SBSA_EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE;
+
+typedef struct
+{
+ EFI_ACPI_6_0_IO_REMAPPING_RC_NODE RcNode;
+ EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE RcIdMap;
+} SBSA_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE;
+
+typedef struct {
+ EFI_ACPI_6_0_IO_REMAPPING_TABLE Iort;
+ SBSA_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE ItsNode;
+ SBSA_EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE SmmuNode;
+ SBSA_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE RcNode;
+} SBSA_IO_REMAPPING_STRUCTURE;
+
+#endif
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index 3bc25a6e3540..e52256616936 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -21,32 +21,10 @@
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Protocol/AcpiTable.h>
+#include "SbsaQemuAcpiDxe.h"
#pragma pack(1)
-typedef struct {
- EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE Node;
- UINT32 Identifiers;
-} SBSA_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE;
-
-typedef struct
-{
- EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE SmmuNode;
- EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE SmmuIdMap;
-} SBSA_EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE;
-
-typedef struct
-{
- EFI_ACPI_6_0_IO_REMAPPING_RC_NODE RcNode;
- EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE RcIdMap;
-} SBSA_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE;
-
-typedef struct {
- EFI_ACPI_6_0_IO_REMAPPING_TABLE Iort;
- SBSA_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE ItsNode;
- SBSA_EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE SmmuNode;
- SBSA_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE RcNode;
-} SBSA_IO_REMAPPING_STRUCTURE;
static UINTN GicItsBase;
--
2.41.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108914): https://edk2.groups.io/g/devel/message/108914
Mute This Topic: https://groups.io/mt/101479612/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [edk2-devel] [PATCH edk2-platforms 2/2] Silicon/SbsaQemu: generate GTDT from C
2023-09-20 14:33 [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SbsaQemu: move IORT structures to header file Marcin Juszkiewicz
@ 2023-09-20 14:33 ` Marcin Juszkiewicz
2023-09-22 15:22 ` [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Marcin Juszkiewicz @ 2023-09-20 14:33 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Graeme Gregory, Marcin Juszkiewicz
We need to have some conditional code while generating GTDT due
to adding non-secure EL2 virtual timer.
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../Qemu/SbsaQemu/AcpiTables/AcpiTables.inf | 1 -
.../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 6 +
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 29 +++++
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 101 +++++++++++++++++
Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc | 107 ------------------
5 files changed, 136 insertions(+), 108 deletions(-)
delete mode 100644 Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index 97021f7971c7..61ff3dff3356 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -19,7 +19,6 @@ [Sources]
Dbg2.aslc
Dsdt.asl
Fadt.aslc
- Gtdt.aslc
Mcfg.aslc
Spcr.aslc
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
index 14d760b36400..19f186f4310c 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
@@ -68,3 +68,9 @@ [FixedPcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+
+ gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
+ gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
+ gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
+ gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
+ gArmTokenSpaceGuid.PcdArmArchTimerHypVirtIntrNum
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
index f13ee3f738c2..7c9074b10960 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
@@ -34,4 +34,33 @@ typedef struct {
SBSA_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE RcNode;
} SBSA_IO_REMAPPING_STRUCTURE;
+typedef struct {
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE mGtdt;
+ EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE mGwdt;
+} GENERIC_TIMER_DESCRIPTION_TABLES;
+
+#ifndef SYSTEM_TIMER_BASE_ADDRESS
+ #define SYSTEM_TIMER_BASE_ADDRESS MAX_ADDRESS
+#endif
+
+#define GTDT_TIMER_LEVEL_TRIGGERED 0
+#define GTDT_TIMER_ACTIVE_LOW EFI_ACPI_6_3_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
+#define GTDT_TIMER_ALWAYS_ON EFI_ACPI_6_3_GTDT_TIMER_FLAG_ALWAYS_ON_CAPABILITY
+
+#define GTDT_GTIMER_FLAGS (GTDT_TIMER_ACTIVE_LOW | \
+ GTDT_TIMER_LEVEL_TRIGGERED | \
+ GTDT_TIMER_ALWAYS_ON)
+
+#define SBSA_PLATFORM_WATCHDOG_COUNT 1
+#define SBSA_PLATFORM_TIMER_COUNT (SBSA_PLATFORM_WATCHDOG_COUNT)
+
+#define SBSAQEMU_WDT_REFRESH_FRAME_BASE 0x50010000
+#define SBSAQEMU_WDT_CONTROL_FRAME_BASE 0x50011000
+#define SBSAQEMU_WDT_IRQ 48
+
+#define GTDT_WDTIMER_LEVEL_TRIGGERED 0
+#define GTDT_WDTIMER_ACTIVE_HIGH 0
+
+#define GTDT_WDTIMER_FLAGS (GTDT_WDTIMER_ACTIVE_HIGH | GTDT_WDTIMER_LEVEL_TRIGGERED)
+
#endif
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index e52256616936..1f10214e264b 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -11,6 +11,7 @@
#include <IndustryStandard/IoRemappingTable.h>
#include <IndustryStandard/SbsaQemuAcpi.h>
#include <Library/AcpiLib.h>
+#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtHelperLib.h>
@@ -586,6 +587,101 @@ AddPpttTable (
return Status;
}
+/*
+ * A function that adds the GTDT ACPI table.
+ */
+EFI_STATUS
+AddGtdtTable (
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
+ )
+{
+ EFI_STATUS Status;
+ UINTN TableHandle;
+ UINT32 TableSize;
+ EFI_PHYSICAL_ADDRESS PageAddress;
+ UINT8 *New;
+
+ TableSize = sizeof (EFI_ACPI_6_5_GENERIC_TIMER_DESCRIPTION_TABLE) +
+ sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE);
+
+ Status = gBS->AllocatePages (
+ AllocateAnyPages,
+ EfiACPIReclaimMemory,
+ EFI_SIZE_TO_PAGES (TableSize),
+ &PageAddress
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to allocate pages for GTDT table\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt = {
+
+ SBSAQEMU_ACPI_HEADER (
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+ GENERIC_TIMER_DESCRIPTION_TABLES,
+ EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION),
+
+ SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddress
+ 0, // UINT32 Reserved
+ FixedPcdGet32 (PcdArmArchTimerSecIntrNum), // UINT32 SecurePL1TimerGSIV
+ GTDT_GTIMER_FLAGS, // UINT32 SecurePL1TimerFlags
+ FixedPcdGet32 (PcdArmArchTimerIntrNum), // UINT32 NonSecurePL1TimerGSIV
+ GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1TimerFlags
+ FixedPcdGet32 (PcdArmArchTimerVirtIntrNum), // UINT32 VirtualTimerGSIV
+ GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerFlags
+ FixedPcdGet32 (PcdArmArchTimerHypIntrNum), // UINT32 NonSecurePL2TimerGSIV
+ GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2TimerFlags
+ MAX_ADDRESS, // UINT64 CntReadBasePhysicalAddress
+ SBSA_PLATFORM_TIMER_COUNT, // UINT32 PlatformTimerCount
+ sizeof(EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE),
+ // UINT32 PlatformTimerOffset
+ FixedPcdGet32 (PcdArmArchTimerHypVirtIntrNum),// UINT32 VirtualPL2TimerGSIV
+ GTDT_GTIMER_FLAGS // UINT32 VirtualPL2TimerFlags
+ };
+
+ // Non-secure EL2 virtual timer requires VHE support (v8.1+)
+ if (! ArmHasVhe()) {
+ Gtdt.VirtualPL2TimerGSIV = 0;
+ Gtdt.VirtualPL2TimerFlags = 0;
+ }
+
+ EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE Gwdt = {
+ EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG,
+ sizeof(EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE),
+ EFI_ACPI_RESERVED_WORD,
+ SBSAQEMU_WDT_REFRESH_FRAME_BASE,
+ SBSAQEMU_WDT_CONTROL_FRAME_BASE,
+ SBSAQEMU_WDT_IRQ,
+ GTDT_WDTIMER_FLAGS
+ };
+
+ New = (UINT8 *)(UINTN) PageAddress;
+ ZeroMem (New, TableSize);
+
+ CopyMem (New, &Gtdt, sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE));
+ New += sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE);
+
+ CopyMem (New, &Gwdt, sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE));
+ New += sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE);
+
+ // Perform Checksum
+ AcpiPlatformChecksum ((UINT8*) PageAddress, TableSize);
+
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ (EFI_ACPI_COMMON_HEADER *)PageAddress,
+ TableSize,
+ &TableHandle
+ );
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to install GTDT table\n"));
+ }
+
+ return Status;
+}
+
EFI_STATUS
EFIAPI
InitializeSbsaQemuAcpiDxe (
@@ -637,5 +733,10 @@ InitializeSbsaQemuAcpiDxe (
DEBUG ((DEBUG_ERROR, "Failed to add PPTT table\n"));
}
+ Status = AddGtdtTable (AcpiTable);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to add GTDT table\n"));
+ }
+
return EFI_SUCCESS;
}
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc b/Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc
deleted file mode 100644
index ba145aff6413..000000000000
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
-* Generic Timer Description Table (GTDT)
-*
-* Copyrignt (c) 2020, Linaro Limited. All rights reserved.
-*
-* SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Library/AcpiLib.h>
-#include <Library/PcdLib.h>
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/SbsaQemuAcpi.h>
-
-#define GTDT_GLOBAL_FLAGS_MAPPED EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_MEMORY_MAPPED_BLOCK_PRESENT
-#define GTDT_GLOBAL_FLAGS_NOT_MAPPED 0
-#define GTDT_GLOBAL_FLAGS_EDGE EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_INTERRUPT_MODE
-#define GTDT_GLOBAL_FLAGS_LEVEL 0
-
-// Note: We could have a build flag that switches between memory mapped/non-memory mapped timer
-#ifdef SYSTEM_TIMER_BASE_ADDRESS
- #define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
-#else
- #define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_NOT_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
- #define SYSTEM_TIMER_BASE_ADDRESS 0xFFFFFFFFFFFFFFFF
-#endif
-
-#define GTDT_TIMER_EDGE_TRIGGERED EFI_ACPI_6_3_GTDT_TIMER_FLAG_TIMER_INTERRUPT_MODE
-#define GTDT_TIMER_LEVEL_TRIGGERED 0
-#define GTDT_TIMER_ACTIVE_LOW EFI_ACPI_6_3_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
-#define GTDT_TIMER_ACTIVE_HIGH 0
-#define GTDT_TIMER_ALWAYS_ON EFI_ACPI_6_3_GTDT_TIMER_FLAG_ALWAYS_ON_CAPABILITY
-
-#define GTDT_GTIMER_FLAGS (GTDT_TIMER_ACTIVE_LOW | \
- GTDT_TIMER_LEVEL_TRIGGERED | \
- GTDT_TIMER_ALWAYS_ON)
-
-#define SBSA_PLATFORM_WATCHDOG_COUNT 1
-#define SBSA_PLATFORM_TIMER_COUNT (SBSA_PLATFORM_WATCHDOG_COUNT)
-
-#define SBSAQEMU_WDT_REFRESH_FRAME_BASE 0x50010000
-#define SBSAQEMU_WDT_CONTROL_FRAME_BASE 0x50011000
-#define SBSAQEMU_WDT_IRQ 48
-
-#define GTDT_WDTIMER_EDGE_TRIGGERED EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_TIMER_INTERRUPT_MODE
-#define GTDT_WDTIMER_LEVEL_TRIGGERED 0
-#define GTDT_WDTIMER_ACTIVE_LOW EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_FLAG_TIMER_INTERRUPT_POLARITY
-#define GTDT_WDTIMER_ACTIVE_HIGH 0
-
-#define GTDT_WDTIMER_FLAGS (GTDT_WDTIMER_ACTIVE_HIGH | GTDT_WDTIMER_LEVEL_TRIGGERED)
-
-#define EFI_ACPI_6_3_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT( \
- RefreshFramePhysicalAddress, ControlFramePhysicalAddress, \
- WatchdogTimerGSIV, WatchdogTimerFlags) \
- { \
- EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG, \
- sizeof(EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
- EFI_ACPI_RESERVED_WORD, \
- RefreshFramePhysicalAddress, \
- ControlFramePhysicalAddress, \
- WatchdogTimerGSIV, \
- WatchdogTimerFlags \
- }
-
- #pragma pack (1)
-
- typedef struct {
- EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
- EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE Gwdt;
- } GENERIC_TIMER_DESCRIPTION_TABLES;
-
- #pragma pack ()
-
- GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
- {
- SBSAQEMU_ACPI_HEADER(
- EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
- GENERIC_TIMER_DESCRIPTION_TABLES,
- EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
- ),
- SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddress
- 0, // UINT32 Reserved
- FixedPcdGet32 (PcdArmArchTimerSecIntrNum), // UINT32 SecurePL1TimerGSIV
- GTDT_GTIMER_FLAGS, // UINT32 SecurePL1TimerFlags
- FixedPcdGet32 (PcdArmArchTimerIntrNum), // UINT32 NonSecurePL1TimerGSIV
- GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1TimerFlags
- FixedPcdGet32 (PcdArmArchTimerVirtIntrNum), // UINT32 VirtualTimerGSIV
- GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerFlags
- FixedPcdGet32 (PcdArmArchTimerHypIntrNum), // UINT32 NonSecurePL2TimerGSIV
- GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2TimerFlags
- 0xFFFFFFFFFFFFFFFF, // UINT64 CntReadBasePhysicalAddress
- SBSA_PLATFORM_TIMER_COUNT, // UINT32 PlatformTimerCount
- sizeof(EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE),
- // UINT32 PlatformTimerOffset
- 0, // UINT32 VirtualPL2TimerGSIV
- 0 // UINT32 VirtualPL2TimerFlags
- },
- EFI_ACPI_6_3_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(
- SBSAQEMU_WDT_REFRESH_FRAME_BASE,
- SBSAQEMU_WDT_CONTROL_FRAME_BASE,
- SBSAQEMU_WDT_IRQ,
- GTDT_WDTIMER_FLAGS
- )
- };
-
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-VOID* CONST ReferenceAcpiTable = &Gtdt;
--
2.41.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108915): https://edk2.groups.io/g/devel/message/108915
Mute This Topic: https://groups.io/mt/101479615/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer
2023-09-20 14:33 [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SbsaQemu: move IORT structures to header file Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 2/2] Silicon/SbsaQemu: generate GTDT from C Marcin Juszkiewicz
@ 2023-09-22 15:22 ` Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Leif Lindholm @ 2023-09-22 15:22 UTC (permalink / raw)
To: Marcin Juszkiewicz; +Cc: devel, Ard Biesheuvel, Graeme Gregory
On Wed, Sep 20, 2023 at 16:33:16 +0200, Marcin Juszkiewicz wrote:
> Arm BSA (Base System Architecture) specification requires Armv8.1+ cpus
> to have non-secure EL2 virtual timer. Which we lacked.
>
> In previous week I wrote a small patch to QEMU which enabled it for SBSA
> Reference Platform. Leif Lindholm refactored code around timers to make
> it more readable.
>
> Then he added missing timer into EDK2 ArmPkg and to "virt" platform.
>
> This patchset enables NS EL2 virtual timer on SBSA Reference Platform.
>
> changes since v1:
> - GTDT generated from C
> - NS EL2 virtual timer is disabled for Arm v8.0 cpus
For the series:
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Pushed as 88ea1c2b62d4..f3f7d3a1b41e.
Thanks!
> Marcin Juszkiewicz (2):
> Silicon/SbsaQemu: move IORT structures to header file
> Silicon/SbsaQemu: generate GTDT from C
>
> .../Qemu/SbsaQemu/AcpiTables/AcpiTables.inf | 1 -
> .../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 6 +
> .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 66 +++++++++
> .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 125 ++++++++++++++----
> Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc | 107 ---------------
> 5 files changed, 174 insertions(+), 131 deletions(-)
> create mode 100644 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
> delete mode 100644 Silicon/Qemu/SbsaQemu/AcpiTables/Gtdt.aslc
>
> --
> 2.41.0
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109014): https://edk2.groups.io/g/devel/message/109014
Mute This Topic: https://groups.io/mt/101479611/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-22 15:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 14:33 [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SbsaQemu: move IORT structures to header file Marcin Juszkiewicz
2023-09-20 14:33 ` [edk2-devel] [PATCH edk2-platforms 2/2] Silicon/SbsaQemu: generate GTDT from C Marcin Juszkiewicz
2023-09-22 15:22 ` [edk2-devel] [PATCH v2 edk2-platforms 0/2] define NS EL2 virtual timer Leif Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox