diff --git a/kernel/include/mmu.h b/kernel/include/mmu.h index f39656b5453..78569657b55 100644 --- a/kernel/include/mmu.h +++ b/kernel/include/mmu.h @@ -43,15 +43,34 @@ #define Z_VM_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET)) -/* Only applies to boot RAM mappings within the Zephyr image that have never - * been remapped or paged out. Never use this unless you know exactly what you - * are doing. +/** + * @brief Get physical address from virtual address for boot RAM mappings. + * + * @note Only applies to boot RAM mappings within the Zephyr image that have never + * been remapped or paged out. Never use this unless you know exactly what you + * are doing. + * + * @param virt Virtual address. + * + * @return Physical address. */ -#define Z_BOOT_VIRT_TO_PHYS(virt) ((uintptr_t)(((uint8_t *)(virt)) - Z_VM_OFFSET)) -#define Z_BOOT_PHYS_TO_VIRT(phys) ((uint8_t *)(((uintptr_t)(phys)) + Z_VM_OFFSET)) +#define K_MEM_BOOT_VIRT_TO_PHYS(virt) ((uintptr_t)(((uint8_t *)(virt)) - Z_VM_OFFSET)) + +/** + * @brief Get virtual address from physical address for boot RAM mappings. + * + * @note Only applies to boot RAM mappings within the Zephyr image that have never + * been remapped or paged out. Never use this unless you know exactly what you + * are doing. + * + * @param phys Physical address. + * + * @return Virtual address. + */ +#define K_MEM_BOOT_PHYS_TO_VIRT(phys) ((uint8_t *)(((uintptr_t)(phys)) + Z_VM_OFFSET)) #ifdef CONFIG_ARCH_MAPS_ALL_RAM -#define Z_FREE_VM_START Z_BOOT_PHYS_TO_VIRT(Z_PHYS_RAM_END) +#define Z_FREE_VM_START K_MEM_BOOT_PHYS_TO_VIRT(Z_PHYS_RAM_END) #else #define Z_FREE_VM_START Z_KERNEL_VIRT_END #endif /* CONFIG_ARCH_MAPS_ALL_RAM */ diff --git a/kernel/mmu.c b/kernel/mmu.c index e90a9a177f0..391c74b2145 100644 --- a/kernel/mmu.c +++ b/kernel/mmu.c @@ -936,7 +936,7 @@ static void mark_linker_section_pinned(void *start_addr, void *end_addr, VIRT_FOREACH(UINT_TO_POINTER(pinned_start), pinned_size, addr) { - pf = z_phys_to_page_frame(Z_BOOT_VIRT_TO_PHYS(addr)); + pf = z_phys_to_page_frame(K_MEM_BOOT_VIRT_TO_PHYS(addr)); frame_mapped_set(pf, addr); if (pin) { @@ -972,7 +972,7 @@ void z_mem_manage_init(void) */ VIRT_FOREACH(Z_KERNEL_VIRT_START, Z_KERNEL_VIRT_SIZE, addr) { - pf = z_phys_to_page_frame(Z_BOOT_VIRT_TO_PHYS(addr)); + pf = z_phys_to_page_frame(K_MEM_BOOT_VIRT_TO_PHYS(addr)); frame_mapped_set(pf, addr); /* TODO: for now we pin the whole Zephyr image. Demand paging