MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClGlikey.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2022-2024 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
43
44#ifndef MCUXCLGLIKEY_H_
45#define MCUXCLGLIKEY_H_
46
47#include <mcuxClConfig.h> // Exported features flags header
48
49#include <stdint.h>
50#include <stddef.h>
51
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59
60/**********************************************
61 * CONSTANTS
62 **********************************************/
69
70/* [Design]
71 Value: XX YZ UU VW
72 - XX: F0: write to WR_EN1, 0F: do not write to WR_EN1
73 - UU: F0: write to WR_EN0, 0F: do not write to WR_EN0
74 - Y: equal to <step> ^ W
75 - Z: value to write to WR_EN1 or equal to ~W
76 - V: equal to <step> ^ Z
77 - W: value to write to WR_EN0 or equal to ~Z
78 Invariant: XXYZ ^ UUVW == 0xFFFF
79*/
80#define MCUXCLGLIKEY_CODEWORD_STEP1 ((uint32_t) 0xF0C10F3EU)
81#define MCUXCLGLIKEY_CODEWORD_STEP2 ((uint32_t) 0x0F1DF0E2U)
82#define MCUXCLGLIKEY_CODEWORD_STEP3 ((uint32_t) 0xF0B00F4FU)
83#define MCUXCLGLIKEY_CODEWORD_STEP4 ((uint32_t) 0x0F4EF0B1U)
84#define MCUXCLGLIKEY_CODEWORD_STEP5 ((uint32_t) 0xF0810F7EU)
85#define MCUXCLGLIKEY_CODEWORD_STEP6 ((uint32_t) 0x0F5DF0A2U)
86#define MCUXCLGLIKEY_CODEWORD_STEP7 ((uint32_t) 0xF0700F8FU)
87#define MCUXCLGLIKEY_CODEWORD_STEP_EN ((uint32_t) 0x0FFFF000U)
88
89#define MCUXCLGLIKEY_STATUS_OK 0x0FF22E03u
90#define MCUXCLGLIKEY_STATUS_NOT_LOCKED 0x0FF22E07u
91#define MCUXCLGLIKEY_STATUS_LOCKED 0x0FF22E0Bu
92
93#define MCUXCLGLIKEY_STATUS_VERSION_ERROR 0x0FF25334u
94#define MCUXCLGLIKEY_STATUS_LOCKED_ERROR 0x0FF25338u
95
96// Glikey state defines
97#define MCUXCLGLIKEY_FSM_WR_DIS 0x0Bu
98#define MCUXCLGLIKEY_FSM_INIT 0x16u
99#define MCUXCLGLIKEY_FSM_STEP1 0x2Cu
100#define MCUXCLGLIKEY_FSM_STEP2 0x58u
101#define MCUXCLGLIKEY_FSM_STEP3 0xB0u
102#define MCUXCLGLIKEY_FSM_STEP4 0x160u
103#define MCUXCLGLIKEY_FSM_LOCKED 0xC01u
104#define MCUXCLGLIKEY_FSM_WR_EN 0x1802u
105#define MCUXCLGLIKEY_FSM_SSR_RESET 0x1005u
107
111
112
113
114/**********************************************
115 * TYPEDEFS
116 **********************************************/
123
124typedef uint32_t mcuxClGlikey_BaseAddress_t;
125typedef uint32_t mcuxClGlikey_Status_t;
126typedef uint32_t mcuxClGlikey_IntEnable_t;
127typedef uint32_t mcuxClGlikey_GlikeyStatus_t;
131
132/**********************************************
133 * FUNCTIONS
134 **********************************************/
141
142
156 mcuxClGlikey_BaseAddress_t * base,
157 mcuxClGlikey_GlikeyStatus_t * result
158 );
175 mcuxClGlikey_BaseAddress_t * base
176 );
177
192 mcuxClGlikey_BaseAddress_t * base,
193 mcuxClGlikey_IntEnable_t value
194 );
195
209 mcuxClGlikey_BaseAddress_t * base,
210 mcuxClGlikey_IntEnable_t * value
211 );
212
224 mcuxClGlikey_BaseAddress_t * base
225 );
226
238 mcuxClGlikey_BaseAddress_t * base
239 );
240
252 mcuxClGlikey_BaseAddress_t * base
253 );
254
267 mcuxClGlikey_BaseAddress_t * base
268 );
269
283 mcuxClGlikey_BaseAddress_t * base,
284 uint32_t index
285 );
286
308 mcuxClGlikey_BaseAddress_t * base,
309 uint32_t index
310 );
311
332/* [Design]
333 - Check if Glikey is locked
334 if ( GLIKEY_LOCKED == GLIKEY_GET_SFR_LOCK(base) ) return MCUXCLGLIKEY_STATUS_LOCKED_ERROR
335 - Decode the codeword and write to Glikey CTRL[]
336 EnableSelect = (XX - 0xF)%2
337 EnableValue = (XXYZUUVW >> (EnableSelect << 4))&3
338 Write GLIKEY_CTRL(base, EnableSelect, EnableValue)
339 - Return MCUXCLGLIKEY_STATUS_OK
340*/
343 mcuxClGlikey_BaseAddress_t * base,
344 uint32_t codeword
345 );
346
364 mcuxClGlikey_BaseAddress_t * base
365 );
366
384 mcuxClGlikey_BaseAddress_t * base,
385 uint32_t index
386 );
387
388
389
409 mcuxClGlikey_BaseAddress_t * base
410 );
411
412
416
417#ifdef __cplusplus
418} /* extern "C" */
419#endif
420
421#endif // MCUXCLGLIKEY_H_
Definition of function identifiers for the flow protection mechanism.
Provides the API for the CSSL flow protection mechanism.
mcuxClGlikey_Status_t mcuxClGlikey_ContinueEnable(mcuxClGlikey_BaseAddress_t *base, uint32_t codeword)
Continue Glikey enable.
mcuxClGlikey_Status_t mcuxClGlikey_GetIntEnable(mcuxClGlikey_BaseAddress_t *base, mcuxClGlikey_IntEnable_t *value)
Get interrupt enable flag of Glikey.
mcuxClGlikey_Status_t mcuxClGlikey_StartEnable(mcuxClGlikey_BaseAddress_t *base, uint32_t index)
Start Glikey enable.
mcuxClGlikey_Status_t mcuxClGlikey_SetIntStatus(mcuxClGlikey_BaseAddress_t *base)
Set the interrupt status flag of Glikey.
mcuxClGlikey_Status_t mcuxClGlikey_IsLocked(mcuxClGlikey_BaseAddress_t *base)
Check if Glikey is locked.
mcuxClGlikey_Status_t mcuxClGlikey_ResetIndex(mcuxClGlikey_BaseAddress_t *base, uint32_t index)
Reset Glikey index.
mcuxClGlikey_Status_t mcuxClGlikey_IsIndexLocked(mcuxClGlikey_BaseAddress_t *base, uint32_t index)
Check if Glikey index is locked.
mcuxClGlikey_Status_t mcuxClGlikey_Lock(mcuxClGlikey_BaseAddress_t *base)
Lock Glikey SFR interface.
mcuxClGlikey_Status_t mcuxClGlikey_GetStatus(mcuxClGlikey_BaseAddress_t *base, mcuxClGlikey_GlikeyStatus_t *result)
Retrieves the current status of Glikey.
mcuxClGlikey_Status_t mcuxClGlikey_LockIndex(mcuxClGlikey_BaseAddress_t *base)
Lock Glikey index.
mcuxClGlikey_Status_t mcuxClGlikey_SyncReset(mcuxClGlikey_BaseAddress_t *base)
Perform a synchronous reset of Glikey.
mcuxClGlikey_Status_t mcuxClGlikey_SetIntEnable(mcuxClGlikey_BaseAddress_t *base, mcuxClGlikey_IntEnable_t value)
Set interrupt enable flag of Glikey.
mcuxClGlikey_Status_t mcuxClGlikey_EndOperation(mcuxClGlikey_BaseAddress_t *base)
End Glikey operation TODO: if we are in locked state we cannot exit(move to init) as curent index is ...
mcuxClGlikey_Status_t mcuxClGlikey_ClearIntStatus(mcuxClGlikey_BaseAddress_t *base)
Clear the interrupt status flag of Glikey.
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:186
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:158