Zephyr API 3.6.99
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
134#define K_MEM_MAP_UNPAGED BIT(18)
135
149size_t k_mem_free_get(void);
150
190static inline void *k_mem_map(size_t size, uint32_t flags)
191{
192 return k_mem_map_phys_guard((uintptr_t)NULL, size, flags, true);
193}
194
195#ifdef CONFIG_DEMAND_MAPPING
236static inline void *k_mem_map_unpaged(uintptr_t location, size_t size, uint32_t flags)
237{
239 return k_mem_map_phys_guard(location, size, flags, false);
240}
241#endif
242
256static inline void k_mem_unmap(void *addr, size_t size)
257{
258 k_mem_unmap_phys_guard(addr, size, true);
259}
260
276int k_mem_update_flags(void *addr, size_t size, uint32_t flags);
277
291size_t k_mem_region_align(uintptr_t *aligned_addr, size_t *aligned_size,
292 uintptr_t addr, size_t size, size_t align);
293
294#ifdef __cplusplus
295}
296#endif
297
300#endif /* !_ASMLANGUAGE */
301#endif /* ZEPHYR_INCLUDE_KERNEL_MM_H */
#define K_MEM_MAP_UNPAGED
Region will be unpaged i.e.
Definition mm.h:134
static void k_mem_unmap(void *addr, size_t size)
Un-map mapped memory.
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:190
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.
int k_mem_update_flags(void *addr, size_t size, uint32_t flags)
Modify memory mapping attribute flags.
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
Misc utilities.
Macros to abstract toolchain specific capabilities.