Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 1 | /* |
Kevin Peng | e61e705 | 2022-01-27 14:57:06 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __PSA_SERVICE_H__ |
| 9 | #define __PSA_SERVICE_H__ |
| 10 | |
Jamie Fox | 520fb4d | 2019-06-13 14:27:21 +0100 | [diff] [blame] | 11 | #include <stddef.h> |
| 12 | #include <stdint.h> |
| 13 | |
Jamie Fox | 520fb4d | 2019-06-13 14:27:21 +0100 | [diff] [blame] | 14 | #include "psa/client.h" |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 15 | #include "psa_config.h" |
| 16 | #include "psa/error.h" |
Shawn Shan | 038348e | 2021-09-08 17:11:04 +0800 | [diff] [blame] | 17 | #include "psa/framework_feature.h" |
Jamie Fox | 520fb4d | 2019-06-13 14:27:21 +0100 | [diff] [blame] | 18 | |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 23 | /********************** PSA Secure Partition Macros and Types ****************/ |
| 24 | |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 25 | /** |
| 26 | * A timeout value that requests a polling wait operation. |
| 27 | */ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 28 | #define PSA_POLL (0x00000000u) |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * A timeout value that requests a blocking wait operation. |
| 32 | */ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 33 | #define PSA_BLOCK (0x80000000u) |
| 34 | |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 35 | /** |
| 36 | * A mask value that includes all Secure Partition signals. |
| 37 | */ |
| 38 | #define PSA_WAIT_ANY (0xFFFFFFFFu) |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 39 | |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 40 | /** |
| 41 | * The signal number for the Secure Partition doorbell. |
| 42 | */ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 43 | #define PSA_DOORBELL (0x00000008u) |
| 44 | |
| 45 | /* PSA message types */ |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 46 | /* An IPC message type that indicates a new connection. */ |
| 47 | #define PSA_IPC_CONNECT (-1) |
| 48 | /* An IPC message type that indicates the end of a connection. */ |
| 49 | #define PSA_IPC_DISCONNECT (-2) |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 50 | |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 51 | /* FLIH return types */ |
| 52 | #define PSA_FLIH_NO_SIGNAL ((psa_flih_result_t) 0) |
| 53 | #define PSA_FLIH_SIGNAL ((psa_flih_result_t) 1) |
| 54 | |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 55 | /* Store a set of one or more Secure Partition signals */ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 56 | typedef uint32_t psa_signal_t; |
| 57 | |
Kevin Peng | f9a0eb0 | 2021-01-05 15:06:05 +0800 | [diff] [blame] | 58 | /* A type used to temporarily store a previous interrupt state. */ |
| 59 | typedef uint32_t psa_irq_status_t; |
| 60 | |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 61 | /* The type of the return value from an FLIH function */ |
| 62 | typedef uint32_t psa_flih_result_t; |
| 63 | |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 64 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 65 | * Describe a message received by an RoT Service after calling \ref psa_get(). |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 66 | */ |
| 67 | typedef struct psa_msg_t { |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 68 | int32_t type; /* One of the following values: |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 69 | * \ref PSA_IPC_CONNECT |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 70 | * >= 0 |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 71 | * \ref PSA_IPC_DISCONNECT |
| 72 | */ |
| 73 | psa_handle_t handle; /* A reference generated by the SPM to the |
| 74 | * message returned by psa_get(). |
| 75 | */ |
Kevin Peng | e61e705 | 2022-01-27 14:57:06 +0800 | [diff] [blame] | 76 | int32_t client_id; /* |
| 77 | * Partition ID of the sender of the |
| 78 | * message: |
| 79 | * - secure partition id; |
| 80 | * - non secure client endpoint id. |
| 81 | */ |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 82 | void *rhandle; /* Be useful for binding a connection to some |
| 83 | * application-specific data or function |
| 84 | * pointer within the RoT Service |
| 85 | * implementation. |
| 86 | */ |
| 87 | size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input |
| 88 | * vector in bytes. |
| 89 | */ |
| 90 | size_t out_size[PSA_MAX_IOVEC];/* Provide the size of each client output |
| 91 | * vector in bytes. |
| 92 | */ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 93 | } psa_msg_t; |
| 94 | |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 95 | /************************* PSA Secure Partition API **************************/ |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 96 | |
| 97 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 98 | * \brief Return the Secure Partition interrupt signals that have been asserted |
| 99 | * from a subset of signals provided by the caller. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 100 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 101 | * \param[in] signal_mask A set of signals to query. Signals that are not |
| 102 | * in this set will be ignored. |
| 103 | * \param[in] timeout Specify either blocking \ref PSA_BLOCK or |
| 104 | * polling \ref PSA_POLL operation. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 105 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 106 | * \retval >0 At least one signal is asserted. |
| 107 | * \retval 0 No signals are asserted. This is only seen when |
| 108 | * a polling timeout is used. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 109 | */ |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 110 | psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 111 | |
| 112 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 113 | * \brief Retrieve the message which corresponds to a given RoT Service signal |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 114 | * and remove the message from the RoT Service queue. |
| 115 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 116 | * \param[in] signal The signal value for an asserted RoT Service. |
| 117 | * \param[out] msg Pointer to \ref psa_msg_t object for receiving |
| 118 | * the message. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 119 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 120 | * \retval PSA_SUCCESS Success, *msg will contain the delivered |
| 121 | * message. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 122 | * \retval PSA_ERROR_DOES_NOT_EXIST Message could not be delivered. |
| 123 | * \retval "PROGRAMMER ERROR" The call is invalid because one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 124 | * following are true: |
| 125 | * \arg signal has more than a single bit set. |
| 126 | * \arg signal does not correspond to an RoT Service. |
| 127 | * \arg The RoT Service signal is not currently |
| 128 | * asserted. |
| 129 | * \arg The msg pointer provided is not a valid memory |
| 130 | * reference. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 131 | */ |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 132 | psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 133 | |
| 134 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 135 | * \brief Associate some RoT Service private data with a client connection. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 136 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 137 | * \param[in] msg_handle Handle for the client's message. |
| 138 | * \param[in] rhandle Reverse handle allocated by the RoT Service. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 139 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 140 | * \retval void Success, rhandle will be provided with all |
| 141 | * subsequent messages delivered on this |
| 142 | * connection. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 143 | * \retval "PROGRAMMER ERROR" msg_handle is invalid. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 144 | */ |
| 145 | void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle); |
| 146 | |
| 147 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 148 | * \brief Read a message parameter or part of a message parameter from a client |
| 149 | * input vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 150 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 151 | * \param[in] msg_handle Handle for the client's message. |
| 152 | * \param[in] invec_idx Index of the input vector to read from. Must be |
| 153 | * less than \ref PSA_MAX_IOVEC. |
| 154 | * \param[out] buffer Buffer in the Secure Partition to copy the |
| 155 | * requested data to. |
| 156 | * \param[in] num_bytes Maximum number of bytes to be read from the |
| 157 | * client input vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 158 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 159 | * \retval >0 Number of bytes copied. |
| 160 | * \retval 0 There was no remaining data in this input |
| 161 | * vector. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 162 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 163 | * following are true: |
| 164 | * \arg msg_handle is invalid. |
| 165 | * \arg msg_handle does not refer to a |
| 166 | * \ref PSA_IPC_CALL message. |
| 167 | * \arg invec_idx is equal to or greater than |
| 168 | * \ref PSA_MAX_IOVEC. |
| 169 | * \arg the memory reference for buffer is invalid or |
| 170 | * not writable. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 171 | */ |
| 172 | size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx, |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 173 | void *buffer, size_t num_bytes); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 174 | |
| 175 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 176 | * \brief Skip over part of a client input vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 177 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 178 | * \param[in] msg_handle Handle for the client's message. |
| 179 | * \param[in] invec_idx Index of input vector to skip from. Must be |
| 180 | * less than \ref PSA_MAX_IOVEC. |
| 181 | * \param[in] num_bytes Maximum number of bytes to skip in the client |
| 182 | * input vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 183 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 184 | * \retval >0 Number of bytes skipped. |
| 185 | * \retval 0 There was no remaining data in this input |
| 186 | * vector. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 187 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 188 | * following are true: |
| 189 | * \arg msg_handle is invalid. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 190 | * \arg msg_handle does not refer to a request |
| 191 | * message. |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 192 | * \arg invec_idx is equal to or greater than |
| 193 | * \ref PSA_MAX_IOVEC. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 194 | */ |
| 195 | size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes); |
| 196 | |
| 197 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 198 | * \brief Write a message response to a client output vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 199 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 200 | * \param[in] msg_handle Handle for the client's message. |
| 201 | * \param[out] outvec_idx Index of output vector in message to write to. |
| 202 | * Must be less than \ref PSA_MAX_IOVEC. |
| 203 | * \param[in] buffer Buffer with the data to write. |
| 204 | * \param[in] num_bytes Number of bytes to write to the client output |
| 205 | * vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 206 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 207 | * \retval void Success |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 208 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 209 | * following are true: |
| 210 | * \arg msg_handle is invalid. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 211 | * \arg msg_handle does not refer to a request |
| 212 | * message. |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 213 | * \arg outvec_idx is equal to or greater than |
| 214 | * \ref PSA_MAX_IOVEC. |
| 215 | * \arg The memory reference for buffer is invalid. |
| 216 | * \arg The call attempts to write data past the end |
| 217 | * of the client output vector. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 218 | */ |
| 219 | void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 220 | const void *buffer, size_t num_bytes); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 221 | |
| 222 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 223 | * \brief Complete handling of a specific message and unblock the client. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 224 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 225 | * \param[in] msg_handle Handle for the client's message. |
| 226 | * \param[in] status Message result value to be reported to the |
| 227 | * client. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 228 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 229 | * \retval void Success. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 230 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 231 | * following are true: |
| 232 | * \arg msg_handle is invalid. |
| 233 | * \arg An invalid status code is specified for the |
| 234 | * type of message. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 235 | */ |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 236 | void psa_reply(psa_handle_t msg_handle, psa_status_t status); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 237 | |
| 238 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 239 | * \brief Send a PSA_DOORBELL signal to a specific Secure Partition. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 240 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 241 | * \param[in] partition_id Secure Partition ID of the target partition. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 242 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 243 | * \retval void Success. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 244 | * \retval "PROGRAMMER ERROR" partition_id does not correspond to a Secure |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 245 | * Partition. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 246 | */ |
| 247 | void psa_notify(int32_t partition_id); |
| 248 | |
| 249 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 250 | * \brief Clear the PSA_DOORBELL signal. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 251 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 252 | * \retval void Success. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 253 | * \retval "PROGRAMMER ERROR" The Secure Partition's doorbell signal is not |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 254 | * currently asserted. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 255 | */ |
| 256 | void psa_clear(void); |
| 257 | |
| 258 | /** |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 259 | * \brief Inform the SPM that an interrupt has been handled (end of interrupt). |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 260 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 261 | * \param[in] irq_signal The interrupt signal that has been processed. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 262 | * |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 263 | * \retval void Success. |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 264 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 265 | * following are true: |
| 266 | * \arg irq_signal is not an interrupt signal. |
| 267 | * \arg irq_signal indicates more than one signal. |
| 268 | * \arg irq_signal is not currently asserted. |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 269 | * \arg The interrupt is not using SLIH. |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 270 | */ |
Edison Ai | b3e5696 | 2018-09-04 19:12:31 +0800 | [diff] [blame] | 271 | void psa_eoi(psa_signal_t irq_signal); |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 272 | |
Summer Qin | 4b1d03b | 2019-07-02 14:56:08 +0800 | [diff] [blame] | 273 | /** |
| 274 | * \brief Terminate execution within the calling Secure Partition and will not |
| 275 | * return. |
| 276 | * |
| 277 | * \retval "Does not return" |
| 278 | */ |
| 279 | void psa_panic(void); |
| 280 | |
Kevin Peng | f9a0eb0 | 2021-01-05 15:06:05 +0800 | [diff] [blame] | 281 | /** |
| 282 | * \brief Enable an interrupt. |
| 283 | * |
| 284 | * \param[in] irq_signal The signal for the interrupt to be enabled. |
| 285 | * This must have a single bit set, which must be the |
| 286 | * signal value for an interrupt in the calling Secure |
| 287 | * Partition. |
| 288 | * |
| 289 | * \retval void |
| 290 | * \retval "PROGRAMMER ERROR" If one or more of the following are true: |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 291 | * \arg \a irq_signal is not an interrupt signal. |
| 292 | * \arg \a irq_signal indicates more than one signal. |
Kevin Peng | f9a0eb0 | 2021-01-05 15:06:05 +0800 | [diff] [blame] | 293 | */ |
| 294 | void psa_irq_enable(psa_signal_t irq_signal); |
| 295 | |
| 296 | /** |
| 297 | * \brief Disable an interrupt and return the status of the interrupt prior to |
| 298 | * being disabled by this call. |
| 299 | * |
| 300 | * \param[in] irq_signal The signal for the interrupt to be disabled. |
| 301 | * This must have a single bit set, which must be the |
| 302 | * signal value for an interrupt in the calling Secure |
| 303 | * Partition. |
| 304 | * |
| 305 | * \retval 0 The interrupt was disabled prior to this call. |
| 306 | * 1 The interrupt was enabled prior to this call. |
| 307 | * \retval "PROGRAMMER ERROR" If one or more of the following are true: |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 308 | * \arg \a irq_signal is not an interrupt signal. |
| 309 | * \arg \a irq_signal indicates more than one signal. |
Kevin Peng | f9a0eb0 | 2021-01-05 15:06:05 +0800 | [diff] [blame] | 310 | * |
| 311 | * \note The current implementation always return 1. Do not use the return. |
| 312 | */ |
| 313 | psa_irq_status_t psa_irq_disable(psa_signal_t irq_signal); |
| 314 | |
Kevin Peng | 9280ae9 | 2021-01-13 14:42:10 +0800 | [diff] [blame] | 315 | /** |
| 316 | * \brief Reset the signal for an interrupt that is using FLIH handling. |
| 317 | * |
| 318 | * \param[in] irq_signal The interrupt signal to be reset. |
| 319 | * This must have a single bit set, corresponding to a |
| 320 | * currently asserted signal for an interrupt that is |
| 321 | * defined to use FLIH handling. |
| 322 | * |
| 323 | * \retval void |
| 324 | * \retval "Programmer Error" if one or more of the following are true: |
| 325 | * \arg \a irq_signal is not a signal for an interrupt |
| 326 | * that is specified with FLIH handling in the Secure |
| 327 | * Partition manifest. |
| 328 | * \arg \a irq_signal indicates more than one signal. |
| 329 | * \arg \a irq_signal is not currently asserted. |
| 330 | */ |
| 331 | void psa_reset_signal(psa_signal_t irq_signal); |
| 332 | |
Shawn Shan | 038348e | 2021-09-08 17:11:04 +0800 | [diff] [blame] | 333 | #if PSA_FRAMEWORK_HAS_MM_IOVEC |
| 334 | |
| 335 | /** |
| 336 | * \brief Map a client input vector for direct access by a Secure Partition RoT |
| 337 | * Service. |
| 338 | * |
| 339 | * \param[in] msg_handle Handle for the client's message. |
| 340 | * \param[in] invec_idx Index of input vector to map. Must be |
| 341 | * less than \ref PSA_MAX_IOVEC. |
| 342 | * |
| 343 | * \retval A pointer to the input vector data. |
| 344 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
| 345 | * following are true: |
| 346 | * \arg MM-IOVEC has not been enabled for the RoT |
| 347 | * Service that received the message. |
| 348 | * \arg msg_handle is invalid. |
| 349 | * \arg msg_handle does not refer to a request |
| 350 | * message. |
| 351 | * \arg invec_idx is equal to or greater than |
| 352 | * \ref PSA_MAX_IOVEC. |
| 353 | * \arg The input vector has length zero. |
| 354 | * \arg The input vector has already been mapped using |
| 355 | * psa_map_invec(). |
| 356 | * \arg The input vector has already been accessed |
| 357 | * using psa_read() or psa_skip(). |
| 358 | */ |
| 359 | const void *psa_map_invec(psa_handle_t msg_handle, uint32_t invec_idx); |
| 360 | |
| 361 | /** |
| 362 | * \brief Unmap a previously mapped client input vector from a Secure Partition |
| 363 | * RoT Service. |
| 364 | * |
| 365 | * \param[in] msg_handle Handle for the client's message. |
| 366 | * \param[in] invec_idx Index of input vector to map. Must be |
| 367 | * less than \ref PSA_MAX_IOVEC. |
| 368 | * |
| 369 | * \retval void |
| 370 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
| 371 | * following are true: |
| 372 | * \arg msg_handle is invalid. |
| 373 | * \arg msg_handle does not refer to a request |
| 374 | * message. |
| 375 | * \arg invec_idx is equal to or greater than |
| 376 | * \ref PSA_MAX_IOVEC. |
| 377 | * \arg The input vector has not been mapped by a call |
| 378 | * to psa_map_invec(). |
| 379 | * \arg The input vector has already been unmapped by |
| 380 | * a call to psa_unmap_invec(). |
| 381 | */ |
| 382 | void psa_unmap_invec(psa_handle_t msg_handle, uint32_t invec_idx); |
| 383 | |
| 384 | /** |
| 385 | * \brief Map a client output vector for direct access by a Secure Partition RoT |
| 386 | * Service. |
| 387 | * |
| 388 | * \param[in] msg_handle Handle for the client's message. |
| 389 | * \param[in] outvec_idx Index of output vector to map. Must be |
| 390 | * less than \ref PSA_MAX_IOVEC. |
| 391 | * |
| 392 | * \retval A pointer to the output vector data. |
| 393 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
| 394 | * following are true: |
| 395 | * \arg MM-IOVEC has not been enabled for the RoT |
| 396 | * Service that received the message. |
| 397 | * \arg msg_handle is invalid. |
| 398 | * \arg msg_handle does not refer to a request |
| 399 | * message. |
| 400 | * \arg outvec_idx is equal to or greater than |
| 401 | * \ref PSA_MAX_IOVEC. |
| 402 | * \arg The output vector has length zero. |
| 403 | * \arg The output vector has already been mapped |
| 404 | * using psa_map_outvec(). |
| 405 | * \arg The output vector has already been accessed |
| 406 | * using psa_write(). |
| 407 | */ |
| 408 | void *psa_map_outvec(psa_handle_t msg_handle, uint32_t outvec_idx); |
| 409 | |
| 410 | /** |
| 411 | * \brief Unmap a previously mapped client output vector from a Secure Partition |
| 412 | * RoT Service. |
| 413 | * |
| 414 | * \param[in] msg_handle Handle for the client's message. |
| 415 | * \param[in] outvec_idx Index of output vector to map. Must be |
| 416 | * less than \ref PSA_MAX_IOVEC. |
| 417 | * \param[in] len The number of bytes written to the output |
| 418 | * vector. This must be less than or equal to the |
| 419 | * size of the output vector. |
| 420 | * |
| 421 | * \retval void |
| 422 | * \retval "PROGRAMMER ERROR" The call is invalid, one or more of the |
| 423 | * following are true: |
| 424 | * \arg msg_handle is invalid. |
| 425 | * \arg msg_handle does not refer to a request |
| 426 | * message. |
| 427 | * \arg outvec_idx is equal to or greater than |
| 428 | * \ref PSA_MAX_IOVEC. |
| 429 | * \arg The output vector has not been mapped by a |
| 430 | * call to psa_map_outvec(). |
| 431 | * \arg The output vector has already been unmapped by |
| 432 | * a call to psa_unmap_outvec(). |
| 433 | */ |
| 434 | void psa_unmap_outvec(psa_handle_t msg_handle, uint32_t outvec_idx, size_t len); |
| 435 | |
| 436 | #endif /* PSA_FRAMEWORK_HAS_MM_IOVEC */ |
| 437 | |
Miklos Balint | 9ecb24c | 2018-03-29 15:30:28 +0200 | [diff] [blame] | 438 | #ifdef __cplusplus |
| 439 | } |
| 440 | #endif |
| 441 | |
| 442 | #endif /* __PSA_SERVICE_H__ */ |