Zephyr API Documentation  3.7.0-rc1
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_phys_guard((uintptr_t)NULL, size, flags, true);
174}
175
189static inline void k_mem_unmap(void *addr, size_t size)
190{
191 k_mem_unmap_phys_guard(addr, size, true);
192}
193
207size_t k_mem_region_align(uintptr_t *aligned_addr, size_t *aligned_size,
208 uintptr_t addr, size_t size, size_t align);
209
210#ifdef __cplusplus
211}
212#endif
213
216#endif /* !_ASMLANGUAGE */
217#endif /* ZEPHYR_INCLUDE_KERNEL_MM_H */
static void k_mem_unmap(void *addr, size_t size)
Un-map mapped memory.
Definition: mm.h:189
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.
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.
void k_mem_unmap_phys_guard(void *addr, size_t size, bool is_anon)
Un-map memory mapped via k_mem_map_phys_guard().
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.