123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #include "sdk_common.h"
- #if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310_BL)
- #include "nrf.h"
- #include "nrf_crypto_init.h"
- #include "nrf_crypto_error.h"
- #include "cc310_bl_backend_shared.h"
- #include "cc310_backend_mutex.h"
- #include "sns_silib.h"
- #include "nrf_cc310_bl_init.h"
- nrf_mtx_t g_cc310_mutex;
- static uint32_t init_result_get(uint32_t crys_error)
- {
- uint32_t ret_val = NRF_ERROR_INTERNAL;
- switch (crys_error)
- {
- case SA_SILIB_RET_OK:
- ret_val = NRF_SUCCESS;
- break;
- case SA_SILIB_RET_EINVAL_HW_VERSION:
- ret_val = NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE;
- break;
- default:
- ret_val = NRF_ERROR_INTERNAL;
- break;
- }
- return ret_val;
- }
- static ret_code_t cc310_bl_backend_init(void)
- {
- uint32_t ret_val;
- CRYSError_t crys_error;
- cc310_backend_mutex_init();
-
- NRF_CRYPTOCELL->ENABLE = 1;
-
- crys_error = nrf_cc310_bl_init();
-
- NRF_CRYPTOCELL->ENABLE = 0;
- ret_val = init_result_get(crys_error);
- return ret_val;
- }
- static ret_code_t cc310_bl_backend_uninit(void)
- {
-
- NRF_CRYPTOCELL->ENABLE = 0;
- return NRF_SUCCESS;
- }
- CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const cc310_bl_backend) =
- {
- .init_fn = cc310_bl_backend_init,
- .uninit_fn = cc310_bl_backend_uninit
- };
- #endif
|