spi_flash_encrypt_hal_iram.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. // This part is put in iram.
  7. #include "hal/spi_flash_encrypted_ll.h"
  8. void spi_flash_encryption_hal_enable(void)
  9. {
  10. spi_flash_encrypt_ll_enable();
  11. #if CONFIG_IDF_TARGET_ESP32S2
  12. spi_flash_encrypt_ll_aes_accelerator_enable();
  13. #endif //CONFIG_IDF_TARGET_ESP32S2
  14. #if !CONFIG_IDF_TARGET_ESP32
  15. spi_flash_encrypt_ll_type(FLASH_ENCRYPTION_MANU);
  16. #endif // !CONFIG_IDF_TARGET_ESP32
  17. }
  18. void spi_flash_encryption_hal_disable(void)
  19. {
  20. spi_flash_encrypt_ll_disable();
  21. }
  22. void spi_flash_encryption_hal_prepare(uint32_t address, const uint32_t* buffer, uint32_t size)
  23. {
  24. #if !CONFIG_IDF_TARGET_ESP32
  25. spi_flash_encrypt_ll_buffer_length(size);
  26. #endif // !CONFIG_IDF_TARGET_ESP32
  27. spi_flash_encrypt_ll_address_save(address);
  28. spi_flash_encrypt_ll_plaintext_save(address, buffer, size);
  29. spi_flash_encrypt_ll_calculate_start();
  30. }
  31. void spi_flash_encryption_hal_done(void)
  32. {
  33. spi_flash_encrypt_ll_calculate_wait_idle();
  34. spi_flash_encrypt_ll_done();
  35. }
  36. void spi_flash_encryption_hal_destroy(void)
  37. {
  38. spi_flash_encrypt_ll_destroy();
  39. }
  40. bool spi_flash_encryption_hal_check(uint32_t address, uint32_t length)
  41. {
  42. return spi_flash_encrypt_ll_check(address, length);
  43. }