@@ -54,6 +54,18 @@ extern "C" {
54
54
/** Reserved bits for cache modes */
55
55
#define SYS_MM_MEM_CACHE_MASK (BIT(3) - 1)
56
56
57
+ /**
58
+ * @brief Represents an available memory region.
59
+ *
60
+ * A memory region that can be used by allocators. Driver defined
61
+ * attributes can be used to guide the proper usage of each region.
62
+ */
63
+ struct sys_mm_drv_region {
64
+ void * addr ; /**< @brief Address of the memory region */
65
+ size_t size ; /**< @brief Size of the memory region */
66
+ uint32_t attr ; /**< @brief Driver defined attributes of the memory region */
67
+ };
68
+
57
69
/**
58
70
* @}
59
71
*/
@@ -109,6 +121,18 @@ extern "C" {
109
121
*/
110
122
int sys_mm_drv_map_page (void * virt , uintptr_t phys , uint32_t flags );
111
123
124
+ /**
125
+ * @brief Map one physical page into the virtual address space with region check
126
+ *
127
+ * This maps one physical page into the virtual address space by calling
128
+ * sys_mm_drv_map_page. Refer to sys_mm_drv_map_page for references
129
+ *
130
+ * Before call it performs a safety check by verifying if the mapped virtual memory page
131
+ * fits into a given virtual region
132
+ */
133
+ int sys_mm_drv_map_page_safe (const struct sys_mm_drv_region * virtual_region ,
134
+ void * virt , uintptr_t phys , uint32_t flags );
135
+
112
136
/**
113
137
* @brief Map a region of physical memory into the virtual address space
114
138
*
@@ -133,6 +157,19 @@ int sys_mm_drv_map_page(void *virt, uintptr_t phys, uint32_t flags);
133
157
int sys_mm_drv_map_region (void * virt , uintptr_t phys ,
134
158
size_t size , uint32_t flags );
135
159
160
+ /**
161
+ * @brief Map a region of physical memory into the virtual address space with region check
162
+ *
163
+ * This maps a region of physical memory into the virtual address space by calling
164
+ * sys_mm_drv_map_region. Refer to sys_mm_drv_map_region for references
165
+ *
166
+ * Before call it performs a safety check by verifying if the mapped virtual memory pages
167
+ * fit into a given virtual region
168
+ */
169
+ int sys_mm_drv_map_region_safe (const struct sys_mm_drv_region * virtual_region ,
170
+ void * virt , uintptr_t phys , size_t size ,
171
+ uint32_t flags );
172
+
136
173
/**
137
174
* @brief Map an array of physical memory into the virtual address space
138
175
*
@@ -402,18 +439,6 @@ int sys_mm_drv_update_region_flags(void *virt, size_t size, uint32_t flags);
402
439
*/
403
440
int sys_mm_drv_page_phys_get (void * virt , uintptr_t * phys );
404
441
405
- /**
406
- * @brief Represents an available memory region.
407
- *
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.
410
- */
411
- struct sys_mm_drv_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 */
415
- };
416
-
417
442
/* TODO is it safe to assume no valid region has size == 0? */
418
443
/**
419
444
* @brief Iterates over an array of regions returned by #sys_mm_drv_query_memory_regions
0 commit comments