feat: test if errata 2938996 and 2726228 workaround is applied

This patch confirms if access to trbe el1 register generates an undef
injection in affected cores. If a core is affected by errata 2938996/
2726228 and it generates an undef injection on access to trbe el1 register then
the test passes. If it is an unaffected core then the test passes , but
when undef injection doesn't happen in affected core, the test fails.

Change-Id: I515a9aa4613c6d99ee73e579206089ebf89ffae8
Signed-off-by: Arvind Ram Prakash <arvind.ramprakash@arm.com>
Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index 6a0b08b..adcac3d 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -160,3 +160,22 @@
 {
 	return ((unsigned long long)rand() << 32) | rand();
 }
+
+/* Check if TRBE erratums 2938996 and 2726228 applies */
+bool is_trbe_errata_affected_core(void)
+{
+        long midr_val = read_midr();
+        long rev_var = EXTRACT_REV_VAR(midr_val);
+
+        if(EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_A520_MIDR)) {
+                if(RXPX_RANGE(rev_var, 0, 1)) {
+                        return true;
+                }
+        } else if (EXTRACT_PARTNUM(midr_val) == EXTRACT_PARTNUM(CORTEX_X4_MIDR)) {
+                if(RXPX_RANGE(rev_var, 0, 1)) {
+                        return true;
+                }
+        }
+
+        return false;
+}