refactor(lib/smc): Move COMPILER_ASSERTs to separate file
To make the RMI header file simpler, the COMPILER_ASSERTs in rmi
header file are moved to a separate C file and compiled as part of
rmm-lib compilation unit. This allows easier sharing of RMI header
with other software entities which need to invoke RMI calls.
Signed-off-by: Yousuf A <yousuf.sait@arm.com>
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I12522587b7ee792500f24099072e861962c0c8f1
diff --git a/lib/smc/CMakeLists.txt b/lib/smc/CMakeLists.txt
index 4e733c1..2db2782 100644
--- a/lib/smc/CMakeLists.txt
+++ b/lib/smc/CMakeLists.txt
@@ -14,7 +14,8 @@
if(NOT RMM_ARCH STREQUAL fake_host)
target_sources(rmm-lib-smc
- PRIVATE "src/aarch64/smc.S")
+ PRIVATE "src/aarch64/smc.S"
+ "src/smc-rmi-offsets.c")
else()
target_sources(rmm-lib-smc
PRIVATE "src/fake_host/smc_wrapper.c")
diff --git a/lib/smc/include/smc-rmi.h b/lib/smc/include/smc-rmi.h
index f7c3e03..00ac669 100644
--- a/lib/smc/include/smc-rmi.h
+++ b/lib/smc/include/smc-rmi.h
@@ -7,7 +7,6 @@
#ifndef SMC_RMI_H
#define SMC_RMI_H
-#include <stddef.h>
#include <smc.h>
/*
@@ -272,16 +271,6 @@
}, 0x800, 0x1000);
};
-COMPILER_ASSERT(sizeof(struct rmi_realm_params) == 0x1000);
-
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, features_0) == 0);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, hash_algo) == 0x100);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, rpv) == 0x400);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, vmid) == 0x800);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_base) == 0x808);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_level_start) == 0x810);
-COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_num_start) == 0x818);
-
/*
* The REC attribute parameters are shared by the Host via
* MI_REC_CREATE::params_ptr. The values can be observed or modified
@@ -304,15 +293,6 @@
}, 0x800, 0x1000);
};
-COMPILER_ASSERT(sizeof(struct rmi_rec_params) == 0x1000);
-
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, flags) == 0);
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, mpidr) == 0x100);
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, pc) == 0x200);
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, gprs) == 0x300);
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, num_aux) == 0x800);
-COMPILER_ASSERT(offsetof(struct rmi_rec_params, aux) == 0x808);
-
/*
* Structure contains data passed from the Host to the RMM on REC entry
*/
@@ -329,13 +309,6 @@
}, 0x300, 0x800);
};
-COMPILER_ASSERT(sizeof(struct rmi_rec_entry) == 0x800);
-
-COMPILER_ASSERT(offsetof(struct rmi_rec_entry, flags) == 0);
-COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gprs) == 0x200);
-COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_hcr) == 0x300);
-COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_lrs) == 0x308);
-
/*
* Structure contains data passed from the RMM to the Host on REC exit
*/
@@ -384,26 +357,6 @@
SET_MEMBER(unsigned int imm, 0x600, 0x800); /* 0x600 */
};
-COMPILER_ASSERT(sizeof(struct rmi_rec_exit) == 0x800);
-
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, exit_reason) == 0);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, esr) == 0x100);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, far) == 0x108);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, hpfar) == 0x110);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gprs) == 0x200);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_hcr) == 0x300);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_lrs) == 0x308);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_misr) == 0x388);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_vmcr) == 0x390);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntp_ctl) == 0x400);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntp_cval) == 0x408);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntv_ctl) == 0x410);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntv_cval) == 0x418);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_base) == 0x500);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_size) == 0x508);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_value) == 0x510);
-COMPILER_ASSERT(offsetof(struct rmi_rec_exit, imm) == 0x600);
-
/*
* Structure contains shared information between RMM and Host
* during REC entry and REC exit.
@@ -415,9 +368,4 @@
SET_MEMBER(struct rmi_rec_exit exit, 0x800, 0x1000); /* 0x800 */
};
-COMPILER_ASSERT(sizeof(struct rmi_rec_run) <= GRANULE_SIZE);
-
-COMPILER_ASSERT(offsetof(struct rmi_rec_run, entry) == 0);
-COMPILER_ASSERT(offsetof(struct rmi_rec_run, exit) == 0x800);
-
#endif /* SMC_RMI_H */
diff --git a/lib/smc/src/smc-rmi-offsets.c b/lib/smc/src/smc-rmi-offsets.c
new file mode 100644
index 0000000..4750dac
--- /dev/null
+++ b/lib/smc/src/smc-rmi-offsets.c
@@ -0,0 +1,54 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+ */
+
+#include <smc-rmi.h>
+#include <stddef.h>
+
+COMPILER_ASSERT(sizeof(struct rmi_realm_params) == 0x1000);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, features_0) == 0);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, hash_algo) == 0x100);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, rpv) == 0x400);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, vmid) == 0x800);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_base) == 0x808);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_level_start) == 0x810);
+COMPILER_ASSERT(offsetof(struct rmi_realm_params, rtt_num_start) == 0x818);
+
+
+COMPILER_ASSERT(sizeof(struct rmi_rec_params) == 0x1000);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, flags) == 0);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, mpidr) == 0x100);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, pc) == 0x200);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, gprs) == 0x300);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, num_aux) == 0x800);
+COMPILER_ASSERT(offsetof(struct rmi_rec_params, aux) == 0x808);
+
+COMPILER_ASSERT(sizeof(struct rmi_rec_entry) == 0x800);
+COMPILER_ASSERT(offsetof(struct rmi_rec_entry, flags) == 0);
+COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gprs) == 0x200);
+COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_hcr) == 0x300);
+COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_lrs) == 0x308);
+
+
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, exit_reason) == 0);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, esr) == 0x100);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, far) == 0x108);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, hpfar) == 0x110);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gprs) == 0x200);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_hcr) == 0x300);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_lrs) == 0x308);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_misr) == 0x388);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, gicv3_vmcr) == 0x390);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntp_ctl) == 0x400);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntp_cval) == 0x408);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntv_ctl) == 0x410);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, cntv_cval) == 0x418);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_base) == 0x500);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_size) == 0x508);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, ripas_value) == 0x510);
+COMPILER_ASSERT(offsetof(struct rmi_rec_exit, imm) == 0x600);
+
+COMPILER_ASSERT(sizeof(struct rmi_rec_run) <= GRANULE_SIZE);
+COMPILER_ASSERT(offsetof(struct rmi_rec_run, entry) == 0);
+COMPILER_ASSERT(offsetof(struct rmi_rec_run, exit) == 0x800);