bootloader_mem.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdbool.h>
  7. #include "hal/mpu_hal.h"
  8. #include "hal/mpu_types.h"
  9. #include "soc/soc_caps.h"
  10. #include "bootloader_mem.h"
  11. #include "esp_cpu.h"
  12. #if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
  13. #include "soc/hp_apm_reg.h"
  14. #include "soc/lp_apm_reg.h"
  15. #include "soc/lp_apm0_reg.h"
  16. #endif
  17. void bootloader_init_mem(void)
  18. {
  19. #if SOC_APM_SUPPORTED
  20. /* By default, these access path filters are enable and allow the
  21. * access to masters only if they are in TEE mode. Since all masters
  22. * except HP CPU boots in REE mode, default setting of these filters
  23. * will deny the access to all masters except HP CPU.
  24. * So, at boot disabling these filters. They will enable as per the
  25. * use case by TEE initialization code.
  26. */
  27. REG_WRITE(LP_APM_FUNC_CTRL_REG, 0);
  28. REG_WRITE(LP_APM0_FUNC_CTRL_REG, 0);
  29. REG_WRITE(HP_APM_FUNC_CTRL_REG, 0);
  30. #endif
  31. #ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
  32. // protect memory region
  33. esp_cpu_configure_region_protection();
  34. #endif
  35. }