Mistake on this page?
Report an issue in GitHub or email us
crypto_management.h
1 /*
2  * Silicon Labs CRYPTO device management interface.
3  *
4  * Copyright (C) 2016, Silicon Labs, http://www.silabs.com
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may
8  * not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef CRYPTO_MANAGEMENT_H
21 #define CRYPTO_MANAGEMENT_H
22 
23 /***************************************************************************//**
24  * \addtogroup sl_crypto
25  * \{
26  ******************************************************************************/
27 
28 /***************************************************************************//**
29  * \addtogroup sl_crypto_management CRYPTO peripheral instance management
30  * \brief Management functions for CRYPTO peripherals. These functions take care
31  * of not having two 'owners' simultaneously for the same peripheral,
32  * potentially messing up the internal state of said peripheral.
33  * \{
34  ******************************************************************************/
35 
36 #if !defined(MBEDTLS_CONFIG_FILE)
37 #include "mbedtls/config.h"
38 #else
39 #include MBEDTLS_CONFIG_FILE
40 #endif
41 
42 #include <stdlib.h>
43 
44 #include "em_device.h"
45 
46 #if defined( CRYPTO_PRESENT )
47 #include "em_crypto.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /** Save DDATA0 register when preempting */
54 #define CRYPTO_MANAGEMENT_SAVE_DDATA0 (0x1U << 3)
55 /** Save DDATA1 register when preempting */
56 #define CRYPTO_MANAGEMENT_SAVE_DDATA1 (0x1U << 4)
57 /** Save DDATA2 register when preempting */
58 #define CRYPTO_MANAGEMENT_SAVE_DDATA2 (0x1U << 5)
59 /** Save DDATA3 register when preempting */
60 #define CRYPTO_MANAGEMENT_SAVE_DDATA3 (0x1U << 6)
61 /** Save DDATA4 register when preempting */
62 #define CRYPTO_MANAGEMENT_SAVE_DDATA4 (0x1U << 7)
63 /** Save SEQ0 register when preempting */
64 #define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ0 (0x1U)
65 /** Save SEQ0 through SEQ1 register when preempting */
66 #define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ1 (0x2U)
67 /** Save SEQ0 through SEQ2 register when preempting */
68 #define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ2 (0x3U)
69 /** Save SEQ0 through SEQ3 register when preempting */
70 #define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ3 (0x4U)
71 /** Save SEQ0 through SEQ4 register when preempting */
72 #define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ4 (0x5U)
73 
74 /**
75  * \brief Get ownership of a CRYPTO peripheral
76  *
77  * \return Handle of assigned CRYPTO peripheral
78  */
79 CRYPTO_TypeDef *crypto_management_acquire( void );
80 
81 /**
82  * \brief Get ownership of the default CRYPTO peripheral
83  *
84  * \return Handle of default CRYPTO peripheral
85  */
86 CRYPTO_TypeDef *crypto_management_acquire_default( void );
87 
88 /**
89  * \brief Release ownership of a CRYPTO peripheral
90  *
91  * \param device Handle of CRYPTO peripheral to be released
92  */
93 void crypto_management_release( CRYPTO_TypeDef *device );
94 
95 /**
96  * \brief Acquire preempting ownership of a CRYPTO peripheral.
97  * NOTE: this function is not meant for general use, it
98  * is not thread-safe, and must be called form the
99  * highest priority thread/interrupt allowed to use mbed TLS.
100  *
101  * \param regmask Bitmask of CRYPTO_MANAGEMENT_ defines instructing what
102  * parts of the device state will be clobbered during
103  * preemption.
104  *
105  * \return Handle of assigned CRYPTO peripheral
106  */
107 CRYPTO_TypeDef *crypto_management_acquire_preemption( uint32_t regmask );
108 
109 /**
110  * \brief Releasing preempting ownership of a CRYPTO peripheral.
111  * NOTE: this function is not meant for general use, it
112  * is not thread-safe, and must be called form the
113  * highest priority thread/interrupt allowed to use mbed TLS.
114  *
115  * \param device Handle of preempted CRYPTO peripheral to be released
116  */
117 void crypto_management_release_preemption( CRYPTO_TypeDef *device );
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif /* CRYPTO_PRESENT */
124 
125 /** \} (end addtogroup sl_crypto_management) */
126 /** \} (end addtogroup sl_crypto) */
127 
128 #endif /* CRYPTO_MANAGEMENT_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.