1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4  */
5 
6 #ifndef INSTR_HELPERS_H
7 #define INSTR_HELPERS_H
8 
9 #include <host_harness.h>
10 #include <stddef.h>
11 
12 /**********************************************************************
13  * Macros which create inline functions to read or write CPU system
14  * registers
15  *********************************************************************/
16 #define DEFINE_SYSREG_READ_FUNC_(_name, _reg_name)		\
17 static inline u_register_t read_ ## _name(void)			\
18 {								\
19 	return host_read_sysreg(#_name);					\
20 }
21 
22 #define DEFINE_SYSREG_WRITE_FUNC_(_name, _reg_name)		\
23 static inline void write_ ## _name(u_register_t v)		\
24 {								\
25 	host_write_sysreg(#_name, v);				\
26 }
27 
28 #define SYSREG_WRITE_CONST(reg_name, v)				\
29 		host_write_sysreg(#reg_name, v)
30 
31 /**********************************************************************
32  * Macros to create inline functions for system instructions
33  *********************************************************************/
34 
35 /* Define function for simple system instruction */
36 #define DEFINE_SYSOP_FUNC(_op)				\
37 static inline void (_op)(void)				\
38 {							\
39 	(void)_op;					\
40 }
41 
42 /* Define function for system instruction with register parameter */
43 #define DEFINE_SYSOP_PARAM_FUNC(_op)			\
44 static inline void (_op)(uint64_t v)			\
45 {							\
46 	(void)v; /* To avoid MISRA-C:2012-2.7 warnings */ \
47 }
48 
49 /* Define function for system instruction with type specifier */
50 #define DEFINE_SYSOP_TYPE_FUNC(_op, _type)		\
51 static inline void (_op ## _type)(void)			\
52 {							\
53 }
54 
55 /* Define function for system instruction with register parameter */
56 #define DEFINE_SYSOP_TYPE_PARAM_FUNC(_op, _type)	\
57 static inline void (_op ## _type)(uint64_t v)		\
58 {							\
59 	(void)v; /* To avoid MISRA-C:2012-2.7 warnings */ \
60 }
61 
62 #define dsb(scope)
63 #define dmb(scope)
64 
65 #endif /* INSTR_HELPERS_H */
66