Skip to content

Commit 68f1ef2

Browse files
authored
Merge pull request #12716 from OpenNuvoton/nuvoton_m487_bsp
M487: Update BSP
2 parents 4c444ae + 2c9ec8f commit 68f1ef2

File tree

181 files changed

+52140
-40858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+52140
-40858
lines changed

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -150,15 +152,15 @@ static void __nvt_aes_crypt( mbedtls_aes_context *ctx,
150152
/* Init crypto module */
151153
crypto_init();
152154
/* Enable AES interrupt */
153-
AES_ENABLE_INT();
155+
AES_ENABLE_INT(CRPT);
154156

155157
/* We support multiple contexts with context save & restore and so needs just one
156158
* H/W channel. Always use H/W channel #0. */
157159

158160
/* AES_IN_OUT_SWAP: Let H/W know both input/output data are arranged in little-endian */
159-
AES_Open(0, ctx->encDec, ctx->opMode, ctx->keySize, AES_IN_OUT_SWAP);
160-
AES_SetInitVect(0, ctx->iv);
161-
AES_SetKey(0, ctx->keys, ctx->keySize);
161+
AES_Open(CRPT, 0, ctx->encDec, ctx->opMode, ctx->keySize, AES_IN_OUT_SWAP);
162+
AES_SetInitVect(CRPT, 0, ctx->iv);
163+
AES_SetKey(CRPT, 0, ctx->keys, ctx->keySize);
162164

163165
/* AES DMA buffer requirements same as above */
164166
if (! crypto_dma_buff_compat(input, dataSize, 16)) {
@@ -182,10 +184,10 @@ static void __nvt_aes_crypt( mbedtls_aes_context *ctx,
182184
}
183185
MBED_ASSERT(! crypto_dma_buffs_overlap(pIn, dataSize, pOut, dataSize));
184186

185-
AES_SetDMATransfer(0, (uint32_t)pIn, (uint32_t)pOut, dataSize);
187+
AES_SetDMATransfer(CRPT, 0, (uint32_t)pIn, (uint32_t)pOut, dataSize);
186188

187189
crypto_aes_prestart();
188-
AES_Start(0, CRYPTO_DMA_ONE_SHOT);
190+
AES_Start(CRPT, 0, CRYPTO_DMA_ONE_SHOT);
189191
crypto_aes_wait();
190192

191193
if( pOut != output ) {
@@ -199,7 +201,7 @@ static void __nvt_aes_crypt( mbedtls_aes_context *ctx,
199201
ctx->iv[3] = CRPT->AES_FDBCK[3];
200202

201203
/* Disable AES interrupt */
202-
AES_DISABLE_INT();
204+
AES_DISABLE_INT(CRPT);
203205
/* Uninit crypto module */
204206
crypto_uninit();
205207

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -355,7 +357,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
355357
/* Init crypto module */
356358
crypto_init();
357359
/* Enable DES interrupt */
358-
TDES_ENABLE_INT();
360+
TDES_ENABLE_INT(CRPT);
359361

360362
/* Configure TDES_CTL register
361363
*
@@ -373,7 +375,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
373375
* 1. BE for byte sequence in word
374376
* 2. BE for word sequence in double-word
375377
*/
376-
TDES_Open(0, // Channel number (0~4)
378+
TDES_Open(CRPT
379+
0, // Channel number (0~4)
377380
enc, // 0: decode, 1: encode
378381
(tdes_opmode & CRPT_TDES_CTL_TMODE_Msk) ? 1 : 0, // 0: DES, 1: TDES
379382
(keyopt == 1) ? 1 : 0, // 0: TDES 2-key mode, 1: TDES 3-key mode
@@ -390,7 +393,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
390393
keys3x2[i][0] = nu_get32_be(key[i] + 0);
391394
keys3x2[i][1] = nu_get32_be(key[i] + 4);
392395
}
393-
TDES_SetKey(0, keys3x2);
396+
TDES_SetKey(CRPT, 0, keys3x2);
394397

395398
uint32_t rmn = length;
396399
const unsigned char *in_pos = input;
@@ -402,15 +405,15 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
402405
uint32_t ivh, ivl;
403406
ivh = nu_get32_be(iv);
404407
ivl = nu_get32_be(iv + 4);
405-
TDES_SetInitVect(0, ivh, ivl);
408+
TDES_SetInitVect(CRPT, 0, ivh, ivl);
406409

407410
memcpy(dmabuf_in, in_pos, data_len);
408411

409412
/* We always use DMA backup buffers, which are guaranteed to be non-overlapped. */
410-
TDES_SetDMATransfer(0, (uint32_t) dmabuf_in, (uint32_t) dmabuf_out, data_len);
413+
TDES_SetDMATransfer(CRPT, 0, (uint32_t) dmabuf_in, (uint32_t) dmabuf_out, data_len);
411414

412415
crypto_des_prestart();
413-
TDES_Start(0, CRYPTO_DMA_ONE_SHOT);
416+
TDES_Start(CRPT, 0, CRYPTO_DMA_ONE_SHOT);
414417
crypto_des_wait();
415418

416419
memcpy(out_pos, dmabuf_out, data_len);
@@ -452,7 +455,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
452455
}
453456

454457
/* Disable DES interrupt */
455-
TDES_DISABLE_INT();
458+
TDES_DISABLE_INT(CRPT);
456459
/* Uninit crypto module */
457460
crypto_uninit();
458461

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2016-2018 Nuvoton
1+
/*
2+
* Copyright (c) 2016-2018, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -240,15 +242,15 @@ int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp )
240242
crypto_init();
241243

242244
/* Enable ECC interrupt */
243-
ECC_ENABLE_INT();
245+
ECC_ENABLE_INT(CRPT);
244246

245247
return 0;
246248
}
247249

248250
void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp )
249251
{
250252
/* Disable ECC interrupt */
251-
ECC_DISABLE_INT();
253+
ECC_DISABLE_INT(CRPT);
252254

253255
/* Uninit crypto module */
254256
crypto_uninit();

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/mbedtls_device.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -13,6 +15,7 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
18+
1619
#ifndef MBEDTLS_DEVICE_H
1720
#define MBEDTLS_DEVICE_H
1821

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -13,6 +15,7 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
18+
1619
#ifndef MBEDTLS_SHA1_ALT_H
1720
#define MBEDTLS_SHA1_ALT_H
1821

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -13,6 +15,7 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
18+
1619
#ifndef MBEDTLS_SHA256_ALT_H
1720
#define MBEDTLS_SHA256_ALT_H
1821

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -13,6 +15,7 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
18+
1619
#ifndef MBEDTLS_SHA512_ALT_H
1720
#define MBEDTLS_SHA512_ALT_H
1821

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -69,7 +71,7 @@ void mbedtls_sha1_hw_starts(crypto_sha_context *ctx)
6971
ctx->blocksize = 64;
7072
ctx->blocksize_mask = 0x3F;
7173

72-
SHA_Open(SHA_MODE_SHA1, SHA_NO_SWAP, 0);
74+
SHA_Open(CRPT, SHA_MODE_SHA1, SHA_NO_SWAP, 0);
7375

7476
// Ensure we have correct initial internal states in SHA_DGST registers even though SHA H/W is not actually started.
7577
CRPT->HMAC_CTL |= CRPT_HMAC_CTL_START_Msk;
@@ -143,7 +145,7 @@ void mbedtls_sha256_hw_starts( crypto_sha_context *ctx, int is224)
143145
ctx->blocksize_mask = 0x3F;
144146
ctx->is224_384 = is224;
145147

146-
SHA_Open(is224 ? SHA_MODE_SHA224 : SHA_MODE_SHA256, SHA_NO_SWAP, 0);
148+
SHA_Open(CRPT, is224 ? SHA_MODE_SHA224 : SHA_MODE_SHA256, SHA_NO_SWAP, 0);
147149

148150
// Ensure we have correct initial internal states in SHA_DGST registers even though SHA H/W is not actually started.
149151
CRPT->HMAC_CTL |= CRPT_HMAC_CTL_START_Msk;
@@ -218,7 +220,7 @@ void mbedtls_sha512_hw_starts( crypto_sha_context *ctx, int is384)
218220
ctx->blocksize_mask = 0x7F;
219221
ctx->is224_384 = is384;
220222

221-
SHA_Open(is384 ? SHA_MODE_SHA384 : SHA_MODE_SHA512, SHA_NO_SWAP, 0);
223+
SHA_Open(CRPT, is384 ? SHA_MODE_SHA384 : SHA_MODE_SHA512, SHA_NO_SWAP, 0);
222224

223225
// Ensure we have correct initial internal states in SHA_DGST registers even though SHA H/W is not actually started.
224226
CRPT->HMAC_CTL |= CRPT_HMAC_CTL_START_Msk;

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha_alt_hw.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 Nuvoton
1+
/*
2+
* Copyright (c) 2015-2016, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -13,6 +15,7 @@
1315
* See the License for the specific language governing permissions and
1416
* limitations under the License.
1517
*/
18+
1619
#ifndef MBEDTLS_SHA_ALT_HW_H
1720
#define MBEDTLS_SHA_ALT_HW_H
1821

0 commit comments

Comments
 (0)