diff options
Diffstat (limited to 'aarch64/el0_common/el0_common.h')
-rw-r--r-- | aarch64/el0_common/el0_common.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/aarch64/el0_common/el0_common.h b/aarch64/el0_common/el0_common.h new file mode 100644 index 0000000..58ad537 --- /dev/null +++ b/aarch64/el0_common/el0_common.h @@ -0,0 +1,65 @@ +#ifndef __EL0_COMMON_H +#define __EL0_COMMON_H + +#include "libcflat.h" +#include "svc.h" +#include "syscntl.h" +#include "armv8_exception.h" +#include "arm_builtins.h" +#include "el0.h" +#include "debug.h" + +/* Make the below globals volatile as found that the compiler uses the + * register value ratherh than the memory value making it look like the writes + * actually happened. + */ + +extern sys_control_t *syscntl; + +#define INC_TEST_COUNT() (syscntl->test_cntl->test_count += 1) +#define INC_FAIL_COUNT() (syscntl->test_cntl->fail_count += 1) + +#define TEST_CONDITION(_cond) \ + do { \ + if (!(_cond)) { \ + printf("FAILED\n"); \ + INC_FAIL_COUNT(); \ + } else { \ + printf("PASSED\n"); \ + } \ + INC_TEST_COUNT(); \ + } while(0) + +#define TEST_FUNCTION(_fn, _cond) \ + do { \ + _fn; \ + TEST_CONDITION(_cond); \ + } while(0) + +#define TEST_EXCEPTION(_fn, _excp, _el) \ + do { \ + syscntl->_el.ec = 0; \ + syscntl->excp_action = EXCP_ACTION_SKIP; \ + syscntl->excp_log = true; \ + _fn; \ + TEST_CONDITION(syscntl->_el.taken && \ + syscntl->_el.ec == (_excp)); \ + syscntl->_el.taken = 0; \ + syscntl->excp_action = 0; \ + syscntl->_el.ec = 0; \ + } while (0) + +#define TEST_EL1S_EXCEPTION(_fn, _excp) \ + TEST_EXCEPTION(_fn, _excp, el1_excp[SEC]) +#define TEST_EL1NS_EXCEPTION(_fn, _excp) \ + TEST_EXCEPTION(_fn, _excp, el1_excp[NSEC]) +#define TEST_EL3_EXCEPTION(_fn, _excp) \ + TEST_EXCEPTION(_fn, _excp, el3_excp) + +extern uint32_t P0_nonsecure_check_smc(); +extern uint32_t P0_check_register_access(); +extern uint32_t P0_check_trap_to_EL3(); +extern void *alloc_mem(int type, size_t len); +extern void map_va(void *va, size_t len, int type); + +#endif |