1 /***************************************************************************//**
2 * \file cy_crypto_core_mem.h
3 * \version 2.40
4 *
5 * \brief
6 * This file provides the headers for the memory management API
7 * in the Crypto driver.
8 *
9 ********************************************************************************
10 * Copyright 2016-2020 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25
26
27 #if !defined (CY_CRYPTO_CORE_MEM_H)
28 #define CY_CRYPTO_CORE_MEM_H
29
30 #include "cy_device.h"
31
32 #if defined (CY_IP_MXCRYPTO)
33
34 #include "cy_crypto_common.h"
35
36 #if defined(__cplusplus)
37 extern "C" {
38 #endif
39
40 #include "cy_crypto_core_mem_v1.h"
41 #include "cy_crypto_core_mem_v2.h"
42 #include "cy_crypto_core_hw.h"
43
44 typedef void (*cy_crypto_memcpy_func_t)(CRYPTO_Type *base,
45 void* dst, void const *src, uint16_t size);
46 typedef void (*cy_crypto_memset_func_t)(CRYPTO_Type *base,
47 void* dst, uint8_t data, uint16_t size);
48 typedef uint32_t (*cy_crypto_memcmp_func_t)(CRYPTO_Type *base,
49 void const *src0, void const *src1, uint16_t size);
50 typedef void (*cy_crypto_memxor_func_t)(CRYPTO_Type *base, void* dst,
51 void const *src0, void const *src1, uint16_t size);
52
53 /**
54 * \addtogroup group_crypto_lld_mem_functions
55 * \{
56 */
57
58 /*******************************************************************************
59 * Function Name: Cy_Crypto_Core_MemCpy
60 ****************************************************************************//**
61 *
62 * Function MemCpy uses Crypto HW.
63 * Memory structures should not overlap!
64 * There is no alignment restriction.
65 *
66 * \param base
67 * The pointer to the CRYPTO instance.
68 *
69 * \param dst
70 * The pointer to the destination of MemCpy.
71 *
72 * \param src
73 * The pointer to the source of MemCpy.
74 *
75 * \param size
76 * The size in bytes of the copy operation.
77 *
78 *******************************************************************************/
Cy_Crypto_Core_MemCpy(CRYPTO_Type * base,void * dst,void const * src,uint16_t size)79 __STATIC_INLINE void Cy_Crypto_Core_MemCpy(CRYPTO_Type *base, void* dst, void const *src, uint16_t size)
80 {
81 if (CY_CRYPTO_V1)
82 {
83 Cy_Crypto_Core_V1_MemCpy(base, dst, src, size);
84 }
85 else
86 {
87 Cy_Crypto_Core_V2_MemCpy(base, dst, src, size);
88 }
89 }
90
91 /*******************************************************************************
92 * Function Name: Cy_Crypto_Core_MemSet
93 ****************************************************************************//**
94 *
95 * Function MemSet uses Crypto HW.
96 * There is no alignment restriction.
97 *
98 * \param base
99 * The pointer to the CRYPTO instance.
100 *
101 * \param dst
102 * The pointer to the destination of MemSet.
103
104 * \param data
105 * The value to be set.
106
107 * \param size
108 * The size in bytes of the set operation.
109 *
110 *******************************************************************************/
Cy_Crypto_Core_MemSet(CRYPTO_Type * base,void * dst,uint8_t data,uint16_t size)111 __STATIC_INLINE void Cy_Crypto_Core_MemSet(CRYPTO_Type *base, void* dst, uint8_t data, uint16_t size)
112 {
113 if (CY_CRYPTO_V1)
114 {
115 Cy_Crypto_Core_V1_MemSet(base, dst, data, size);
116 }
117 else
118 {
119 Cy_Crypto_Core_V2_MemSet(base, dst, data, size);
120 }
121 }
122
123 /*******************************************************************************
124 * Function Name: Cy_Crypto_Core_MemCmp
125 ****************************************************************************//**
126 *
127 * Function MemCmp uses Crypto HW.
128 * There is no alignment restriction.
129 *
130 * \param base
131 * The pointer to the CRYPTO instance.
132 *
133 * \param src0
134 * The pointer to the first source of MemCmp.
135
136 * \param src1
137 * The pointer to the second source of MemCmp.
138
139 * \param size
140 * the size in bytes of the compare operation.
141 *
142 * \return
143 * 0 - if Source 1 = Source 2, 1 - if not.
144 *
145 *******************************************************************************/
Cy_Crypto_Core_MemCmp(CRYPTO_Type * base,void const * src0,void const * src1,uint16_t size)146 __STATIC_INLINE uint32_t Cy_Crypto_Core_MemCmp(CRYPTO_Type *base, void const *src0, void const *src1, uint16_t size)
147 {
148 uint32_t tmpResult;
149 if (CY_CRYPTO_V1)
150 {
151 tmpResult = Cy_Crypto_Core_V1_MemCmp(base, src0, src1, size);
152 }
153 else
154 {
155 tmpResult = Cy_Crypto_Core_V2_MemCmp(base, src0, src1, size);
156 }
157
158 return (tmpResult);
159 }
160
161 /*******************************************************************************
162 * Function Name: Cy_Crypto_Core_MemXor
163 ****************************************************************************//**
164 *
165 * Function MemXor uses Crypto HW.
166 * Memory structures should not overlap!
167 * There is no alignment restriction.
168 *
169 * \param base
170 * The pointer to the CRYPTO instance.
171 *
172 * \param dst
173 * The pointer to the destination of MemXor.
174 *
175 * \param src0
176 * The pointer to the first source of MemXor.
177 *
178 * \param src1
179 * The pointer to the second source of MemXor.
180 *
181 * \param size
182 * The size in bytes of the compare operation.
183 *
184 *******************************************************************************/
Cy_Crypto_Core_MemXor(CRYPTO_Type * base,void * dst,void const * src0,void const * src1,uint16_t size)185 __STATIC_INLINE void Cy_Crypto_Core_MemXor(CRYPTO_Type *base, void* dst,
186 void const *src0, void const *src1, uint16_t size)
187 {
188 if (CY_CRYPTO_V1)
189 {
190 Cy_Crypto_Core_V1_MemXor(base, dst, src0, src1, size);
191 }
192 else
193 {
194 Cy_Crypto_Core_V2_MemXor(base, dst, src0, src1, size);
195 }
196 }
197
198 /** \} group_crypto_lld_mem_functions */
199
200 #if defined(__cplusplus)
201 }
202 #endif
203
204 #endif /* CY_IP_MXCRYPTO */
205
206 #endif /* #if !defined (CY_CRYPTO_CORE_MEM_H) */
207
208
209 /* [] END OF FILE */
210