mmu: move mem_caps macro to hal/mmu_types.h as an enum type

This commit is contained in:
Armando 2022-09-23 17:28:36 +08:00
parent 8ba67dfc38
commit 16398c2d06
4 changed files with 14 additions and 11 deletions

View File

@ -8,7 +8,7 @@
#include "sdkconfig.h"
#include "soc/ext_mem_defs.h"
#include "ext_mem_layout.h"
#include "mmu.h"
#include "hal/mmu_types.h"
#if CONFIG_IDF_TARGET_ESP32

View File

@ -184,7 +184,7 @@ void esp_mmu_init(void)
assert(available_region_idx == region_num);
}
esp_err_t esp_mmu_get_max_consecutive_free_block(int caps, size_t *out_len)
esp_err_t esp_mmu_get_max_consecutive_free_block(mmu_mem_caps_t caps, size_t *out_len)
{
ESP_RETURN_ON_FALSE(out_len, ESP_ERR_INVALID_ARG, TAG, "null pointer");
if (caps & MMU_MEM_CAP_EXEC) {
@ -210,7 +210,7 @@ esp_err_t esp_mmu_get_max_consecutive_free_block(int caps, size_t *out_len)
return ESP_OK;
}
esp_err_t esp_mmu_reserve_block_with_caps(size_t size, uint32_t caps, const void **out_ptr)
esp_err_t esp_mmu_reserve_block_with_caps(size_t size, mmu_mem_caps_t caps, const void **out_ptr)
{
ESP_RETURN_ON_FALSE(out_ptr, ESP_ERR_INVALID_ARG, TAG, "null pointer");
if (caps & MMU_MEM_CAP_EXEC) {

View File

@ -24,12 +24,6 @@ extern "C" {
*/
#define MMU_MEM_CAP_EXEC (1<<0)
#define MMU_MEM_CAP_READ (1<<1)
#define MMU_MEM_CAP_WRITE (1<<2)
#define MMU_MEM_CAP_32BIT (1<<3)
#define MMU_MEM_CAP_8BIT (1<<4)
/**
* @brief Initialise the MMU driver
*
@ -47,7 +41,7 @@ void esp_mmu_init(void);
* - ESP_OK: On success
* - ESP_ERR_INVALID_ARG: Invalid arguments, could be null pointer
*/
esp_err_t esp_mmu_get_max_consecutive_free_block(int caps, size_t *out_len);
esp_err_t esp_mmu_get_max_consecutive_free_block(mmu_mem_caps_t caps, size_t *out_len);
/**
* @brief Reserve a consecutive external virtual memory block, with given capabilities and size
@ -61,7 +55,7 @@ esp_err_t esp_mmu_get_max_consecutive_free_block(int caps, size_t *out_len);
* - ESP_ERR_INVALID_ARG: Invalid arguments, could be wrong caps makeup, or null pointer
* - ESP_ERR_NOT_FOUND: Didn't find enough memory with give caps
*/
esp_err_t esp_mmu_reserve_block_with_caps(size_t size, uint32_t caps, const void **out_ptr);
esp_err_t esp_mmu_reserve_block_with_caps(size_t size, mmu_mem_caps_t caps, const void **out_ptr);
/**
* @brief Dump internal memory region usage

View File

@ -6,11 +6,20 @@
#pragma once
#include "esp_bit_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
MMU_MEM_CAP_EXEC = BIT(0),
MMU_MEM_CAP_READ = BIT(1),
MMU_MEM_CAP_WRITE = BIT(2),
MMU_MEM_CAP_32BIT = BIT(3),
MMU_MEM_CAP_8BIT = BIT(4),
} mmu_mem_caps_t;
/**
* MMU Page size
*/