TF-RMM Release v0.1.0
This is the first external release of TF-RMM and provides a reference
implementation of Realm Management Monitor (RMM) as specified by the
RMM Beta0 specification[1].
The `docs/readme.rst` has more details about the project and
`docs/getting_started/getting-started.rst` has details on how to get
started with TF-RMM.
[1] https://developer.arm.com/documentation/den0137/1-0bet0/?lang=en
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I205ef14c015e4a37ae9ae1a64e4cd22eb8da746e
diff --git a/lib/arch/src/fpu_helpers.c b/lib/arch/src/fpu_helpers.c
new file mode 100644
index 0000000..70f79d9
--- /dev/null
+++ b/lib/arch/src/fpu_helpers.c
@@ -0,0 +1,51 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+ */
+
+#include <cpuid.h>
+#include <fpu_helpers.h>
+#include <stdbool.h>
+
+struct rmm_fpu_state {
+ struct fpu_state state;
+ bool saved;
+};
+
+struct rmm_fpu_state rmm_fpu_state[MAX_CPUS];
+
+#ifdef RMM_FPU_USE_AT_REL2
+void fpu_save_my_state(void)
+{
+ struct rmm_fpu_state *rmm_state;
+ unsigned int cpu_id = my_cpuid();
+
+ rmm_state = rmm_fpu_state + cpu_id;
+ assert(!rmm_state->saved);
+ rmm_state->saved = true;
+ FPU_ALLOW(fpu_save_state(&(rmm_state->state)));
+}
+
+void fpu_restore_my_state(void)
+{
+ struct rmm_fpu_state *rmm_state;
+ unsigned int cpu_id = my_cpuid();
+
+ rmm_state = rmm_fpu_state + cpu_id;
+ assert(rmm_state->saved);
+ FPU_ALLOW(fpu_restore_state(&(rmm_state->state)));
+ rmm_state->saved = false;
+}
+
+bool fpu_is_my_state_saved(unsigned int cpu_id)
+{
+ assert(cpu_id < MAX_CPUS);
+ return rmm_fpu_state[cpu_id].saved;
+}
+
+#else /* RMM_FPU_USE_AT_REL2 */
+void fpu_save_my_state(void) {}
+
+void fpu_restore_my_state(void) {}
+
+#endif /* RMM_FPU_USE_AT_REL2 */