blob: b283dc62a15d6a1ca7a2f8dc5e67643d1e096505 [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Jamie Fox5592db02017-12-18 16:48:29 +00002 * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
Ashutosh Singhf4d88672017-11-29 13:35:43 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include <stdio.h>
9#include <cmsis_compiler.h>
10
11#ifndef __TFM_NS_SVC_H__
12#define __TFM_NS_SVC_H__
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/**
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010019 * \brief Include all the SVC handler headers
20 */
21#include "tfm_sst_svc_handler.h"
Antonio de Angeliscc657b32018-02-05 15:56:47 +000022#include "tfm_log_svc_handler.h"
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010023#include "svc_core_test_ns.h"
24#include "sst_test_service_svc.h"
25
26/**
Ashutosh Singhf4d88672017-11-29 13:35:43 +000027 * \brief Macro to encode an svc instruction
28 *
29 */
30#define SVC(code) __ASM("svc %0" : : "I" (code))
31
32/**
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010033 * \def LIST_SVC_DISPATCHERS
34 *
35 * \brief This is an X macro which lists
36 * the SVC interface exposed by the
37 * available secure services. The
38 * enumerator and corresponding
39 * SVC handler function need to be
40 * registered.
41 *
42 */
43#define LIST_SVC_DISPATCHERS \
44 X(SVC_TFM_SST_GET_HANDLE, tfm_sst_svc_get_handle) \
45 X(SVC_TFM_SST_CREATE, tfm_sst_svc_create) \
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010046 X(SVC_TFM_SST_GET_INFO, tfm_sst_svc_get_info) \
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010047 X(SVC_TFM_SST_GET_ATTRIBUTES, tfm_sst_svc_get_attributes) \
48 X(SVC_TFM_SST_SET_ATTRIBUTES, tfm_sst_svc_set_attributes) \
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010049 X(SVC_TFM_SST_READ, tfm_sst_svc_read) \
50 X(SVC_TFM_SST_WRITE, tfm_sst_svc_write) \
Antonio de Angelisf1c08512018-02-05 14:55:09 +000051 X(SVC_TFM_SST_DELETE, tfm_sst_svc_delete) \
Antonio de Angelis9a5bfea2018-03-27 13:13:55 +010052 X(SVC_TFM_LOG_RETRIEVE, tfm_log_svc_retrieve) \
53 X(SVC_TFM_LOG_GET_INFO, tfm_log_svc_get_info) \
54 X(SVC_TFM_LOG_DELETE_ITEMS, tfm_log_svc_delete_items)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010055
56/**
57 * \def LIST_SVC_CORE_TEST_INTERACTIVE
58 *
59 * \brief This is an X macro which lists
60 * the SVC interface available for
61 * the CORE_TEST_INTERACTIVE. The
62 * enumerator and corresponding
63 * SVC handler function need to be
64 * registered.
65 *
66 */
67#define LIST_SVC_CORE_TEST_INTERACTIVE \
68 X(SVC_SECURE_DECREMENT_NS_LOCK_1, svc_secure_decrement_ns_lock_1) \
69 X(SVC_SECURE_DECREMENT_NS_LOCK_2, svc_secure_decrement_ns_lock_2)
70
71/**
72 * \def LIST_SVC_TFM_PARTITION_TEST_CORE
73 *
74 * \brief This is an X macro which lists
75 * the SVC interface available for
76 * the TEST_CORE partition. The
77 * enumerator and corresponding
78 * SVC handler function need to be
79 * registered.
80 *
81 */
82#define LIST_SVC_TFM_PARTITION_TEST_CORE \
83 X(SVC_TFM_CORE_TEST, svc_tfm_core_test) \
84 X(SVC_TFM_CORE_TEST_MULTIPLE_CALLS, svc_tfm_core_test_multiple_calls)
85
86/**
87 * \def LIST_SVC_TFM_PARTITION_TEST_SST
88 *
89 * \brief This is an X macro which lists
90 * the SVC interface available for
91 * TEST_SST partition. The
92 * enumerator and corresponding
93 * SVC handler function need to be
94 * registered.
95 *
96 */
97#define LIST_SVC_TFM_PARTITION_TEST_SST \
98 X(SVC_SST_TEST_SERVICE_SETUP, sst_test_service_svc_setup) \
99 X(SVC_SST_TEST_SERVICE_DUMMY_ENCRYPT, sst_test_service_svc_dummy_encrypt) \
100 X(SVC_SST_TEST_SERVICE_DUMMY_DECRYPT, sst_test_service_svc_dummy_decrypt) \
101 X(SVC_SST_TEST_SERVICE_CLEAN, sst_test_service_svc_clean)
102
103/**
Ben Davis6d7256b2018-04-18 14:16:53 +0100104 * \def LIST_SVC_TFM_PARTITION_TEST_SECURE_SERVICES
105 *
106 * \brief This is an X macro which lists
107 * the SVC interface available for
108 * TEST_SECURE_SERVICES partition.
109 * The enumerator and corresponding
110 * SVC handler function need to be
111 * registered.
112 *
113 */
114#define LIST_SVC_TFM_PARTITION_TEST_SECURE_SERVICES \
115 X(SVC_TFM_SECURE_CLIENT_RUN_TESTS, tfm_secure_client_service_svc_run_tests)
116
117/**
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000118 * \brief Numbers associated to each SVC available
119 *
120 * \details Start from 1 as 0 is reserved by RTX
121 */
122enum tfm_svc_num {
123 SVC_INVALID = 0,
124
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +0100125#define X(SVC_ENUM, SVC_HANDLER) SVC_ENUM,
126 /* SVC API for Services */
127 LIST_SVC_DISPATCHERS
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000128
129#if defined(CORE_TEST_INTERACTIVE)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +0100130 LIST_SVC_CORE_TEST_INTERACTIVE
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000131#endif /* CORE_TEST_INTERACTIVE */
132
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100133#if defined(TFM_PARTITION_TEST_CORE)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +0100134 LIST_SVC_TFM_PARTITION_TEST_CORE
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100135#endif /* TFM_PARTITION_TEST_CORE */
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000136
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100137#if defined(TFM_PARTITION_TEST_SST)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +0100138 LIST_SVC_TFM_PARTITION_TEST_SST
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100139#endif /* TFM_PARTITION_TEST_SST */
Jamie Fox5592db02017-12-18 16:48:29 +0000140
Ben Davis6d7256b2018-04-18 14:16:53 +0100141#if defined(TFM_PARTITION_TEST_SECURE_SERVICES)
142 LIST_SVC_TFM_PARTITION_TEST_SECURE_SERVICES
143#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
144
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +0100145#undef X
146
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000147 /* add all the new entries above this line */
148 SVC_TFM_MAX,
149};
150
151/* number of user SVC functions */
152#define USER_SVC_COUNT (SVC_TFM_MAX - 1)
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif /* __TFM_NS_SVC_H__ */