1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 
8 
9 /************* Include Files ****************/
10 #include "cc_pal_buff_attr.h"
11 #include "cc_hal_plat.h"
12 #include "dx_id_registers.h"
13 #include "dx_crys_kernel.h"
14 #include "cc_regs.h"
15 #ifdef ARCH_V8M
16 #include <arm_cmse.h>
17 #endif
18 /************************ Defines ******************************/
19 
20 /************************ Enums ******************************/
21 
22 /************************ Typedefs ******************************/
23 
24 /************************ Global Data ******************************/
25 
26 /************************ Private Functions ******************************/
27 
28 /************************ Public Functions ******************************/
29 #ifdef ARCH_V8M
CC_PalDataBufferAttrGet(const unsigned char * pDataBuffer,size_t buffSize,uint8_t buffType,uint8_t * pBuffNs)30 CCError_t CC_PalDataBufferAttrGet(const unsigned char *pDataBuffer,     /*!< [in] Address of the buffer to map. */
31                                   size_t              buffSize,         /*!< [in] Buffer size in bytes. */
32                                   uint8_t             buffType,         /* ! [in] Input for read / output for write */
33                                   uint8_t             *pBuffNs          /*!< [out] HNONSEC buffer attribute (0 for secure, 1 for non-secure) */
34 )
35 {
36     cmse_address_info_t addInfo;
37     CC_UNUSED_PARAM(buffSize);
38     CC_UNUSED_PARAM(buffType);
39     *pBuffNs = DATA_BUFFER_IS_SECURE;
40 
41     /* It is assumed that an object is allocated in a single MPU (Memory Protection Unit) region,
42      * so it is not needed to check the entire length of the buffer. */
43     addInfo = cmse_TT((unsigned char*)pDataBuffer);
44     if (addInfo.flags.secure == 0x00) {
45         *pBuffNs = DATA_BUFFER_IS_NONSECURE;
46     } else {
47     }
48 
49     return CC_OK;
50 }
51 #else
CC_PalDataBufferAttrGet(const unsigned char * pDataBuffer,size_t buffSize,uint8_t buffType,uint8_t * pBuffNs)52 CCError_t CC_PalDataBufferAttrGet(const unsigned char *pDataBuffer,     /*!< [in] Address of the buffer to map. */
53                                   size_t              buffSize,         /*!< [in] Buffer size in bytes. */
54                                   uint8_t             buffType,         /* ! [in] Input for read / output for write */
55                                   uint8_t             *pBuffNs          /*!< [out] HNONSEC buffer attribute (0 for secure, 1 for non-secure) */
56 )
57 {
58     CC_UNUSED_PARAM(pDataBuffer);
59     CC_UNUSED_PARAM(buffSize);
60     CC_UNUSED_PARAM(buffType);
61 
62     *pBuffNs = DATA_BUFFER_IS_SECURE;
63 
64     return CC_OK;
65 }
66 #endif
67