Changes in kernel/generic/src/ddi/ddi.c [473d5d2:c0699467] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r473d5d2 rc0699467 41 41 42 42 #include <ddi/ddi.h> 43 #include <ddi/ddi_arg.h>44 43 #include <proc/task.h> 45 44 #include <security/cap.h> … … 122 121 backend_data.frames = pages; 123 122 124 /* Find the zone of the physical memory */ 123 /* 124 * Check if the memory region is explicitly enabled 125 * for mapping by any parea structure. 126 */ 127 128 mutex_lock(&parea_lock); 129 btree_node_t *nodep; 130 parea_t *parea = (parea_t *) btree_search(&parea_btree, 131 (btree_key_t) pf, &nodep); 132 133 if ((parea != NULL) && (parea->frames >= pages)) { 134 if ((!priv) && (!parea->unpriv)) { 135 mutex_unlock(&parea_lock); 136 return EPERM; 137 } 138 139 goto map; 140 } 141 142 parea = NULL; 143 mutex_unlock(&parea_lock); 144 145 /* 146 * Check if the memory region is part of physical 147 * memory generally enabled for mapping. 148 */ 149 125 150 irq_spinlock_lock(&zones.lock, true); 126 151 size_t znum = find_zone(ADDR2PFN(pf), pages, 0); … … 153 178 } 154 179 155 if (zone_flags_available(zones.info[znum].flags)) {156 /*157 * Frames are part of physical memory, check158 * if the memory region is enabled for mapping.159 */160 irq_spinlock_unlock(&zones.lock, true);161 162 mutex_lock(&parea_lock);163 btree_node_t *nodep;164 parea_t *parea = (parea_t *) btree_search(&parea_btree,165 (btree_key_t) pf, &nodep);166 167 if ((!parea) || (parea->frames < pages)) {168 mutex_unlock(&parea_lock);169 return ENOENT;170 }171 172 if (!priv) {173 if (!parea->unpriv) {174 mutex_unlock(&parea_lock);175 return EPERM;176 }177 }178 179 mutex_unlock(&parea_lock);180 goto map;181 }182 183 180 irq_spinlock_unlock(&zones.lock, true); 184 181 return ENOENT; … … 188 185 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { 189 186 /* 190 * The address space area could not have beencreated.187 * The address space area was not created. 191 188 * We report it using ENOMEM. 192 189 */ 190 191 if (parea != NULL) 192 mutex_unlock(&parea_lock); 193 193 194 return ENOMEM; 194 195 } … … 197 198 * Mapping is created on-demand during page fault. 198 199 */ 199 return 0; 200 201 if (parea != NULL) { 202 parea->mapped = true; 203 mutex_unlock(&parea_lock); 204 } 205 206 return EOK; 200 207 } 201 208
Note:
See TracChangeset
for help on using the changeset viewer.