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
/* SPDX-License-Identifier: BSD-3-Clause */
5
/* */
6
/* Redistribution and use in source and binary forms, with or without */
7
/* modification, are permitted provided that the following conditions are */
8
/* met: */
9
/* */
10
/* 1. Redistributions of source code must retain the above copyright */
11
/* notice, this list of conditions and the following disclaimer. */
12
/* */
13
/* 2. Redistributions in binary form must reproduce the above copyright */
14
/* notice, this list of conditions and the following disclaimer in the */
15
/* documentation and/or other materials provided with the distribution. */
16
/* */
17
/* 3. Neither the name of the copyright holder nor the names of its */
18
/* contributors may be used to endorse or promote products derived from */
19
/* this software without specific prior written permission. */
20
/* */
21
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22
/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23
/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24
/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25
/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28
/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32
/*--------------------------------------------------------------------------*/
33
39
40
#ifndef MCUXCLCORE_MACROS_H_
41
#define MCUXCLCORE_MACROS_H_
42
43
/* Macro to calculate the rounded down number of words that fit into the specified size */
44
#define MCUXCLCORE_NUM_OF_WORDS_FLOOR(wordsize, size) \
45
((size) / (wordsize))
46
47
/* Macro to calculate the rounded up number of words needed to fit an object of the specified size */
48
#define MCUXCLCORE_NUM_OF_WORDS_CEIL(wordsize, size) \
49
(((size) + (wordsize) - 1u) / (wordsize))
50
51
/* Macro to calculate the rounded down number of CPU words that fit into the specified size */
52
#define MCUXCLCORE_NUM_OF_CPUWORDS_FLOOR(size) \
53
MCUXCLCORE_NUM_OF_WORDS_FLOOR(sizeof(uint32_t), size)
54
55
/* Macro to calculate the rounded up number of CPU words needed to fit an object of the specified size */
56
#define MCUXCLCORE_NUM_OF_CPUWORDS_CEIL(size) \
57
MCUXCLCORE_NUM_OF_WORDS_CEIL(sizeof(uint32_t), size)
58
59
/* Macro to round up a given size to the nearest multiple of a specified word size */
60
#define MCUXCLCORE_ALIGN_TO_WORDSIZE(wordsize, size) \
61
(MCUXCLCORE_NUM_OF_WORDS_CEIL(wordsize, size) * (wordsize))
62
63
/* Macro to round up a given size to the nearest multiple of the CPU word size */
64
#define MCUXCLCORE_ALIGN_TO_CPU_WORDSIZE(size) \
65
MCUXCLCORE_ALIGN_TO_WORDSIZE(sizeof(uint32_t), size)
66
67
/* Macro to calculate the maximum of two values */
68
#define MCUXCLCORE_MAX(a, b) \
69
(((a) > (b)) ? (a) : (b))
70
71
/* Macro to calculate the minimum of two values */
72
#define MCUXCLCORE_MIN(a, b) \
73
(((a) < (b)) ? (a) : (b))
74
75
/* Macros to get the status code class of a 32-bit return code */
76
#define MCUXCLCORE_CLS_MASK (0x0000FF00u)
77
#define MCUXCLCORE_CLS_NORMAL (0x00002E00u)
78
#define MCUXCLCORE_CLS_NORMALMISMATCH (0x00008900u)
79
#define MCUXCLCORE_CLS_ABNORMAL (0x00005300U)
80
#define MCUXCLCORE_CLS_ATTACK (0x0000F000U)
81
#define MCUXCLCORE_GET_CLS(returnCode) \
82
((returnCode) & MCUXCLCORE_CLS_MASK)
83
90
#if !defined ( __m56800E__ )
91
#define MCUXCLCORE_DONOTOPTIMIZE(val) \
92
__asm volatile("" : "+r" (val))
93
#else
94
#define MCUXCLCORE_DONOTOPTIMIZE(val)
95
#endif
/* !defined ( __m56800E__ ) */
96
#endif
/* MCUXCLCORE_MACROS_H_ */
mcuxClCore_Macros.h
Generated by
1.16.1