1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
|