aboutsummaryrefslogtreecommitdiff
path: root/test/test_services/tfm_core_test/core_test_defs.h
blob: 11c11892ad445569ddb41256a800cfca1c993b5f (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#ifndef __CORE_TEST_DEFS_H__
#define __CORE_TEST_DEFS_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <inttypes.h>
#include <limits.h>
#include "tfm_api.h"
#include "secure_fw/core/tfm_core.h"

/* These definitions are used in symbols, only digits are permitted */
#define CORE_TEST_ID_NS_THREAD            1001
#define CORE_TEST_ID_CHECK_INIT           1003
#define CORE_TEST_ID_RECURSION            1004
#define CORE_TEST_ID_MEMORY_PERMISSIONS   1005
#define CORE_TEST_ID_MPU_ACCESS           1006
#define CORE_TEST_ID_BUFFER_CHECK         1007
#define CORE_TEST_ID_SS_TO_SS             1008
#define CORE_TEST_ID_SHARE_REDIRECTION    1009
#define CORE_TEST_ID_SS_TO_SS_BUFFER      1010
#define CORE_TEST_ID_PERIPHERAL_ACCESS    1012
#define CORE_TEST_ID_GET_CALLER_CLIENT_ID 1013
#define CORE_TEST_ID_SPM_REQUEST          1014
#define CORE_TEST_ID_IOVEC_SANITIZATION   1015
#define CORE_TEST_ID_OUTVEC_WRITE         1016
#define CORE_TEST_ID_SECURE_IRQ           1017
#define CORE_TEST_ID_BLOCK                2001

enum irq_test_scenario_t {
    IRQ_TEST_SCENARIO_NONE,
    IRQ_TEST_SCENARIO_1,
    IRQ_TEST_SCENARIO_2,
    IRQ_TEST_SCENARIO_3,
    IRQ_TEST_SCENARIO_4,
    IRQ_TEST_SCENARIO_5,
};

struct irq_test_execution_data_t {
    volatile int32_t timer0_triggered;
    volatile int32_t timer1_triggered;
};

/* Use lower 16 bits in return value for error code, upper 16 for line number
 * in test service
 */
#define CORE_TEST_RETURN_ERROR(x) return (((__LINE__) << 16) | x)
#define CORE_TEST_ERROR_GET_EXTRA(x) (x >> 16)
#define CORE_TEST_ERROR_GET_CODE(x) (x & 0xFFFF)

enum core_test_errno_t {
    CORE_TEST_ERRNO_TEST_NOT_SUPPORTED         = -13,
    CORE_TEST_ERRNO_SP_NOT_INITED              = -12,
    CORE_TEST_ERRNO_UNEXPECTED_CORE_BEHAVIOUR  = -11,
    CORE_TEST_ERRNO_SP_RECURSION_NOT_REJECTED  = -10,
    CORE_TEST_ERRNO_INVALID_BUFFER             = -9,
    CORE_TEST_ERRNO_SLAVE_SP_CALL_FAILURE      = -8,
    CORE_TEST_ERRNO_SLAVE_SP_BUFFER_FAILURE    = -7,
    CORE_TEST_ERRNO_FIRST_CALL_FAILED          = -6,
    CORE_TEST_ERRNO_SECOND_CALL_FAILED         = -5,
    CORE_TEST_ERRNO_PERIPHERAL_ACCESS_FAILED   = -4,
    CORE_TEST_ERRNO_TEST_FAULT                 = -3,
    CORE_TEST_ERRNO_INVALID_TEST_ID            = -2,
    CORE_TEST_ERRNO_INVALID_PARAMETER          = -1,

    CORE_TEST_ERRNO_SUCCESS                    =  0,

    CORE_TEST_ERRNO_SUCCESS_2                  =  1,

    /* Following entry is only to ensure the error code of int size */
    CORE_TEST_ERRNO_FORCE_INT_SIZE = INT_MAX
};

#ifdef __cplusplus
}
#endif

#endif /* __CORE_TEST_DEFS_H__ */