2021-05-09 22:35:07 -04:00
|
|
|
/*
|
2024-02-07 03:56:53 -05:00
|
|
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
2021-05-09 22:35:07 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-02-03 05:12:32 -05:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "hal/mpu_hal.h"
|
|
|
|
#include "hal/mpu_types.h"
|
2020-09-09 22:37:58 -04:00
|
|
|
#include "soc/soc_caps.h"
|
2020-02-03 05:12:32 -05:00
|
|
|
#include "bootloader_mem.h"
|
2021-12-13 23:38:15 -05:00
|
|
|
#include "esp_cpu.h"
|
2020-02-03 05:12:32 -05:00
|
|
|
|
2023-09-28 07:01:06 -04:00
|
|
|
#if SOC_APM_SUPPORTED
|
|
|
|
#include "hal/apm_hal.h"
|
2022-07-08 04:46:11 -04:00
|
|
|
#endif
|
|
|
|
|
2024-02-07 03:56:53 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32C5 // TODO: IDF-8615 Remove the workaround when APM supported on C5!
|
|
|
|
#include "soc/hp_apm_reg.h"
|
|
|
|
#include "soc/lp_apm_reg.h"
|
|
|
|
#include "soc/lp_apm0_reg.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-03 05:12:32 -05:00
|
|
|
void bootloader_init_mem(void)
|
|
|
|
{
|
2023-09-28 07:01:06 -04:00
|
|
|
|
|
|
|
#if !defined(BOOTLOADER_BUILD) && defined(SOC_APM_SUPPORTED)
|
2023-02-13 01:52:15 -05:00
|
|
|
/* 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.
|
|
|
|
*/
|
2023-09-28 07:01:06 -04:00
|
|
|
apm_hal_apm_ctrl_filter_enable_all(false);
|
2022-07-08 04:46:11 -04:00
|
|
|
#endif
|
|
|
|
|
2024-02-07 03:56:53 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32C5 // TODO: IDF-8615 Remove the workaround when APM supported on C5!
|
|
|
|
// disable apm filter
|
|
|
|
REG_WRITE(LP_APM_FUNC_CTRL_REG, 0);
|
|
|
|
REG_WRITE(LP_APM0_FUNC_CTRL_REG, 0);
|
|
|
|
REG_WRITE(HP_APM_FUNC_CTRL_REG, 0);
|
|
|
|
#endif
|
|
|
|
|
2022-05-02 09:37:19 -04:00
|
|
|
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
2020-02-03 05:12:32 -05:00
|
|
|
// protect memory region
|
2020-11-05 23:00:07 -05:00
|
|
|
esp_cpu_configure_region_protection();
|
2022-05-02 09:37:19 -04:00
|
|
|
#endif
|
2020-11-10 02:40:01 -05:00
|
|
|
}
|