summaryrefslogtreecommitdiffstats
path: root/lib/extensions/trf
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extensions/trf')
-rw-r--r--lib/extensions/trf/aarch32/trf.c24
-rw-r--r--lib/extensions/trf/aarch64/trf.c40
2 files changed, 64 insertions, 0 deletions
diff --git a/lib/extensions/trf/aarch32/trf.c b/lib/extensions/trf/aarch32/trf.c
new file mode 100644
index 0000000..321c089
--- /dev/null
+++ b/lib/extensions/trf/aarch32/trf.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdbool.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <lib/extensions/trf.h>
+
+void trf_init_el3(void)
+{
+ uint32_t val;
+
+ /*
+ * Allow access of trace filter control registers from
+ * non-monitor mode.
+ */
+ val = read_sdcr();
+ val &= ~(SDCR_TTRF_BIT);
+ write_sdcr(val);
+}
diff --git a/lib/extensions/trf/aarch64/trf.c b/lib/extensions/trf/aarch64/trf.c
new file mode 100644
index 0000000..83fbf85
--- /dev/null
+++ b/lib/extensions/trf/aarch64/trf.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch.h>
+#include <arch_features.h>
+#include <arch_helpers.h>
+#include <lib/extensions/trf.h>
+
+void trf_init_el3(void)
+{
+ u_register_t val;
+
+ /*
+ * MDCR_EL3.STE = b0
+ * Trace prohibited in Secure state unless overridden by the
+ * IMPLEMENTATION DEFINED authentication interface.
+ *
+ * MDCR_EL3.TTRF = b0
+ * Allow access of trace filter control registers from NS-EL2
+ * and NS-EL1 when NS-EL2 is implemented but not used
+ */
+ val = read_mdcr_el3();
+ val &= ~(MDCR_STE_BIT | MDCR_TTRF_BIT);
+ write_mdcr_el3(val);
+}
+
+void trf_init_el2_unused(void)
+{
+ /*
+ * MDCR_EL2.TTRF: Set to zero so that access to Trace
+ * Filter Control register TRFCR_EL1 at EL1 is not
+ * trapped to EL2. This bit is RES0 in versions of
+ * the architecture earlier than ARMv8.4.
+ *
+ */
+ write_mdcr_el2(read_mdcr_el2() & ~MDCR_EL2_TTRF);
+}