client.h (1823B)
1 /* PSA Firmware Framework client header for psasim. */ 2 3 /* 4 * Copyright The Mbed TLS Contributors 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 */ 7 8 #ifndef __PSA_CLIENT_H__ 9 #define __PSA_CLIENT_H__ 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #include <stdint.h> 16 #include <stddef.h> 17 #include <psa/error.h> 18 /*********************** PSA Client Macros and Types *************************/ 19 20 #define PSA_FRAMEWORK_VERSION (0x0100) 21 22 #define PSA_VERSION_NONE (0) 23 24 /* PSA response types */ 25 #define PSA_CONNECTION_REFUSED PSA_ERROR_CONNECTION_REFUSED 26 #define PSA_CONNECTION_BUSY PSA_ERROR_CONNECTION_BUSY 27 #define PSA_DROP_CONNECTION PSA_ERROR_PROGRAMMER_ERROR 28 29 /* PSA message handles */ 30 #define PSA_NULL_HANDLE ((psa_handle_t) 0) 31 32 #define PSA_HANDLE_IS_VALID(handle) ((psa_handle_t) (handle) > 0) 33 #define PSA_HANDLE_TO_ERROR(handle) ((psa_status_t) (handle)) 34 35 #define PSA_MAX_IOVEC (4u) 36 37 #define PSA_IPC_CALL (0) 38 39 typedef int32_t psa_handle_t; 40 41 /** 42 * A read-only input memory region provided to an RoT Service. 43 */ 44 typedef struct psa_invec { 45 const void *base; 46 size_t len; 47 } psa_invec; 48 49 /** 50 * A writable output memory region provided to an RoT Service. 51 */ 52 typedef struct psa_outvec { 53 void *base; 54 size_t len; 55 } psa_outvec; 56 57 /*************************** PSA Client API **********************************/ 58 59 uint32_t psa_framework_version(void); 60 61 uint32_t psa_version(uint32_t sid); 62 63 psa_handle_t psa_connect(uint32_t sid, uint32_t version); 64 65 psa_status_t psa_call(psa_handle_t handle, 66 int32_t type, 67 const psa_invec *in_vec, 68 size_t in_len, 69 psa_outvec *out_vec, 70 size_t out_len); 71 72 void psa_close(psa_handle_t handle); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* __PSA_CLIENT_H__ */