Merge branch 'feat/mmu_find_paddr_caps_by_any_offset_v5.2' into 'release/v5.2'

mmu: supported find paddr caps by any paddr offset (v5.2)

See merge request espressif/esp-idf!36840
This commit is contained in:
morris 2025-02-28 17:59:56 +08:00
commit d08c883ec3
2 changed files with 21 additions and 1 deletions

View File

@ -351,7 +351,7 @@ IRAM_ATTR esp_err_t esp_mmu_paddr_find_caps(const esp_paddr_t paddr, mmu_mem_cap
}
//now we are only traversing the actual dynamically allocated blocks, dummy_head and dummy_tail are excluded already
if (mem_block->paddr_start == paddr) {
if (paddr >= mem_block->paddr_start && paddr < mem_block->paddr_end) {
found = true;
found_block = mem_block;
break;

View File

@ -50,3 +50,23 @@ TEST_CASE("Can dump mapped block stats", "[mmu]")
TEST_ESP_OK(esp_mmu_unmap(ptr1));
TEST_ESP_OK(esp_mmu_unmap(ptr2));
}
TEST_CASE("Can find paddr caps by any paddr offset", "[mmu]")
{
const esp_partition_t *part = s_get_partition();
ESP_LOGI(TAG, "found partition '%s' at offset 0x%"PRIx32" with size 0x%"PRIx32, part->label, part->address, part->size);
void *ptr0 = NULL;
TEST_ESP_OK(esp_mmu_map(part->address, TEST_BLOCK_SIZE, MMU_TARGET_FLASH0, MMU_MEM_CAP_READ, 0, &ptr0));
mmu_mem_caps_t caps = 0;
TEST_ESP_OK(esp_mmu_paddr_find_caps(part->address, &caps));
ESP_LOGI(TAG, "caps: 0x%x", caps);
TEST_ASSERT(caps == MMU_MEM_CAP_READ);
TEST_ESP_OK(esp_mmu_paddr_find_caps(part->address + 0x100, &caps));
ESP_LOGI(TAG, "caps: 0x%x", caps);
TEST_ASSERT(caps == MMU_MEM_CAP_READ);
TEST_ESP_OK(esp_mmu_unmap(ptr0));
}