Просмотр исходного кода

mmu: rename api to esp_mmu_reserve_block_with_caps

esp_mmu_get_largest_free_block() ->
esp_mmu_get_max_consecutive_free_block()

esp_mmu_find_vaddr_range() -> esp_mmu_reserve_block_with_caps()
Armando 3 лет назад
Родитель
Сommit
8ba67dfc38
3 измененных файлов с 10 добавлено и 10 удалено
  1. 4 4
      components/esp_psram/esp_psram.c
  2. 2 2
      components/esp_psram/mmu.c
  3. 4 4
      components/esp_psram/mmu.h

+ 4 - 4
components/esp_psram/esp_psram.c

@@ -203,12 +203,12 @@ esp_err_t esp_psram_init(void)
     size_t total_mapped_size = 0;
     size_t size_to_map = 0;
     size_t byte_aligned_size = 0;
-    ret = esp_mmu_get_largest_free_block(MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_8BIT | MMU_MEM_CAP_32BIT, &byte_aligned_size);
+    ret = esp_mmu_get_max_consecutive_free_block(MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_8BIT | MMU_MEM_CAP_32BIT, &byte_aligned_size);
     assert(ret == ESP_OK);
     size_to_map = MIN(byte_aligned_size, psram_available_size);
 
     const void *v_start_8bit_aligned = NULL;
-    ret = esp_mmu_find_vaddr_range(size_to_map, MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_8BIT | MMU_MEM_CAP_32BIT, &v_start_8bit_aligned);
+    ret = esp_mmu_reserve_block_with_caps(size_to_map, MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_8BIT | MMU_MEM_CAP_32BIT, &v_start_8bit_aligned);
     assert(ret == ESP_OK);
 
 #if CONFIG_IDF_TARGET_ESP32
@@ -248,12 +248,12 @@ esp_err_t esp_psram_init(void)
         size_to_map = psram_available_size - total_mapped_size;
 
         size_t word_aligned_size = 0;
-        ret = esp_mmu_get_largest_free_block(MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_32BIT, &word_aligned_size);
+        ret = esp_mmu_get_max_consecutive_free_block(MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_32BIT, &word_aligned_size);
         assert(ret == ESP_OK);
         size_to_map = MIN(word_aligned_size, size_to_map);
 
         const void *v_start_32bit_aligned = NULL;
-        ret = esp_mmu_find_vaddr_range(size_to_map, MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_32BIT, &v_start_32bit_aligned);
+        ret = esp_mmu_reserve_block_with_caps(size_to_map, MMU_MEM_CAP_READ | MMU_MEM_CAP_WRITE | MMU_MEM_CAP_32BIT, &v_start_32bit_aligned);
         assert(ret == ESP_OK);
 
         mmu_hal_map_region(0, MMU_TARGET_PSRAM0, (intptr_t)v_start_32bit_aligned, MMU_PAGE_TO_BYTES(start_page), size_to_map, &actual_mapped_len);

+ 2 - 2
components/esp_psram/mmu.c

@@ -184,7 +184,7 @@ void esp_mmu_init(void)
     assert(available_region_idx == region_num);
 }
 
-esp_err_t esp_mmu_get_largest_free_block(int caps, size_t *out_len)
+esp_err_t esp_mmu_get_max_consecutive_free_block(int 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_largest_free_block(int caps, size_t *out_len)
     return ESP_OK;
 }
 
-esp_err_t esp_mmu_find_vaddr_range(size_t size, uint32_t caps, const void **out_ptr)
+esp_err_t esp_mmu_reserve_block_with_caps(size_t size, uint32_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) {

+ 4 - 4
components/esp_psram/mmu.h

@@ -47,21 +47,21 @@ 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_largest_free_block(int caps, size_t *out_len);
+esp_err_t esp_mmu_get_max_consecutive_free_block(int caps, size_t *out_len);
 
 /**
- * @brief Find a consecutive external virtual memory range, with given capabilities and size
+ * @brief Reserve a consecutive external virtual memory block, with given capabilities and size
  *
  * @param[in] size      Size, in bytes, the amount of memory to find
  * @param[in] caps      Bitwise OR of MMU_MEM_CAP_* flags indicating the memory block
- * @param[out] out_ptr  Pointer to the memory range found
+ * @param[out] out_ptr  Pointer to start address of the memory block that is reserved
  *
  * @return
  *        - ESP_OK:              On success
  *        - 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_find_vaddr_range(size_t size, uint32_t caps, const void **out_ptr);
+esp_err_t esp_mmu_reserve_block_with_caps(size_t size, uint32_t caps, const void **out_ptr);
 
 /**
  * @brief Dump internal memory region usage