Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mm.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_KERNEL_MM_H
8#define ZEPHYR_INCLUDE_KERNEL_MM_H
9
10#include <zephyr/sys/util.h>
11#include <zephyr/toolchain.h>
12#if defined(CONFIG_ARM_MMU) && defined(CONFIG_ARM64)
14#endif /* CONFIG_ARM_MMU && CONFIG_ARM64 */
15
17
34#define K_MEM_CACHE_NONE 2
35
37#define K_MEM_CACHE_WT 1
38
40#define K_MEM_CACHE_WB 0
41
42/*
43 * ARM64 Specific flags are defined in arch/arm64/arm_mem.h,
44 * pay attention to be not conflicted when updating these flags.
45 */
46
48#define K_MEM_CACHE_MASK (BIT(3) - 1)
49
61#define K_MEM_PERM_RW BIT(3)
62
64#define K_MEM_PERM_EXEC BIT(4)
65
67#define K_MEM_PERM_USER BIT(5)
68
78#define K_MEM_DIRECT_MAP BIT(6)
79
82#ifndef _ASMLANGUAGE
83#include <stdint.h>
84#include <stddef.h>
85#include <inttypes.h>
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90
106#define K_MEM_MAP_UNINIT BIT(16)
107
115#define K_MEM_MAP_LOCK BIT(17)
116
130size_t k_mem_free_get(void);
131
171static inline void *k_mem_map(size_t size, uint32_t flags)
172{
173 return k_mem_map_impl((uintptr_t)NULL, size, flags, true);
174}
175
215static inline void *k_mem_phys_map(uintptr_t phys, size_t size, uint32_t flags)
216{
217 return k_mem_map_impl(phys, size, flags, false);
218}
219
233static inline void k_mem_unmap(void *addr, size_t size)
234{
235 k_mem_unmap_impl(addr, size, true);
236}
237
256static inline void k_mem_phys_unmap(void *addr, size_t size)
257{
258 k_mem_unmap_impl(addr, size, false);
259}
260
274size_t k_mem_region_align(uintptr_t *aligned_addr, size_t *aligned_size,
275 uintptr_t addr, size_t size, size_t align);
276
277#ifdef __cplusplus
278}
279#endif
280
283#endif /* !_ASMLANGUAGE */
284#endif /* ZEPHYR_INCLUDE_KERNEL_MM_H */
static void k_mem_unmap(void *addr, size_t size)
Un-map mapped memory.
Definition: mm.h:233
static void k_mem_phys_unmap(void *addr, size_t size)
Un-map memory mapped via k_mem_phys_map().
Definition: mm.h:256
size_t k_mem_free_get(void)
Return the amount of free memory available.
static void * k_mem_map(size_t size, uint32_t flags)
Map anonymous memory into Zephyr's address space.
Definition: mm.h:171
size_t k_mem_region_align(uintptr_t *aligned_addr, size_t *aligned_size, uintptr_t addr, size_t size, size_t align)
Given an arbitrary region, provide a aligned region that covers it.
static void * k_mem_phys_map(uintptr_t phys, size_t size, uint32_t flags)
Map a physical memory region into kernel's virtual address space with guard pages.
Definition: mm.h:215
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.
flags
Definition: parser.h:96
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
Macros to abstract toolchain specific capabilities.
Misc utilities.