7#ifndef ZEPHYR_INCLUDE_KERNEL_INTERNAL_MM_H
8#define ZEPHYR_INCLUDE_KERNEL_INTERNAL_MM_H
38#define Z_MEM_VM_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \
39 (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET))
41#define Z_MEM_VM_OFFSET 0
44#define Z_MEM_PHYS_ADDR(virt) ((virt) - Z_MEM_VM_OFFSET)
45#define Z_MEM_VIRT_ADDR(phys) ((phys) + Z_MEM_VM_OFFSET)
47#if Z_MEM_VM_OFFSET != 0
50#error "XIP and a virtual memory kernel are not allowed"
62static inline uintptr_t z_mem_phys_addr(
void *virt)
66#if defined(CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK)
68 "address %p not in permanent mappings", virt);
69#elif defined(CONFIG_MMU)
71#
if CONFIG_KERNEL_VM_BASE != 0
72 (addr >= CONFIG_KERNEL_VM_BASE) &&
74#
if (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_SIZE) != 0
75 (addr < (CONFIG_KERNEL_VM_BASE +
76 (CONFIG_KERNEL_VM_SIZE))),
80 "address %p not in permanent mappings", virt);
84#
if CONFIG_SRAM_BASE_ADDRESS != 0
85 (addr >= CONFIG_SRAM_BASE_ADDRESS) &&
87#
if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
88 (addr < (CONFIG_SRAM_BASE_ADDRESS +
89 (CONFIG_SRAM_SIZE * 1024UL))),
93 "physical address 0x%lx not in RAM",
101 return Z_MEM_PHYS_ADDR(addr);
105static inline void *z_mem_virt_addr(
uintptr_t phys)
107#if defined(CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK)
109 "physical address 0x%lx not in RAM", (
unsigned long)phys);
112#
if CONFIG_SRAM_BASE_ADDRESS != 0
113 (phys >= CONFIG_SRAM_BASE_ADDRESS) &&
115#
if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
116 (phys < (CONFIG_SRAM_BASE_ADDRESS +
117 (CONFIG_SRAM_SIZE * 1024UL))),
121 "physical address 0x%lx not in RAM", (
unsigned long)phys);
128 return (
void *)Z_MEM_VIRT_ADDR(phys);
206void z_phys_unmap(
uint8_t *virt,
size_t size);
void k_mem_unmap_impl(void *addr, size_t size, bool is_anon)
Un-map mapped memory.
void * k_mem_map_impl(uintptr_t phys, size_t size, uint32_t flags, bool is_anon)
Map memory into virtual address space with guard pages.
bool sys_mm_is_virt_addr_in_range(void *virt)
Check if a virtual address is within range of virtual memory.
bool sys_mm_is_phys_addr_in_range(uintptr_t phys)
Check if a physical address is within range of physical memory.
flags
Definition: parser.h:96
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105