1 /* 2 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "soc/lldesc.h" 10 #include "esp_private/gdma.h" 11 #include "esp_err.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * @brief Start a GDMA transfer on the shared crypto DMA channel 19 * 20 * @note Will allocate a GDMA channel for AES & SHA if no such channel is already allocated 21 * 22 * @param input Input linked list descriptor 23 * @param output Output linked list descriptor 24 * @param peripheral Crypto peripheral to connect the DMA to, either GDMA_TRIG_PERIPH_AES or 25 * GDMA_TRIG_PERIPH_SHA 26 * @return esp_err_t ESP_FAIL if no GDMA channel available 27 */ 28 esp_err_t esp_crypto_shared_gdma_start(const lldesc_t *input, const lldesc_t *output, gdma_trigger_peripheral_t peripheral); 29 30 31 /** 32 * @brief Frees any shared crypto DMA channel, if esp_crypto_shared_gdma_start is called after 33 * this, new GDMA channels will be allocated. 34 * 35 * @note Function is meant to be called from user code, and thus takes AES/SHA lock. 36 * This means this function should not be called from code which already takes these locks, 37 * i.e. inside our AES/SHA code. 38 * 39 * If you are continously using AES/SHA (e.g. because of a wifi connection) then it's not recommended 40 * to use this API. Freeing the channel is mainly for use cases where you are finished with the crypto peripherals 41 * and need the DMA channel for other peripherals. An example would be doing some processing after disconnecting WiFi 42 */ 43 void esp_crypto_shared_gdma_free(void); 44 45 #ifdef __cplusplus 46 } 47 #endif 48