feat(sme): add sme helper routines and add streaming sve support
This patch adds a few helper routines to set the Streaming SVE vector
length (SVL) in the SMCR_EL2 register, to enable/disable FEAT_SME_FA64
and to get CPU's Streaming SVE mode status.
This patch also makes SVE compare routines compatible for both normal
SVE and streaming SVE mode.
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
Change-Id: I7294bb17a85de395a321e99241704066662c90e8
diff --git a/include/lib/extensions/sme.h b/include/lib/extensions/sme.h
index 99372e4..4a7e9b7 100644
--- a/include/lib/extensions/sme.h
+++ b/include/lib/extensions/sme.h
@@ -7,9 +7,14 @@
#ifndef SME_H
#define SME_H
+#include <stdlib.h> /* for rand() */
+
#define MAX_VL (512)
#define MAX_VL_B (MAX_VL / 8)
-#define SME_SMCR_LEN_MAX U(0x1FF)
+#define SME_SVQ_ARCH_MAX (MASK(SMCR_ELX_LEN) >> SMCR_ELX_LEN_SHIFT)
+
+/* get a random Streaming SVE VQ b/w 0 to SME_SVQ_ARCH_MAX */
+#define SME_GET_RANDOM_SVQ (rand() % (SME_SVQ_ARCH_MAX + 1))
typedef enum {
SMSTART, /* enters streaming sve mode and enables SME ZA array */
@@ -34,5 +39,10 @@
void sme_ZA_to_vector(const uint64_t *output_vector);
void sme2_load_zt0_instruction(const uint64_t *inputbuf);
void sme2_store_zt0_instruction(const uint64_t *outputbuf);
+void sme_config_svq(uint32_t svq);
+void sme_enable_fa64(void);
+void sme_disable_fa64(void);
+bool sme_smstat_sm(void);
+bool sme_feat_fa64_enabled(void);
#endif /* SME_H */
diff --git a/include/lib/extensions/sve.h b/include/lib/extensions/sve.h
index 4458001..5670afc 100644
--- a/include/lib/extensions/sve.h
+++ b/include/lib/extensions/sve.h
@@ -9,6 +9,7 @@
#include <arch.h>
#include <stdlib.h> /* for rand() */
+#include <lib/extensions/sme.h>
#define fill_sve_helper(num) "ldr z"#num", [%0, #"#num", MUL VL];"
#define read_sve_helper(num) "str z"#num", [%0, #"#num", MUL VL];"