1 /**************************************************************************/ /** 2 * @file 3 * @brief Threadsafe utilities for RADIOAES peripheral. 4 ******************************************************************************* 5 * # License 6 * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b> 7 ******************************************************************************* 8 * 9 * SPDX-License-Identifier: Zlib 10 * 11 * The licensor of this software is Silicon Laboratories Inc. 12 * 13 * This software is provided 'as-is', without any express or implied 14 * warranty. In no event will the authors be held liable for any damages 15 * arising from the use of this software. 16 * 17 * Permission is granted to anyone to use this software for any purpose, 18 * including commercial applications, and to alter it and redistribute it 19 * freely, subject to the following restrictions: 20 * 21 * 1. The origin of this software must not be misrepresented; you must not 22 * claim that you wrote the original software. If you use this software 23 * in a product, an acknowledgment in the product documentation would be 24 * appreciated but is not required. 25 * 2. Altered source versions must be plainly marked as such, and must not be 26 * misrepresented as being the original software. 27 * 3. This notice may not be removed or altered from any source distribution. 28 * 29 ******************************************************************************/ 30 #ifndef SLI_RADIOAES_MANAGEMENT_H 31 #define SLI_RADIOAES_MANAGEMENT_H 32 33 /// @cond DO_NOT_INCLUDE_WITH_DOXYGEN 34 35 #include <stdint.h> 36 #include "sl_status.h" 37 38 #if defined(RADIOAES_PRESENT) 39 40 /***************************************************************************//** 41 * @addtogroup sli_protocol_crypto 42 * @{ 43 ******************************************************************************/ 44 45 /// 46 /// @brief Structure that represents the state of the RADIOAES peripheral 47 /// (in scatter-gather mode). 48 /// 49 typedef struct { 50 uint32_t FETCHADDR; ///< Fetcher Address 51 uint32_t PUSHADDR; ///< Pusher Address 52 } sli_radioaes_state_t; 53 54 #if defined(SLI_RADIOAES_REQUIRES_MASKING) 55 /// Static variable containing the masking value for the RADIOAES 56 extern uint32_t sli_radioaes_mask; 57 #endif // SLI_RADIOAES_REQUIRES_MASKING 58 59 /***************************************************************************//** 60 * @brief Acquire RADIOAES access 61 * 62 * @return SL_STATUS_OK if successful and resource is idle, 63 * SL_STATUS_ISR if successful but resource was preempted, in 64 * which case the caller is responsible for saving state, 65 * relevant status code on error 66 ******************************************************************************/ 67 sl_status_t sli_radioaes_acquire(void); 68 69 /***************************************************************************//** 70 * @brief Release RADIOAES access 71 * 72 * @return SL_STATUS_OK if successful, relevant status code on error 73 ******************************************************************************/ 74 sl_status_t sli_radioaes_release(void); 75 76 /***************************************************************************//** 77 * @brief Save RADIOAES register state to RAM 78 * 79 * @param ctx Context struct to save register state into 80 * 81 * @return SL_STATUS_OK if successful, relevant status code on error 82 ******************************************************************************/ 83 sl_status_t sli_radioaes_save_state(sli_radioaes_state_t *ctx); 84 85 /***************************************************************************//** 86 * @brief Restore RADIOAES register state from RAM 87 * 88 * @param ctx Context struct to restore register state from 89 * 90 * @return SL_STATUS_OK if successful, relevant status code on error 91 ******************************************************************************/ 92 sl_status_t sli_radioaes_restore_state(sli_radioaes_state_t *ctx); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 /// @} (end addtogroup sli_protocol_crypto) 99 #endif // RADIOAES_PRESENT 100 /// @endcond 101 #endif // SLI_RADIOAES_MANAGEMENT_H 102