Merge branch 'refactor/remove_redundant_rom_cache_dependency' into 'master'

cache: remove redundant rom cache dependency in bootloader

Closes IDF-4523

See merge request espressif/esp-idf!17077
This commit is contained in:
Armando (Dou Yiwen)
2022-03-12 10:11:39 +08:00
70 changed files with 2314 additions and 466 deletions

View File

@@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "hal/cache_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Cache init and cache hal context init
*
*/
void cache_hal_init(void);
/**
* Disable the ICache or DCache or both, all the items in the corresponding Cache(s) will be invalideated.
* Next request to these items will trigger a transaction to the external memory (flash / psram)
*
* @note If the autoload feature is enabled, this API will return until the ICache autoload is disabled.
*
* @param type see `cache_type_t`
*/
void cache_hal_disable(cache_type_t type);
/**
* Enable the ICache or DCache or both.
*
* @param type see `cache_type_t`
*/
void cache_hal_enable(cache_type_t type);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_bit_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CACHE_TYPE_DATA,
CACHE_TYPE_INSTRUCTION,
CACHE_TYPE_ALL //This means both ICache and DCache will be used. On some chips, I/D are controlled by a shared Cache. Also use this enum under this condition. See `SOC_SHARED_IDCACHE_SUPPORTED`.
} cache_type_t;
/**
* @brief Ibuses and Dbuses.
*
* @note
* These enumurations are abstract concepts. Virtual address reside in one of these buses.
* Therefore, use `cache_ll_l1_get_bus(cache_id, vaddr_start, len)` to convert your vaddr into buses first
*/
typedef enum {
CACHE_BUS_IBUS0 = BIT(0),
CACHE_BUS_IBUS1 = BIT(1),
CACHE_BUS_IBUS2 = BIT(2),
CACHE_BUS_DBUS0 = BIT(3),
CACHE_BUS_DBUS1 = BIT(4),
CACHE_BUS_DBUS2 = BIT(5),
} cache_bus_mask_t;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,64 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "hal/mmu_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Unmap all the MMU table. After this all external memory vaddr are not available
*/
void mmu_hal_init(void);
#if !CONFIG_IDF_TARGET_ESP32
/**
* 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 32KB, page_num = 2 will be converted into 64KB
*
* @param mmu_id MMU ID
* @param page_num page numbers
*
* @return
* length in byte
*/
uint32_t mmu_hal_pages_to_bytes(uint32_t mmu_id, uint32_t page_num);
/**
* Helper functions to convert bytes into MMU page numbers. e.g.:
* - When MMU page size is 16KB, bytes = 64KB will be converted into 4 pages
* - When MMU page size is 32KB, bytes = 64KB will be converted into 2 pages
*
* @param mmu_id MMU ID
* @param bytes length in byte
*
* @return
* length in MMU_PAGE_SIZE
*/
uint32_t mmu_hal_bytes_to_pages(uint32_t mmu_id, uint32_t bytes);
/**
* To map a virtual address region to a physical memory region
*
* @param mmu_id MMU ID
* @param mem_type physical memory type, see `mmu_target_t`
* @param vaddr start virtual address to be mapped
* @param paddr start physical address to be mapped
* @param len length to be mapped, in bytes
* @param[out] out_len actual mapped length
*
* @note vaddr and paddr should be aligned with the MMU_PAGE_SIZE, see `mmu_ll.h`
*/
void mmu_hal_map_region(uint32_t mmu_id, mmu_target_t mem_type, uint32_t vaddr, uint32_t paddr, uint32_t len, uint32_t *out_len);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,33 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/**
* MMU Page size
*/
typedef enum {
MMU_PAGE_16KB,
MMU_PAGE_32KB,
MMU_PAGE_64KB,
} mmu_page_size_t;
/**
* External physical memory
*/
typedef enum {
MMU_TARGET_FLASH0,
MMU_TARGET_PSRAM0,
} mmu_target_t;
#ifdef __cplusplus
}
#endif