pub unsafe extern "C" fn k_mem_map_phys_bare(
virt_ptr: *mut *mut u8,
phys: usize,
size: usize,
flags: u32,
)
Expand description
Map a physical memory region into the kernel’s virtual address space
This function is intended for mapping memory-mapped I/O regions into the virtual address space. Given a physical address and a size, return a linear address representing the base of where the physical region is mapped in the virtual address space for the Zephyr kernel.
The memory mapped via this function must be unmapped using k_mem_unmap_phys_bare().
This function alters the active page tables in the area reserved for the kernel. This function will choose the virtual address and return it to the caller.
Portable code should never assume that phys_addr and linear_addr will be equal.
Caching and access properties are controlled by the ‘flags’ parameter. Unused bits in ‘flags’ are reserved for future expansion. A caching mode must be selected. By default, the region is read-only with user access and code execution forbidden. This policy is changed by passing K_MEM_CACHE_* and K_MEM_PERM_* macros into the ‘flags’ parameter.
If there is insufficient virtual address space for the mapping this will generate a kernel panic.
This API is only available if CONFIG_MMU is enabled.
It is highly discouraged to use this function to map system RAM page frames. It may conflict with anonymous memory mappings and demand paging and produce undefined behavior. Do not use this for RAM unless you know exactly what you are doing. If you need a chunk of memory, use k_mem_map(). If you need a contiguous buffer of physical memory, statically declare it and pin it at build time, it will be mapped when the system boots.
This API is part of infrastructure still under development and may change.
@param[out] virt_ptr Output virtual address storage location @param[in] phys Physical address base of the memory region @param[in] size Size of the memory region @param[in] flags Caching mode and access flags, see K_MAP_* macros