TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
service.h
Go to the documentation of this file.
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 #include <stddef.h>
12 #include <stdint.h>
13 
14 #include "psa/error.h"
15 #include "psa/client.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /********************** PSA Secure Partition Macros and Types ****************/
22 
26 #define PSA_POLL (0x00000000u)
27 
31 #define PSA_BLOCK (0x80000000u)
32 
36 #define PSA_WAIT_ANY (0xFFFFFFFFu)
37 
41 #define PSA_DOORBELL (0x00000008u)
42 
43 /* PSA message types */
44 /* An IPC message type that indicates a new connection. */
45 #define PSA_IPC_CONNECT (-1)
46 /* An IPC message type that indicates the end of a connection. */
47 #define PSA_IPC_DISCONNECT (-2)
48 
49 /* Store a set of one or more Secure Partition signals */
50 typedef uint32_t psa_signal_t;
51 
55 typedef struct psa_msg_t {
56  int32_t type; /* One of the following values:
57  * \ref PSA_IPC_CONNECT
58  * >= 0
59  * \ref PSA_IPC_DISCONNECT
60  */
61  psa_handle_t handle; /* A reference generated by the SPM to the
62  * message returned by psa_get().
63  */
64  int32_t client_id; /* Partition ID of the sender of the message */
65  void *rhandle; /* Be useful for binding a connection to some
66  * application-specific data or function
67  * pointer within the RoT Service
68  * implementation.
69  */
70  size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input
71  * vector in bytes.
72  */
73  size_t out_size[PSA_MAX_IOVEC];/* Provide the size of each client output
74  * vector in bytes.
75  */
76 } psa_msg_t;
77 
78 /************************* PSA Secure Partition API **************************/
79 
93 psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout);
94 
115 psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg);
116 
128 void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle);
129 
155 size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
156  void *buffer, size_t num_bytes);
157 
178 size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes);
179 
202 void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
203  const void *buffer, size_t num_bytes);
204 
219 void psa_reply(psa_handle_t msg_handle, psa_status_t status);
220 
230 void psa_notify(int32_t partition_id);
231 
239 void psa_clear(void);
240 
253 void psa_eoi(psa_signal_t irq_signal);
254 
261 void psa_panic(void);
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif /* __PSA_SERVICE_H__ */
uint32_t psa_signal_t
Definition: service.h:50
int32_t type
Definition: service.h:56
void psa_clear(void)
Clear the PSA_DOORBELL signal.
Definition: psa_service.c:83
void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle)
Associate some RoT Service private data with a client connection.
Definition: psa_service.c:32
int32_t client_id
Definition: service.h:64
size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes)
Skip over part of a client input vector.
Definition: psa_service.c:50
Standard error codes for the SPM and RoT Services.
size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx, void *buffer, size_t num_bytes)
Read a message parameter or part of a message parameter from a client input vector.
Definition: psa_service.c:40
psa_handle_t handle
Definition: service.h:61
#define PSA_MAX_IOVEC
Definition: client.h:54
void psa_panic(void)
Terminate execution within the calling Secure Partition and will not return.
Definition: psa_service.c:99
size_t in_size[PSA_MAX_IOVEC]
Definition: service.h:70
struct psa_msg_t psa_msg_t
void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer, size_t num_bytes)
Write a message response to a client output vector.
Definition: psa_service.c:58
void psa_reply(psa_handle_t msg_handle, psa_status_t status)
Complete handling of a specific message and unblock the client.
Definition: psa_service.c:67
psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
Return the Secure Partition interrupt signals that have been asserted from a subset of signals provid...
Definition: psa_service.c:15
int32_t psa_handle_t
Definition: client.h:61
void psa_eoi(psa_signal_t irq_signal)
Inform the SPM that an interrupt has been handled (end of interrupt).
Definition: psa_service.c:91
size_t out_size[PSA_MAX_IOVEC]
Definition: service.h:73
void * rhandle
Definition: service.h:65
psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg)
Retrieve the message which corresponds to a given RoT Service signal and remove the message from the ...
Definition: psa_service.c:24
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
void psa_notify(int32_t partition_id)
Send a PSA_DOORBELL signal to a specific Secure Partition.
Definition: psa_service.c:75