MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxCsslFlowProtection_SecureCounter_Local_AssemblyMacros.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 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
38
39#ifndef MCUXCSSLFLOWPROTECTION_SECURECOUNTER_LOCAL_ASSEMBLYMACROS_H_
40#define MCUXCSSLFLOWPROTECTION_SECURECOUNTER_LOCAL_ASSEMBLYMACROS_H_
41
43
49/* TODO: CLNS-18893 - Refactor header files to extract constants and prevent code duplication */
50#define MCUX_CSSL_FP_FUNCTION_ID_ENTRY_EXIT_MASK 0x5A5A5A5A
51
52#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) || defined(__GNUC__)
53
54.macro MCUX_CSSL_FP_ASM_FUNCTION_ENTRY rSc, rTmp, funcID
55 MCUX_CSSL_SC_ASM_INIT_BASE \rSc
56 ldr \rTmp, =(\funcID & MCUX_CSSL_FP_FUNCTION_ID_ENTRY_EXIT_MASK)
57 MCUX_CSSL_SC_ASM_ADD \rSc, \rTmp
58 .endm
59
60.macro MCUX_CSSL_FP_ASM_FUNCTION_CALL rSc, func
61 bl \func
62 MCUX_CSSL_SC_ASM_ADD \rSc, r1
63 .endm
64
65.macro MCUX_CSSL_FP_ASM_FUNCTION_EXIT rSc, rTmp, funcID
66 ldr \rTmp, =(\funcID - (\funcID & MCUX_CSSL_FP_FUNCTION_ID_ENTRY_EXIT_MASK))
67 MCUX_CSSL_SC_ASM_ADD \rSc, \rTmp /* rSc = VALUE(fn_identifier) - VALUE(fn_identifier) & EXIT_MASK */
68 .endm
69
70#elif defined(__IASMARM__) || defined(__ICCARM__)
71
72MCUX_CSSL_FP_ASM_FUNCTION_ENTRY macro rSc, rTmp, funcID
73 MCUX_CSSL_SC_ASM_INIT_BASE rSc
75 MCUX_CSSL_SC_ASM_ADD rSc, rTmp
76 endm
77
78MCUX_CSSL_FP_ASM_FUNCTION_CALL macro rSc, func
79 bl func
80 MCUX_CSSL_SC_ASM_ADD rSc, r1
81 endm
82
83MCUX_CSSL_FP_ASM_FUNCTION_EXIT macro rSc, rTmp, funcID
84 ldr rTmp, =(funcID - (funcID & MCUX_CSSL_FP_FUNCTION_ID_ENTRY_EXIT_MASK))
85 MCUX_CSSL_SC_ASM_ADD rSc, rTmp /* rSc = VALUE(fn_identifier) - VALUE(fn_identifier) & EXIT_MASK */
86 endm
87
88#endif /* defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) || defined(__GNUC__) */
89
90#endif /* MCUXCSSLFLOWPROTECTION_SECURECOUNTER_LOCAL_ASSEMBLYMACROS_H_ */
Assembly macros for the secure counter.
#define MCUX_CSSL_FP_FUNCTION_ID_ENTRY_EXIT_MASK
Mask to be used to derive entry and exit parts from a function identifier.
Definition mcuxCsslFlowProtection_SecureCounter_Local_AssemblyMacros.h:50