1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include "driver_defs.h"
8 #include "cc_pal_buff_attr.h"
9 #include "cc_pal_abort.h"
10 #include "cc_error.h"
11 
12 /******************************************************************************
13 *       PUBLIC FUNCTIONS
14 ******************************************************************************/
15 
16 
SetDataBuffersInfo(const uint8_t * pDataIn,size_t dataInSize,CCBuffInfo_t * pInputBuffInfo,const uint8_t * pDataOut,size_t dataOutSize,CCBuffInfo_t * pOutputBuffInfo)17 drvError_t SetDataBuffersInfo(const uint8_t *pDataIn, size_t dataInSize, CCBuffInfo_t *pInputBuffInfo,
18                               const uint8_t *pDataOut, size_t dataOutSize, CCBuffInfo_t *pOutputBuffInfo)
19 {
20     drvError_t drvRet = CC_OK;
21     uint8_t  buffNs = 0;
22 
23     drvRet = CC_PalDataBufferAttrGet(pDataIn, dataInSize, INPUT_DATA_BUFFER, &buffNs);
24     if (drvRet != CC_OK){
25         CC_PAL_LOG_ERR("input buffer memory is illegal\n");
26         return CC_FATAL_ERROR;
27     }
28     pInputBuffInfo->dataBuffAddr = (uint32_t)pDataIn;
29     pInputBuffInfo->dataBuffNs = buffNs;
30 
31     if (pOutputBuffInfo != NULL) {
32         if (pDataOut != NULL) {
33             drvRet = CC_PalDataBufferAttrGet(pDataOut, dataOutSize, OUTPUT_DATA_BUFFER, &buffNs);
34             if (drvRet != CC_OK){
35                 CC_PAL_LOG_ERR("output buffer memory is illegal\n");
36                 return CC_FATAL_ERROR;
37             }
38         }
39         pOutputBuffInfo->dataBuffAddr = (uint32_t)pDataOut;
40         pOutputBuffInfo->dataBuffNs = buffNs;
41     }
42 
43     return drvRet;
44 }
45 
46 
47 
48