Lines Matching +full:memory +full:- +full:to +full:- +full:memory
4 * SPDX-License-Identifier: Apache-2.0
9 * @brief Memory Management Driver APIs
11 * This contains APIs for a system-wide memory management
27 * @brief Memory Management Driver APIs
28 * @defgroup mm_drv_apis Memory Management Driver APIs
30 * This contains APIs for a system-wide memory management
48 /** Write-through caching */
51 /** Full write-back caching */
55 #define SYS_MM_MEM_CACHE_MASK (BIT(3) - 1)
64 * Default should be read-only, no user, no exec.
69 /** Region will have read/write access (and not read-only) */
75 /** Region will be accessible to user mode (normally supervisor-only) */
83 * @name Memory Mapping and Unmapping
85 * On mapping and unmapping of memory.
95 * is assumed to be page aligned.
97 * The memory range itself is never accessed by this operation.
99 * This API must be safe to call in ISRs or exception handlers. Calls
100 * to this API are assumed to be serialized.
102 * @param virt Page-aligned destination virtual address to map
103 * @param phys Page-aligned source physical address to map
107 * @retval -EINVAL if invalid arguments are provided
108 * @retval -EFAULT if virtual address has already been mapped
113 * @brief Map a region of physical memory into the virtual address space
115 * This maps a region of physical memory into the virtual address space.
117 * are assumed to be page aligned.
119 * The memory range itself is never accessed by this operation.
121 * This API must be safe to call in ISRs or exception handlers. Calls
122 * to this API are assumed to be serialized.
124 * @param virt Page-aligned destination virtual address to map
125 * @param phys Page-aligned source physical address to map
126 * @param size Page-aligned size of the mapped memory region in bytes
130 * @retval -EINVAL if invalid arguments are provided
131 * @retval -EFAULT if any virtual addresses have already been mapped
137 * @brief Map an array of physical memory into the virtual address space
141 * are assumed to be page aligned.
143 * The physical memory pages are never accessed by this operation.
145 * This API must be safe to call in ISRs or exception handlers. Calls
146 * to this API are assumed to be serialized.
148 * @param virt Page-aligned destination virtual address to map
149 * @param phys Array of pge-aligned source physical address to map
154 * @retval -EINVAL if invalid arguments are provided
155 * @retval -EFAULT if any virtual addresses have already been mapped
166 * updated as if no mapping was ever made for that memory page. No previous
167 * context needs to be preserved. This function must update mapping in
171 * is assumed to be page aligned.
175 * @param virt Page-aligned virtual address to un-map
178 * @retval -EINVAL if invalid arguments are provided
179 * @retval -EFAULT if virtual address is not mapped
189 * updated as if no mapping was ever made for that memory range. No previous
190 * context needs to be preserved. This function must update mappings in
194 * is assumed to be page aligned.
198 * @param virt Page-aligned base virtual address to un-map
199 * @param size Page-aligned region size
202 * @retval -EINVAL if invalid arguments are provided
203 * @retval -EFAULT if virtual address is not mapped
210 * This remaps a virtual memory region starting at @p virt_old
211 * of size @p size into a new virtual memory region starting at
212 * @p virt_new. In other words, physical memory at @p virt_old is
213 * remapped to appear at @p virt_new. Both addresses must be page
216 * Note that the virtual memory at both the old and new addresses
217 * must be unmapped in the memory domains of any runnable Zephyr
218 * thread as this does not deal with memory domains.
220 * Note that overlapping of old and new virtual memory regions
221 * is usually not supported for simpler implementation. Refer to
222 * the actual driver to make sure if overlapping is allowed.
224 * @param virt_old Page-aligned base virtual address of existing memory
225 * @param size Page-aligned size of the mapped memory region in bytes
226 * @param virt_new Page-aligned base virtual address to which to remap
227 * the memory
230 * @retval -EINVAL if invalid arguments are provided
231 * @retval -EFAULT if old virtual addresses are not all mapped or
241 * @name Memory Moving
243 * On moving already mapped memory.
249 * @brief Physically move memory, with copy
251 * This maps a region of physical memory into the new virtual address space
253 * address space (@p virt_old). The new virtual memory region is mapped
254 * from physical memory starting at @p phys_new of size @p size.
257 * are assumed to be page aligned.
259 * Note that the virtual memory at both the old and new addresses
260 * must be unmapped in the memory domains of any runnable Zephyr
261 * thread as this does not deal with memory domains.
263 * Note that overlapping of old and new virtual memory regions
264 * is usually not supported for simpler implementation. Refer to
265 * the actual driver to make sure if overlapping is allowed.
267 * @param virt_old Page-aligned base virtual address of existing memory
268 * @param size Page-aligned size of the mapped memory region in bytes
269 * @param virt_new Page-aligned base virtual address to which to map
271 * @param phys_new Page-aligned base physical address to contain
272 * the moved memory
275 * @retval -EINVAL if invalid arguments are provided
276 * @retval -EFAULT if old virtual addresses are not all mapped or
283 * @brief Physically move memory, with copy
285 * This maps a region of physical memory into the new virtual address space
287 * address space (@p virt_old). The new virtual memory region is mapped
291 * are assumed to be page aligned.
293 * Note that the virtual memory at both the old and new addresses
294 * must be unmapped in the memory domains of any runnable Zephyr
295 * thread as this does not deal with memory domains.
297 * Note that overlapping of old and new virtual memory regions
298 * is usually not supported for simpler implementation. Refer to
299 * the actual driver to make sure if overlapping is allowed.
301 * @param virt_old Page-aligned base virtual address of existing memory
302 * @param size Page-aligned size of the mapped memory region in bytes
303 * @param virt_new Page-aligned base virtual address to which to map
305 * @param phys_new Array of page-aligned physical address to contain
306 * the moved memory
310 * @retval -EINVAL if invalid arguments are provided
311 * @retval -EFAULT if old virtual addresses are not all mapped or
322 * @name Memory Mapping Attributes
324 * On manipulating attributes of already mapped memory.
330 * @brief Update memory page flags
332 * This changes the attributes of physical memory page which is already
333 * mapped to a virtual address. This is useful when use case of
334 * specific memory region changes.
335 * E.g. when the library/module code is copied to the memory then
336 * it needs to be read-write and after it has already
337 * been copied and library/module code is ready to be executed then
338 * attributes need to be changed to read-only/executable.
339 * Calling this API must not cause losing memory contents.
341 * @param virt Page-aligned virtual address to be updated
345 * @retval -EINVAL if invalid arguments are provided
346 * @retval -EFAULT if virtual addresses is not mapped
352 * @brief Update memory region flags
354 * This changes the attributes of physical memory which is already
355 * mapped to a virtual address. This is useful when use case of
356 * specific memory region changes.
357 * E.g. when the library/module code is copied to the memory then
358 * it needs to be read-write and after it has already
359 * been copied and library/module code is ready to be executed then
360 * attributes need to be changed to read-only/executable.
361 * Calling this API must not cause losing memory contents.
363 * @param virt Page-aligned virtual address to be updated
364 * @param size Page-aligned size of the mapped memory region in bytes
368 * @retval -EINVAL if invalid arguments are provided
369 * @retval -EFAULT if virtual addresses is not mapped
379 * @name Memory Mappings Query
381 * On querying information on memory mappings.
387 * @brief Get the mapped physical memory address from virtual address.
389 * The function queries the translation tables to find the physical
390 * memory address of a mapped virtual address.
393 * is assumed to be page aligned.
395 * @param virt Page-aligned virtual address
400 * @retval -EINVAL if invalid arguments are provided
401 * @retval -EFAULT if virtual address is not mapped
406 * @brief Represents an available memory region.
408 * A memory region that can be used by allocators. Driver defined
409 * attributes can be used to guide the proper usage of each region.
412 void *addr; /**< @brief Address of the memory region */
413 size_t size; /**< @brief Size of the memory region */
414 uint32_t attr; /**< @brief Driver defined attributes of the memory region */
417 /* TODO is it safe to assume no valid region has size == 0? */
422 * this macro to work.
425 for (iter = regions; iter->size; iter++)
428 * @brief Query available memory regions
430 * Returns an array of available memory regions. One can iterate over
435 * @retval regions A possibly empty array - i.e. containing only the sentinel
436 * marking at the end - of memory regions.
441 * @brief Free the memory array returned by #sys_mm_drv_query_memory_regions
443 * The driver may have dynamically allocated the memory for the array of
445 * it the opportunity to free any related resources.