Mistake on this page?
Report an issue in GitHub or email us
psa_service.h
1 /*
2  * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __PSA_SERVICE_H__
9 #define __PSA_SERVICE_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <inttypes.h>
16 
17 /********************** PSA Secure Partition Macros and Types ****************/
18 
19 /* PSA wait timeouts */
20 #define PSA_POLL (0x00000000u)
21 #define PSA_BLOCK (0x80000000u)
22 
23 /* A mask value that includes all Secure Partition signals */
24 #define PSA_WAIT_ANY (~0u)
25 
26 /* Doorbell signal */
27 #define PSA_DOORBELL (0x00000008u)
28 
29 /* PSA message types */
30 #define PSA_IPC_CONNECT (1)
31 #define PSA_IPC_CALL (2)
32 #define PSA_IPC_DISCONNECT (3)
33 
34 /* Maximum number of input and output vectors */
35 #define PSA_MAX_IOVEC (4)
36 
37 /* Return code from psa_get() */
38 #define PSA_ERR_NOMSG (INT32_MIN + 3)
39 
40 /* Store a set of one or more Secure Partition signals */
41 typedef uint32_t psa_signal_t;
42 
43 /**
44  * Describe a message received by an RoT Service after calling \ref psa_get().
45  */
46 typedef struct psa_msg_t {
47  uint32_t type; /* One of the following values:
48  * \ref PSA_IPC_CONNECT
49  * \ref PSA_IPC_CALL
50  * \ref PSA_IPC_DISCONNECT
51  */
52  psa_handle_t handle; /* A reference generated by the SPM to the
53  * message returned by psa_get().
54  */
55  int32_t client_id; /* Partition ID of the sender of the message */
56  void *rhandle; /* Be useful for binding a connection to some
57  * application-specific data or function
58  * pointer within the RoT Service
59  * implementation.
60  */
61  size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input
62  * vector in bytes.
63  */
64  size_t out_size[PSA_MAX_IOVEC];/* Provide the size of each client output
65  * vector in bytes.
66  */
67 } psa_msg_t;
68 
69 /************************* PSA Secure Partition API **************************/
70 
71 /**
72  * \brief Return the Secure Partition interrupt signals that have been asserted
73  * from a subset of signals provided by the caller.
74  *
75  * \param[in] signal_mask A set of signals to query. Signals that are not
76  * in this set will be ignored.
77  * \param[in] timeout Specify either blocking \ref PSA_BLOCK or
78  * polling \ref PSA_POLL operation.
79  *
80  * \retval >0 At least one signal is asserted.
81  * \retval 0 No signals are asserted. This is only seen when
82  * a polling timeout is used.
83  */
84 psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout);
85 
86 /**
87  * \brief Retrieve the message which corresponds to a given RoT Service signal
88  * and remove the message from the RoT Service queue.
89  *
90  * \param[in] signal The signal value for an asserted RoT Service.
91  * \param[out] msg Pointer to \ref psa_msg_t object for receiving
92  * the message.
93  *
94  * \retval PSA_SUCCESS Success, *msg will contain the delivered
95  * message.
96  * \retval PSA_ERR_NOMSG Message could not be delivered.
97  * \retval "Does not return" The call is invalid because one or more of the
98  * following are true:
99  * \arg signal has more than a single bit set.
100  * \arg signal does not correspond to an RoT Service.
101  * \arg The RoT Service signal is not currently
102  * asserted.
103  * \arg The msg pointer provided is not a valid memory
104  * reference.
105  */
106 psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg);
107 
108 /**
109  * \brief Associate some RoT Service private data with a client connection.
110  *
111  * \param[in] msg_handle Handle for the client's message.
112  * \param[in] rhandle Reverse handle allocated by the RoT Service.
113  *
114  * \retval void Success, rhandle will be provided with all
115  * subsequent messages delivered on this
116  * connection.
117  * \retval "Does not return" msg_handle is invalid.
118  */
119 void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle);
120 
121 /**
122  * \brief Read a message parameter or part of a message parameter from a client
123  * input vector.
124  *
125  * \param[in] msg_handle Handle for the client's message.
126  * \param[in] invec_idx Index of the input vector to read from. Must be
127  * less than \ref PSA_MAX_IOVEC.
128  * \param[out] buffer Buffer in the Secure Partition to copy the
129  * requested data to.
130  * \param[in] num_bytes Maximum number of bytes to be read from the
131  * client input vector.
132  *
133  * \retval >0 Number of bytes copied.
134  * \retval 0 There was no remaining data in this input
135  * vector.
136  * \retval "Does not return" The call is invalid, one or more of the
137  * following are true:
138  * \arg msg_handle is invalid.
139  * \arg msg_handle does not refer to a
140  * \ref PSA_IPC_CALL message.
141  * \arg invec_idx is equal to or greater than
142  * \ref PSA_MAX_IOVEC.
143  * \arg the memory reference for buffer is invalid or
144  * not writable.
145  */
146 size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
147  void *buffer, size_t num_bytes);
148 
149 /**
150  * \brief Skip over part of a client input vector.
151  *
152  * \param[in] msg_handle Handle for the client's message.
153  * \param[in] invec_idx Index of input vector to skip from. Must be
154  * less than \ref PSA_MAX_IOVEC.
155  * \param[in] num_bytes Maximum number of bytes to skip in the client
156  * input vector.
157  *
158  * \retval >0 Number of bytes skipped.
159  * \retval 0 There was no remaining data in this input
160  * vector.
161  * \retval "Does not return" The call is invalid, one or more of the
162  * following are true:
163  * \arg msg_handle is invalid.
164  * \arg msg_handle does not refer to a
165  * \ref PSA_IPC_CALL message.
166  * \arg invec_idx is equal to or greater than
167  * \ref PSA_MAX_IOVEC.
168  */
169 size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes);
170 
171 /**
172  * \brief Write a message response to a client output vector.
173  *
174  * \param[in] msg_handle Handle for the client's message.
175  * \param[out] outvec_idx Index of output vector in message to write to.
176  * Must be less than \ref PSA_MAX_IOVEC.
177  * \param[in] buffer Buffer with the data to write.
178  * \param[in] num_bytes Number of bytes to write to the client output
179  * vector.
180  *
181  * \retval void Success
182  * \retval "Does not return" The call is invalid, one or more of the
183  * following are true:
184  * \arg msg_handle is invalid.
185  * \arg msg_handle does not refer to a
186  * \ref PSA_IPC_CALL message.
187  * \arg outvec_idx is equal to or greater than
188  * \ref PSA_MAX_IOVEC.
189  * \arg The memory reference for buffer is invalid.
190  * \arg The call attempts to write data past the end
191  * of the client output vector.
192  */
193 void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
194  const void *buffer, size_t num_bytes);
195 
196 /**
197  * \brief Complete handling of a specific message and unblock the client.
198  *
199  * \param[in] msg_handle Handle for the client's message.
200  * \param[in] status Message result value to be reported to the
201  * client.
202  *
203  * \retval void Success.
204  * \retval "Does not return" The call is invalid, one or more of the
205  * following are true:
206  * \arg msg_handle is invalid.
207  * \arg An invalid status code is specified for the
208  * type of message.
209  */
210 void psa_reply(psa_handle_t msg_handle, psa_status_t status);
211 
212 /**
213  * \brief Send a PSA_DOORBELL signal to a specific Secure Partition.
214  *
215  * \param[in] partition_id Secure Partition ID of the target partition.
216  *
217  * \retval void Success.
218  * \retval "Does not return" partition_id does not correspond to a Secure
219  * Partition.
220  */
221 void psa_notify(int32_t partition_id);
222 
223 /**
224  * \brief Clear the PSA_DOORBELL signal.
225  *
226  * \retval void Success.
227  * \retval "Does not return" The Secure Partition's doorbell signal is not
228  * currently asserted.
229  */
230 void psa_clear(void);
231 
232 /**
233  * \brief Inform the SPM that an interrupt has been handled (end of interrupt).
234  *
235  * \param[in] irq_signal The interrupt signal that has been processed.
236  *
237  * \retval void Success.
238  * \retval "Does not return" The call is invalid, one or more of the
239  * following are true:
240  * \arg irq_signal is not an interrupt signal.
241  * \arg irq_signal indicates more than one signal.
242  * \arg irq_signal is not currently asserted.
243  */
244 void psa_eoi(psa_signal_t irq_signal);
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 #endif /* __PSA_SERVICE_H__ */
void psa_eoi(uint32_t irq_signal)
Inform the SPM that an interrupt has been handled (end of interrupt).
size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes)
Advance the current read offset by skipping num_bytes bytes for input vector indexed by @а invec_idx...
Describe a message received by an RoT Service after calling psa_get().
Definition: psa_service.h:46
void psa_reply(psa_handle_t msg_handle, psa_status_t status)
Complete handling of specific message and unblocks the client.
size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx, void *buf, size_t num_bytes)
Copy up to len bytes from position offset within the client message payload into the Secure Partition...
void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle)
Associate the caller-provided private data with a specified handle.
psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
Return the signals that have been asserted.
psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg)
Get the message that corresponds to a given signal.
void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer, size_t num_bytes)
Write a response payload of bytes bytes starting at position offset in the client&#39;s response buffer...
void psa_clear(void)
Clear the doorbell signal.
struct psa_msg psa_msg_t
Structure containing the PSA IPC message sent from a client partition to an RoT Service.
#define PSA_MAX_IOVEC
Maximum number of psa_invec and psa_outvec structures allowed for psa_call().
Definition: psa_defs.h:54
void psa_notify(int32_t partition_id)
Send a doorbell signal to a specific partition that is listening for that signal type.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.