blob: d1af993f4f960d716bca4abd748122a064871692 [file] [log] [blame]
Valerio Setti4f4ade92024-05-03 17:28:04 +02001/* 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
12extern "C" {
13#endif
14
15#include <stdint.h>
16#include <stddef.h>
17
18#include "psa/error.h"
19/*********************** PSA Client Macros and Types *************************/
20
21#define PSA_FRAMEWORK_VERSION (0x0100)
22
23#define PSA_VERSION_NONE (0)
24
25/* PSA response types */
26#define PSA_CONNECTION_REFUSED PSA_ERROR_CONNECTION_REFUSED
27#define PSA_CONNECTION_BUSY PSA_ERROR_CONNECTION_BUSY
28#define PSA_DROP_CONNECTION PSA_ERROR_PROGRAMMER_ERROR
29
30/* PSA message handles */
31#define PSA_NULL_HANDLE ((psa_handle_t) 0)
32
33#define PSA_HANDLE_IS_VALID(handle) ((psa_handle_t) (handle) > 0)
34#define PSA_HANDLE_TO_ERROR(handle) ((psa_status_t) (handle))
35
36/**
37 * A read-only input memory region provided to an RoT Service.
38 */
39typedef struct psa_invec {
40 const void *base;
41 size_t len;
42} psa_invec;
43
44/**
45 * A writable output memory region provided to an RoT Service.
46 */
47typedef struct psa_outvec {
48 void *base;
49 size_t len;
50} psa_outvec;
51
52/*************************** PSA Client API **********************************/
53
54uint32_t psa_framework_version(void);
55
56uint32_t psa_version(uint32_t sid);
57
58psa_handle_t psa_connect(uint32_t sid, uint32_t version);
59
60psa_status_t psa_call(psa_handle_t handle,
61 int32_t type,
62 const psa_invec *in_vec,
63 size_t in_len,
64 psa_outvec *out_vec,
65 size_t out_len);
66
67void psa_close(psa_handle_t handle);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* __PSA_CLIENT_H__ */