Mbed OS Reference
Loading...
Searching...
No Matches
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 * \brief Management functions for CRYPTO peripherals. These functions take care
25 * of not having two 'owners' simultaneously for the same peripheral,
26 * potentially messing up the internal state of said peripheral.
27 * \{
28 ******************************************************************************/
29
30#if !defined(MBEDTLS_CONFIG_FILE)
31#include "mbedtls/config.h"
32#else
33#include MBEDTLS_CONFIG_FILE
34#endif
35
36#include <stdlib.h>
37
38#include "em_device.h"
39
40#if defined( CRYPTO_PRESENT )
41#include "em_crypto.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/** Save DDATA0 register when preempting */
48#define CRYPTO_MANAGEMENT_SAVE_DDATA0 (0x1U << 3)
49/** Save DDATA1 register when preempting */
50#define CRYPTO_MANAGEMENT_SAVE_DDATA1 (0x1U << 4)
51/** Save DDATA2 register when preempting */
52#define CRYPTO_MANAGEMENT_SAVE_DDATA2 (0x1U << 5)
53/** Save DDATA3 register when preempting */
54#define CRYPTO_MANAGEMENT_SAVE_DDATA3 (0x1U << 6)
55/** Save DDATA4 register when preempting */
56#define CRYPTO_MANAGEMENT_SAVE_DDATA4 (0x1U << 7)
57/** Save SEQ0 register when preempting */
58#define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ0 (0x1U)
59/** Save SEQ0 through SEQ1 register when preempting */
60#define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ1 (0x2U)
61/** Save SEQ0 through SEQ2 register when preempting */
62#define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ2 (0x3U)
63/** Save SEQ0 through SEQ3 register when preempting */
64#define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ3 (0x4U)
65/** Save SEQ0 through SEQ4 register when preempting */
66#define CRYPTO_MANAGEMENT_SAVE_UPTO_SEQ4 (0x5U)
67
68/**
69 * \brief Get ownership of a CRYPTO peripheral
70 *
71 * \return Handle of assigned CRYPTO peripheral
72 */
73CRYPTO_TypeDef *crypto_management_acquire( void );
74
75/**
76 * \brief Get ownership of the default CRYPTO peripheral
77 *
78 * \return Handle of default CRYPTO peripheral
79 */
80CRYPTO_TypeDef *crypto_management_acquire_default( void );
81
82/**
83 * \brief Release ownership of a CRYPTO peripheral
84 *
85 * \param device Handle of CRYPTO peripheral to be released
86 */
87void crypto_management_release( CRYPTO_TypeDef *device );
88
89/**
90 * \brief Acquire preempting ownership of a CRYPTO peripheral.
91 * NOTE: this function is not meant for general use, it
92 * is not thread-safe, and must be called form the
93 * highest priority thread/interrupt allowed to use mbed TLS.
94 *
95 * \param regmask Bitmask of CRYPTO_MANAGEMENT_ defines instructing what
96 * parts of the device state will be clobbered during
97 * preemption.
98 *
99 * \return Handle of assigned CRYPTO peripheral
100 */
101CRYPTO_TypeDef *crypto_management_acquire_preemption( uint32_t regmask );
102
103/**
104 * \brief Releasing preempting ownership of a CRYPTO peripheral.
105 * NOTE: this function is not meant for general use, it
106 * is not thread-safe, and must be called form the
107 * highest priority thread/interrupt allowed to use mbed TLS.
108 *
109 * \param device Handle of preempted CRYPTO peripheral to be released
110 */
111void crypto_management_release_preemption( CRYPTO_TypeDef *device );
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* CRYPTO_PRESENT */
118
119/** \}*/
120
121#endif /* CRYPTO_MANAGEMENT_H */
Configuration options (set of defines)