1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright 2019, 2021 NXP 4 * 5 * Brief Status management utilities. 6 */ 7 #include <caam_jr_status.h> 8 #include <caam_status.h> 9 #include <caam_utils_status.h> 10 job_status_to_tee_result(uint32_t status)11TEE_Result job_status_to_tee_result(uint32_t status) 12 { 13 /* 14 * Add all status code that can be translated 15 * to a TEE_Result other than TEE_ERROR_GENERIC 16 */ 17 switch (JRSTA_SRC_GET(status)) { 18 case JRSTA_SRC(NONE): 19 return TEE_SUCCESS; 20 21 case JRSTA_SRC(DECO): 22 if (JRSTA_CCB_GET_ERR(status) == JRSTA_DECO_ERRID_FORMAT) 23 return TEE_ERROR_BAD_PARAMETERS; 24 25 if (JRSTA_CCB_GET_ERR(status) == JRSTA_DECO_INV_SIGNATURE) 26 return TEE_ERROR_SIGNATURE_INVALID; 27 28 break; 29 30 default: 31 break; 32 } 33 34 return TEE_ERROR_GENERIC; 35 } 36 caam_status_to_tee_result(enum caam_status status)37TEE_Result caam_status_to_tee_result(enum caam_status status) 38 { 39 switch (status) { 40 case CAAM_NO_ERROR: 41 return TEE_SUCCESS; 42 43 case CAAM_OUT_MEMORY: 44 return TEE_ERROR_OUT_OF_MEMORY; 45 46 case CAAM_BAD_PARAM: 47 return TEE_ERROR_BAD_PARAMETERS; 48 49 case CAAM_SHORT_BUFFER: 50 return TEE_ERROR_SHORT_BUFFER; 51 52 default: 53 break; 54 } 55 56 return TEE_ERROR_GENERIC; 57 } 58