mmu: hal function to init, and hal function to unmap all

This commit is contained in:
Armando
2023-03-13 11:37:23 +08:00
parent 929b7717ff
commit bae6680207
11 changed files with 21 additions and 20 deletions

View File

@@ -241,7 +241,7 @@ void bootloader_munmap(const void *mapping)
mmu_init(0); mmu_init(0);
#else #else
cache_hal_disable(CACHE_TYPE_ALL); cache_hal_disable(CACHE_TYPE_ALL);
mmu_hal_init(); mmu_hal_unmap_all();
#endif #endif
mapped = false; mapped = false;
current_read_mapping = UINT32_MAX; current_read_mapping = UINT32_MAX;

View File

@@ -845,8 +845,8 @@ static void set_cache_and_start_app(
#else #else
cache_hal_disable(CACHE_TYPE_ALL); cache_hal_disable(CACHE_TYPE_ALL);
#endif #endif
//reset MMU table first
mmu_hal_init(); mmu_hal_unmap_all();
//-----------------------MAP DROM-------------------------- //-----------------------MAP DROM--------------------------
uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK; uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK;

View File

@@ -38,7 +38,6 @@
#include "esp_efuse.h" #include "esp_efuse.h"
#include "hal/mmu_hal.h" #include "hal/mmu_hal.h"
#include "hal/cache_hal.h" #include "hal/cache_hal.h"
#include "hal/mmu_ll.h"
static const char *TAG = "boot.esp32c2"; static const char *TAG = "boot.esp32c2";
@@ -113,10 +112,8 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); cache_hal_init();
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// config mmu page size
mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();
#if !CONFIG_APP_BUILD_TYPE_RAM #if !CONFIG_APP_BUILD_TYPE_RAM

View File

@@ -161,7 +161,7 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); cache_hal_init();
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();

View File

@@ -40,7 +40,6 @@
#include "esp_private/bootloader_flash_internal.h" #include "esp_private/bootloader_flash_internal.h"
#include "esp_efuse.h" #include "esp_efuse.h"
#include "hal/mmu_hal.h" #include "hal/mmu_hal.h"
#include "hal/mmu_ll.h"
#include "hal/cache_hal.h" #include "hal/cache_hal.h"
#include "hal/clk_tree_ll.h" #include "hal/clk_tree_ll.h"
#include "soc/lp_wdt_reg.h" #include "soc/lp_wdt_reg.h"
@@ -169,10 +168,8 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); cache_hal_init();
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// config mmu page size
mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();
// Check and run XMC startup flow // Check and run XMC startup flow

View File

@@ -40,7 +40,6 @@
#include "esp_private/bootloader_flash_internal.h" #include "esp_private/bootloader_flash_internal.h"
#include "esp_efuse.h" #include "esp_efuse.h"
#include "hal/mmu_hal.h" #include "hal/mmu_hal.h"
#include "hal/mmu_ll.h"
#include "hal/cache_hal.h" #include "hal/cache_hal.h"
#include "soc/lp_wdt_reg.h" #include "soc/lp_wdt_reg.h"
#include "hal/efuse_hal.h" #include "hal/efuse_hal.h"
@@ -159,10 +158,8 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); cache_hal_init();
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// config mmu page size
mmu_ll_set_page_size(0, SPI_FLASH_MMU_PAGE_SIZE);
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();
// Check and run XMC startup flow // Check and run XMC startup flow

View File

@@ -120,7 +120,7 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); //TODO IDF-4649 cache_hal_init(); //TODO IDF-4649
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();

View File

@@ -142,7 +142,7 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
// init cache hal // init cache hal
cache_hal_init(); cache_hal_init();
// reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// Workaround: normal ROM bootloader exits with DROM0 cache unmasked, but 2nd bootloader exits with it masked. // Workaround: normal ROM bootloader exits with DROM0 cache unmasked, but 2nd bootloader exits with it masked.
REG_CLR_BIT(EXTMEM_PRO_ICACHE_CTRL1_REG, EXTMEM_PRO_ICACHE_MASK_DROM0); REG_CLR_BIT(EXTMEM_PRO_ICACHE_CTRL1_REG, EXTMEM_PRO_ICACHE_MASK_DROM0);

View File

@@ -180,7 +180,7 @@ esp_err_t bootloader_init(void)
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
//init cache hal //init cache hal
cache_hal_init(); cache_hal_init();
//reset mmu //init mmu
mmu_hal_init(); mmu_hal_init();
// update flash ID // update flash ID
bootloader_flash_update_id(); bootloader_flash_update_id();

View File

@@ -14,10 +14,15 @@ extern "C" {
#endif #endif
/** /**
* Unmap all the MMU table. After this all external memory vaddr are not available * MMU Hal layer initialisation
*/ */
void mmu_hal_init(void); void mmu_hal_init(void);
/**
* Unmap all the MMU table. After this all external memory vaddr are not available
*/
void mmu_hal_unmap_all(void);
/** /**
* Helper functions to convert the MMU page numbers into bytes. e.g.: * Helper functions to convert the MMU page numbers into bytes. e.g.:
* - When MMU page size is 16KB, page_num = 2 will be converted into 32KB * - When MMU page size is 16KB, page_num = 2 will be converted into 32KB

View File

@@ -19,7 +19,12 @@ void mmu_hal_init(void)
#if CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT #if CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT
ROM_Boot_Cache_Init(); ROM_Boot_Cache_Init();
#endif #endif
mmu_ll_set_page_size(0, CONFIG_MMU_PAGE_SIZE);
mmu_hal_unmap_all();
}
void mmu_hal_unmap_all(void)
{
mmu_ll_unmap_all(0); mmu_ll_unmap_all(0);
#if !CONFIG_FREERTOS_UNICORE #if !CONFIG_FREERTOS_UNICORE
mmu_ll_unmap_all(1); mmu_ll_unmap_all(1);