1 /* 2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef __TFM_PSA_CALL_PACK_H__ 9 #define __TFM_PSA_CALL_PACK_H__ 10 11 #include "psa/client.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #define TYPE_OFFSET 16U 18 #define TYPE_MASK (0xFFFFUL << TYPE_OFFSET) 19 #define IN_LEN_OFFSET 8U 20 #define IN_LEN_MASK (0xFFUL << IN_LEN_OFFSET) 21 #define OUT_LEN_OFFSET 0U 22 #define OUT_LEN_MASK (0xFFUL << OUT_LEN_OFFSET) 23 24 #define PARAM_PACK(type, in_len, out_len) \ 25 (((((uint32_t)type) << TYPE_OFFSET) & TYPE_MASK) | \ 26 ((((uint32_t)in_len) << IN_LEN_OFFSET) & IN_LEN_MASK) | \ 27 ((((uint32_t)out_len) << OUT_LEN_OFFSET) & OUT_LEN_MASK)) 28 29 #define PARAM_UNPACK_TYPE(ctrl_param) \ 30 ((int32_t)(((ctrl_param) & TYPE_MASK) >> TYPE_OFFSET)) 31 32 #define PARAM_UNPACK_IN_LEN(ctrl_param) \ 33 ((size_t)(((ctrl_param) & IN_LEN_MASK) >> IN_LEN_OFFSET)) 34 35 #define PARAM_UNPACK_OUT_LEN(ctrl_param) \ 36 ((size_t)(((ctrl_param) & OUT_LEN_MASK) >> OUT_LEN_OFFSET)) 37 38 psa_status_t tfm_psa_call_pack(psa_handle_t handle, 39 uint32_t ctrl_param, 40 const psa_invec *in_vec, 41 psa_outvec *out_vec); 42 43 #ifdef __cplusplus 44 } 45 #endif 46 47 #endif /* __TFM_PSA_CALL_PACK_H__ */ 48