Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 1 | /* |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /** |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 19 | * \brief Include all the SVC handler headers |
| 20 | */ |
| 21 | #include "tfm_sst_svc_handler.h" |
Antonio de Angelis | cc657b3 | 2018-02-05 15:56:47 +0000 | [diff] [blame] | 22 | #include "tfm_log_svc_handler.h" |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 23 | #include "svc_core_test_ns.h" |
| 24 | #include "sst_test_service_svc.h" |
| 25 | |
| 26 | /** |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 27 | * \brief Macro to encode an svc instruction |
| 28 | * |
| 29 | */ |
| 30 | #define SVC(code) __ASM("svc %0" : : "I" (code)) |
| 31 | |
| 32 | /** |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 33 | * \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) \ |
| 46 | X(SVC_TFM_SST_GET_ATTRIBUTES, tfm_sst_svc_get_attributes) \ |
| 47 | X(SVC_TFM_SST_READ, tfm_sst_svc_read) \ |
| 48 | X(SVC_TFM_SST_WRITE, tfm_sst_svc_write) \ |
Antonio de Angelis | f1c0851 | 2018-02-05 14:55:09 +0000 | [diff] [blame] | 49 | X(SVC_TFM_SST_DELETE, tfm_sst_svc_delete) \ |
Antonio de Angelis | 9a5bfea | 2018-03-27 13:13:55 +0100 | [diff] [blame^] | 50 | X(SVC_TFM_LOG_RETRIEVE, tfm_log_svc_retrieve) \ |
| 51 | X(SVC_TFM_LOG_GET_INFO, tfm_log_svc_get_info) \ |
| 52 | X(SVC_TFM_LOG_DELETE_ITEMS, tfm_log_svc_delete_items) |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * \def LIST_SVC_CORE_TEST_INTERACTIVE |
| 56 | * |
| 57 | * \brief This is an X macro which lists |
| 58 | * the SVC interface available for |
| 59 | * the CORE_TEST_INTERACTIVE. The |
| 60 | * enumerator and corresponding |
| 61 | * SVC handler function need to be |
| 62 | * registered. |
| 63 | * |
| 64 | */ |
| 65 | #define LIST_SVC_CORE_TEST_INTERACTIVE \ |
| 66 | X(SVC_SECURE_DECREMENT_NS_LOCK_1, svc_secure_decrement_ns_lock_1) \ |
| 67 | X(SVC_SECURE_DECREMENT_NS_LOCK_2, svc_secure_decrement_ns_lock_2) |
| 68 | |
| 69 | /** |
| 70 | * \def LIST_SVC_TFM_PARTITION_TEST_CORE |
| 71 | * |
| 72 | * \brief This is an X macro which lists |
| 73 | * the SVC interface available for |
| 74 | * the TEST_CORE partition. The |
| 75 | * enumerator and corresponding |
| 76 | * SVC handler function need to be |
| 77 | * registered. |
| 78 | * |
| 79 | */ |
| 80 | #define LIST_SVC_TFM_PARTITION_TEST_CORE \ |
| 81 | X(SVC_TFM_CORE_TEST, svc_tfm_core_test) \ |
| 82 | X(SVC_TFM_CORE_TEST_MULTIPLE_CALLS, svc_tfm_core_test_multiple_calls) |
| 83 | |
| 84 | /** |
| 85 | * \def LIST_SVC_TFM_PARTITION_TEST_SST |
| 86 | * |
| 87 | * \brief This is an X macro which lists |
| 88 | * the SVC interface available for |
| 89 | * TEST_SST partition. The |
| 90 | * enumerator and corresponding |
| 91 | * SVC handler function need to be |
| 92 | * registered. |
| 93 | * |
| 94 | */ |
| 95 | #define LIST_SVC_TFM_PARTITION_TEST_SST \ |
| 96 | X(SVC_SST_TEST_SERVICE_SETUP, sst_test_service_svc_setup) \ |
| 97 | X(SVC_SST_TEST_SERVICE_DUMMY_ENCRYPT, sst_test_service_svc_dummy_encrypt) \ |
| 98 | X(SVC_SST_TEST_SERVICE_DUMMY_DECRYPT, sst_test_service_svc_dummy_decrypt) \ |
| 99 | X(SVC_SST_TEST_SERVICE_CLEAN, sst_test_service_svc_clean) |
| 100 | |
| 101 | /** |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 102 | * \brief Numbers associated to each SVC available |
| 103 | * |
| 104 | * \details Start from 1 as 0 is reserved by RTX |
| 105 | */ |
| 106 | enum tfm_svc_num { |
| 107 | SVC_INVALID = 0, |
| 108 | |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 109 | #define X(SVC_ENUM, SVC_HANDLER) SVC_ENUM, |
| 110 | /* SVC API for Services */ |
| 111 | LIST_SVC_DISPATCHERS |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 112 | |
| 113 | #if defined(CORE_TEST_INTERACTIVE) |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 114 | LIST_SVC_CORE_TEST_INTERACTIVE |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 115 | #endif /* CORE_TEST_INTERACTIVE */ |
| 116 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 117 | #if defined(TFM_PARTITION_TEST_CORE) |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 118 | LIST_SVC_TFM_PARTITION_TEST_CORE |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 119 | #endif /* TFM_PARTITION_TEST_CORE */ |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 120 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 121 | #if defined(TFM_PARTITION_TEST_SST) |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 122 | LIST_SVC_TFM_PARTITION_TEST_SST |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 123 | #endif /* TFM_PARTITION_TEST_SST */ |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 124 | |
Antonio de Angelis | d9cd66e | 2018-03-27 11:19:59 +0100 | [diff] [blame] | 125 | #undef X |
| 126 | |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 127 | /* add all the new entries above this line */ |
| 128 | SVC_TFM_MAX, |
| 129 | }; |
| 130 | |
| 131 | /* number of user SVC functions */ |
| 132 | #define USER_SVC_COUNT (SVC_TFM_MAX - 1) |
| 133 | |
| 134 | #ifdef __cplusplus |
| 135 | } |
| 136 | #endif |
| 137 | |
| 138 | #endif /* __TFM_NS_SVC_H__ */ |