mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
fix(hal): Fix key_mgr_ll_reset_register API
the key_mgr_ll_reset_register API now waits till key manager state is IDLE
This commit is contained in:
committed by
Mahavir Jain
parent
82db0feab2
commit
b0664a6f2e
@@ -54,19 +54,35 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable)
|
|||||||
#define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__)
|
#define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset the Key Manager peripheral */
|
* @brief Read state of Key Manager
|
||||||
static inline void key_mgr_ll_reset_register(void)
|
*
|
||||||
|
* @return esp_key_mgr_state_t
|
||||||
|
*/
|
||||||
|
static inline esp_key_mgr_state_t key_mgr_ll_get_state(void)
|
||||||
|
{
|
||||||
|
return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the Key Manager peripheral
|
||||||
|
* Note: Please use key_mgr_ll_reset_register which requires the critical section
|
||||||
|
* and do not use _key_mgr_ll_reset_register
|
||||||
|
*/
|
||||||
|
static inline void _key_mgr_ll_reset_register(void)
|
||||||
{
|
{
|
||||||
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 1;
|
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 1;
|
||||||
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 0;
|
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 0;
|
||||||
|
|
||||||
// Clear reset on parent crypto, otherwise Key Manager is held in reset
|
// Clear reset on parent crypto, otherwise Key Manager is held in reset
|
||||||
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_crypto = 0;
|
HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_crypto = 0;
|
||||||
|
|
||||||
|
while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; key_mgr_ll_reset_register(__VA_ARGS__)
|
#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_reset_register(__VA_ARGS__)
|
||||||
|
|
||||||
/* @brief Start the key manager at IDLE state */
|
/* @brief Start the key manager at IDLE state */
|
||||||
static inline void key_mgr_ll_start(void)
|
static inline void key_mgr_ll_start(void)
|
||||||
@@ -323,16 +339,6 @@ static inline esp_key_mgr_xts_aes_key_len_t key_mgr_ll_get_xts_aes_key_len(void)
|
|||||||
return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_XTS_AES_KEY_LEN);
|
return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_XTS_AES_KEY_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read state of Key Manager
|
|
||||||
*
|
|
||||||
* @return esp_key_mgr_state_t
|
|
||||||
*/
|
|
||||||
static inline esp_key_mgr_state_t key_mgr_ll_get_state(void)
|
|
||||||
{
|
|
||||||
return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read the Key Manager date information
|
* @brief Read the Key Manager date information
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user