2021-05-10 04:35:07 +02:00
|
|
|
|
/*
|
2025-02-18 16:05:36 +08:00
|
|
|
|
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
2021-05-10 04:35:07 +02:00
|
|
|
|
*
|
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
*/
|
2020-02-03 18:12:32 +08:00
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "hal/mpu_hal.h"
|
|
|
|
|
|
#include "hal/mpu_types.h"
|
2020-09-10 10:37:58 +08:00
|
|
|
|
#include "soc/soc_caps.h"
|
2020-02-03 18:12:32 +08:00
|
|
|
|
#include "bootloader_mem.h"
|
2021-12-14 10:08:15 +05:30
|
|
|
|
#include "esp_cpu.h"
|
2020-02-03 18:12:32 +08:00
|
|
|
|
|
2023-09-28 16:31:06 +05:30
|
|
|
|
#include "hal/apm_hal.h"
|
2022-07-08 16:46:11 +08:00
|
|
|
|
|
2020-02-03 18:12:32 +08:00
|
|
|
|
void bootloader_init_mem(void)
|
|
|
|
|
|
{
|
2023-09-28 16:31:06 +05:30
|
|
|
|
|
2025-02-18 16:05:36 +08:00
|
|
|
|
#if !defined(BOOTLOADER_BUILD)
|
2023-02-13 12:22:15 +05:30
|
|
|
|
/* By default, these access path filters are enable and allow the
|
|
|
|
|
|
* access to masters only if they are in TEE mode. Since all masters
|
|
|
|
|
|
* except HP CPU boots in REE mode, default setting of these filters
|
|
|
|
|
|
* will deny the access to all masters except HP CPU.
|
|
|
|
|
|
* So, at boot disabling these filters. They will enable as per the
|
|
|
|
|
|
* use case by TEE initialization code.
|
|
|
|
|
|
*/
|
2025-07-22 12:21:36 +08:00
|
|
|
|
#if SOC_APM_CTRL_FILTER_SUPPORTED
|
|
|
|
|
|
apm_hal_enable_ctrl_filter_all(false);
|
|
|
|
|
|
/* [APM] On power-up, only the HP CPU starts in TEE mode; others
|
|
|
|
|
|
* default to REE2. APM blocks REE0–REE2 access by default.
|
|
|
|
|
|
* Thus, all masters are set to TEE mode.
|
2025-05-09 13:59:56 +05:30
|
|
|
|
*/
|
|
|
|
|
|
#if SOC_APM_SUPPORT_TEE_PERI_ACCESS_CTRL
|
2025-07-22 12:21:36 +08:00
|
|
|
|
apm_hal_set_master_sec_mode_all(APM_SEC_MODE_TEE);
|
2025-05-09 13:59:56 +05:30
|
|
|
|
#endif // SOC_APM_SUPPORT_TEE_PERI_ACCESS_CTRL
|
|
|
|
|
|
#endif // SOC_APM_CTRL_FILTER_SUPPORTED
|
2024-05-21 15:31:09 +05:30
|
|
|
|
#endif
|
2022-07-08 16:46:11 +08:00
|
|
|
|
|
2025-07-22 12:21:36 +08:00
|
|
|
|
#if CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
2020-02-03 18:12:32 +08:00
|
|
|
|
// protect memory region
|
2024-05-31 22:31:57 +05:30
|
|
|
|
esp_cpu_configure_region_protection();
|
2022-05-02 10:37:19 -03:00
|
|
|
|
#endif
|
2020-11-10 18:40:01 +11:00
|
|
|
|
}
|