MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClCore_Macros.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/* Copyright 2023-2025 NXP */
3
/* */
4
/* NXP Confidential and Proprietary. This software is owned or controlled */
5
/* by NXP and may only be used strictly in accordance with the applicable */
6
/* license terms. By expressly accepting such terms or by downloading, */
7
/* installing, activating and/or otherwise using the software, you are */
8
/* agreeing that you have read, and that you agree to comply with and are */
9
/* bound by, such license terms. If you do not agree to be bound by the */
10
/* applicable license terms, then you may not retain, install, activate or */
11
/* otherwise use the software. */
12
/*--------------------------------------------------------------------------*/
13
19
20
#ifndef MCUXCLCORE_MACROS_H_
21
#define MCUXCLCORE_MACROS_H_
22
23
/* Macro to calculate the rounded down number of words that fit into the specified size */
24
#define MCUXCLCORE_NUM_OF_WORDS_FLOOR(wordsize, size) \
25
((size) / (wordsize))
26
27
/* Macro to calculate the rounded up number of words needed to fit an object of the specified size */
28
#define MCUXCLCORE_NUM_OF_WORDS_CEIL(wordsize, size) \
29
(((size) + (wordsize) - 1u) / (wordsize))
30
31
/* Macro to calculate the rounded down number of CPU words that fit into the specified size */
32
#define MCUXCLCORE_NUM_OF_CPUWORDS_FLOOR(size) \
33
MCUXCLCORE_NUM_OF_WORDS_FLOOR(sizeof(uint32_t), size)
34
35
/* Macro to calculate the rounded up number of CPU words needed to fit an object of the specified size */
36
#define MCUXCLCORE_NUM_OF_CPUWORDS_CEIL(size) \
37
MCUXCLCORE_NUM_OF_WORDS_CEIL(sizeof(uint32_t), size)
38
39
/* Macro to round up a given size to the nearest multiple of a specified word size */
40
#define MCUXCLCORE_ALIGN_TO_WORDSIZE(wordsize, size) \
41
(MCUXCLCORE_NUM_OF_WORDS_CEIL(wordsize, size) * (wordsize))
42
43
/* Macro to round up a given size to the nearest multiple of the CPU word size */
44
#define MCUXCLCORE_ALIGN_TO_CPU_WORDSIZE(size) \
45
MCUXCLCORE_ALIGN_TO_WORDSIZE(sizeof(uint32_t), size)
46
47
/* Macro to calculate the maximum of two values */
48
#define MCUXCLCORE_MAX(a, b) \
49
(((a) > (b)) ? (a) : (b))
50
51
/* Macro to calculate the minimum of two values */
52
#define MCUXCLCORE_MIN(a, b) \
53
(((a) < (b)) ? (a) : (b))
54
55
/* Macros to get the status code class of a 32-bit return code */
56
#define MCUXCLCORE_CLS_MASK (0x0000FF00u)
57
#define MCUXCLCORE_CLS_NORMAL (0x00002E00u)
58
#define MCUXCLCORE_CLS_NORMALMISMATCH (0x00008900u)
59
#define MCUXCLCORE_CLS_ABNORMAL (0x00005300U)
60
#define MCUXCLCORE_CLS_ATTACK (0x0000F000U)
61
#define MCUXCLCORE_GET_CLS(returnCode) \
62
((returnCode) & MCUXCLCORE_CLS_MASK)
63
70
#if !defined ( __m56800E__ )
71
#define MCUXCLCORE_DONOTOPTIMIZE(val) \
72
__asm volatile("" : "+r" (val))
73
#else
74
#define MCUXCLCORE_DONOTOPTIMIZE(val)
75
#endif
/* !defined ( __m56800E__ ) */
76
#endif
/* MCUXCLCORE_MACROS_H_ */
mcuxClCore_Macros.h
Generated by
1.16.1