Changes in kernel/generic/src/ddi/ddi.c [953bc1ef:a422bc5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r953bc1ef ra422bc5 46 46 #include <mm/frame.h> 47 47 #include <mm/as.h> 48 #include <synch/ spinlock.h>48 #include <synch/mutex.h> 49 49 #include <syscall/copy.h> 50 50 #include <adt/btree.h> … … 54 54 55 55 /** This lock protects the parea_btree. */ 56 SPINLOCK_INITIALIZE(parea_lock);56 static mutex_t parea_lock; 57 57 58 58 /** B+tree with enabled physical memory areas. */ … … 63 63 { 64 64 btree_create(&parea_btree); 65 mutex_initialize(&parea_lock, MUTEX_PASSIVE); 65 66 } 66 67 … … 72 73 void ddi_parea_register(parea_t *parea) 73 74 { 74 ipl_t ipl = interrupts_disable(); 75 spinlock_lock(&parea_lock); 75 mutex_lock(&parea_lock); 76 76 77 77 /* … … 80 80 btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL); 81 81 82 spinlock_unlock(&parea_lock); 83 interrupts_restore(ipl); 82 mutex_unlock(&parea_lock); 84 83 } 85 84 … … 141 140 spinlock_unlock(&zones.lock); 142 141 143 spinlock_lock(&parea_lock);142 mutex_lock(&parea_lock); 144 143 btree_node_t *nodep; 145 144 parea_t *parea = (parea_t *) btree_search(&parea_btree, 146 145 (btree_key_t) pf, &nodep); 147 146 148 if ((!parea) || (parea->frames < pages)) 147 if ((!parea) || (parea->frames < pages)) { 148 mutex_unlock(&parea_lock); 149 149 goto err; 150 } 150 151 151 spinlock_unlock(&parea_lock);152 mutex_unlock(&parea_lock); 152 153 goto map; 153 154 } 154 155 156 spinlock_unlock(&zones.lock); 155 157 err: 156 spinlock_unlock(&zones.lock);157 158 interrupts_restore(ipl); 158 159 return ENOENT; 159 160 160 161 map: 161 spinlock_lock(&TASK->lock);162 162 interrupts_restore(ipl); 163 163 164 if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp, 164 165 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { … … 167 168 * We report it using ENOMEM. 168 169 */ 169 spinlock_unlock(&TASK->lock);170 interrupts_restore(ipl);171 170 return ENOMEM; 172 171 } … … 175 174 * Mapping is created on-demand during page fault. 176 175 */ 177 178 spinlock_unlock(&TASK->lock);179 interrupts_restore(ipl);180 176 return 0; 181 177 } … … 287 283 } 288 284 289 /** Disable or enable specified interrupts.290 *291 * @param irq the interrupt to be enabled/disabled.292 * @param enable if true enable the interrupt, disable otherwise.293 *294 * @retutn Zero on success, error code otherwise.295 */296 unative_t sys_interrupt_enable(int irq, int enable)297 {298 cap_t task_cap = cap_get(TASK);299 if (!(task_cap & CAP_PREEMPT_CONTROL) || !(task_cap & CAP_IRQ_REG))300 return EPERM;301 302 if (irq < 0 || irq > 16) {303 return EINVAL;304 }305 306 uint16_t irq_mask = (uint16_t)(1 << irq);307 if (enable) {308 trap_virtual_enable_irqs(irq_mask);309 } else {310 trap_virtual_disable_irqs(irq_mask);311 }312 313 return 0;314 }315 316 285 /** @} 317 286 */
Note:
See TracChangeset
for help on using the changeset viewer.