7#ifndef ZEPHYR_INCLUDE_KERNEL_INTERNAL_MM_H
8#define ZEPHYR_INCLUDE_KERNEL_INTERNAL_MM_H
41#define K_MEM_VIRT_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \
42 (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET))
44#define K_MEM_VIRT_OFFSET 0
56#define K_MEM_PHYS_ADDR(virt) ((virt) - K_MEM_VIRT_OFFSET)
67#define K_MEM_VIRT_ADDR(phys) ((phys) + K_MEM_VIRT_OFFSET)
69#if K_MEM_VIRT_OFFSET != 0
73#define K_MEM_IS_VM_KERNEL 1
75#error "XIP and a virtual memory kernel are not allowed"
101#if defined(CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK)
103 "address %p not in permanent mappings", virt);
104#elif defined(CONFIG_MMU)
106#
if CONFIG_KERNEL_VM_BASE != 0
107 (addr >= CONFIG_KERNEL_VM_BASE) &&
109#
if (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_SIZE) != 0
110 (addr < (CONFIG_KERNEL_VM_BASE +
111 (CONFIG_KERNEL_VM_SIZE))),
115 "address %p not in permanent mappings", virt);
119#
if CONFIG_SRAM_BASE_ADDRESS != 0
120 (addr >= CONFIG_SRAM_BASE_ADDRESS) &&
122#
if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
123 (addr < (CONFIG_SRAM_BASE_ADDRESS +
124 (CONFIG_SRAM_SIZE * 1024UL))),
128 "physical address 0x%lx not in RAM",
129 (
unsigned long)addr);
152#if defined(CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK)
154 "physical address 0x%lx not in RAM", (
unsigned long)phys);
157#
if CONFIG_SRAM_BASE_ADDRESS != 0
158 (phys >= CONFIG_SRAM_BASE_ADDRESS) &&
160#
if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0
161 (phys < (CONFIG_SRAM_BASE_ADDRESS +
162 (CONFIG_SRAM_SIZE * 1024UL))),
166 "physical address 0x%lx not in RAM", (
unsigned long)phys);
void * k_mem_map_phys_guard(uintptr_t phys, size_t size, uint32_t flags, bool is_anon)
Map memory into virtual address space with guard pages.
#define K_MEM_PHYS_ADDR(virt)
Get physical address from virtual address.
Definition mm.h:56
#define K_MEM_VIRT_ADDR(phys)
Get virtual address from physical address.
Definition mm.h:67
void k_mem_map_phys_bare(uint8_t **virt_ptr, uintptr_t phys, size_t size, uint32_t flags)
Map a physical memory region into the kernel's virtual address space.
void k_mem_unmap_phys_guard(void *addr, size_t size, bool is_anon)
Un-map memory mapped via k_mem_map_phys_guard().
static uintptr_t k_mem_phys_addr(void *virt)
Get physical address from virtual address.
Definition mm.h:97
void k_mem_unmap_phys_bare(uint8_t *virt, size_t size)
Unmap a virtual memory region from kernel's virtual address space.
static void * k_mem_virt_addr(uintptr_t phys)
Get virtual address from physical address.
Definition mm.h:150
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