Changeset 6f7071b in mainline
- Timestamp:
- 2018-11-05T09:13:04Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4a8d0dd1
- Parents:
- 9c26ef0
- git-author:
- Jiri Svoboda <jiri@…> (2018-10-04 18:11:52)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-11-05 09:13:04)
- Location:
- kernel
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/drivers/niagara.c
r9c26ef0 r6f7071b 221 221 INPUT_BUFFER_SIZE); 222 222 223 ddi_parea_init(&outbuf_parea); 223 224 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); 224 225 outbuf_parea.frames = 1; -
kernel/genarch/src/drivers/dsrln/dsrlnout.c
r9c26ef0 r6f7071b 84 84 85 85 instance->base = base; 86 link_initialize(&instance->parea.link);86 ddi_parea_init(&instance->parea); 87 87 instance->parea.pbase = KA2PA(base); 88 88 instance->parea.frames = 1; -
kernel/genarch/src/drivers/ega/ega.c
r9c26ef0 r6f7071b 616 616 } 617 617 618 link_initialize(&instance->parea.link);618 ddi_parea_init(&instance->parea); 619 619 instance->parea.pbase = addr; 620 620 instance->parea.frames = SIZE2FRAMES(EGA_VRAM_SIZE); -
kernel/genarch/src/drivers/ns16550/ns16550.c
r9c26ef0 r6f7071b 175 175 instance->irq.cir_arg = cir_arg; 176 176 177 ddi_parea_init(&instance->parea); 177 178 instance->parea.pbase = (uintptr_t) dev; 178 179 instance->parea.frames = 1; -
kernel/genarch/src/drivers/s3c24xx/uart.c
r9c26ef0 r6f7071b 135 135 pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL); 136 136 137 link_initialize(&uart->parea.link);137 ddi_parea_init(&uart->parea); 138 138 uart->parea.pbase = paddr; 139 139 uart->parea.frames = 1; -
kernel/genarch/src/fb/fb.c
r9c26ef0 r6f7071b 647 647 glyphs_render(instance); 648 648 649 link_initialize(&instance->parea.link);649 ddi_parea_init(&instance->parea); 650 650 instance->parea.pbase = props->addr; 651 651 instance->parea.frames = SIZE2FRAMES(fbsize); -
kernel/generic/include/ddi/ddi.h
r9c26ef0 r6f7071b 39 39 #include <abi/ddi/arg.h> 40 40 #include <proc/task.h> 41 #include <adt/ list.h>41 #include <adt/odict.h> 42 42 43 43 /** Structure representing contiguous physical memory area. */ 44 44 typedef struct { 45 /** Link ed list link*/46 link_t link;45 /** Link to @c pareas ordered dictionary */ 46 odlink_t lpareas; 47 47 48 48 /** Physical base of the area. */ … … 57 57 58 58 extern void ddi_init(void); 59 extern void ddi_parea_init(parea_t *); 59 60 extern void ddi_parea_register(parea_t *); 60 61 -
kernel/generic/include/proc/task.h
r9c26ef0 r6f7071b 44 44 #include <synch/futex.h> 45 45 #include <synch/workqueue.h> 46 #include <adt/btree.h>47 46 #include <adt/cht.h> 48 47 #include <adt/list.h> -
kernel/generic/src/console/console.c
r9c26ef0 r6f7071b 193 193 assert((uintptr_t) faddr % FRAME_SIZE == 0); 194 194 195 ddi_parea_init(&kio_parea); 195 196 kio_parea.pbase = (uintptr_t) faddr; 196 197 kio_parea.frames = SIZE2FRAMES(sizeof(kio)); -
kernel/generic/src/ddi/ddi.c
r9c26ef0 r6f7071b 49 49 #include <synch/mutex.h> 50 50 #include <syscall/copy.h> 51 #include <adt/ btree.h>51 #include <adt/odict.h> 52 52 #include <arch.h> 53 53 #include <align.h> 54 54 #include <errno.h> 55 #include <mem.h> 55 56 #include <trace.h> 56 57 #include <bitops.h> 57 58 58 /** This lock protects the parea_btree. */ 59 static mutex_t parea_lock; 60 61 /** B+tree with enabled physical memory areas. */ 62 static btree_t parea_btree; 59 /** This lock protects the @c pareas ordered dictionary. */ 60 static mutex_t pareas_lock; 61 62 /** Ordered dictionary of enabled physical memory areas by base address. */ 63 static odict_t pareas; 64 65 static void *pareas_getkey(odlink_t *); 66 static int pareas_cmp(void *, void *); 63 67 64 68 /** Initialize DDI. … … 67 71 void ddi_init(void) 68 72 { 69 btree_create(&parea_btree); 70 mutex_initialize(&parea_lock, MUTEX_PASSIVE); 73 odict_initialize(&pareas, pareas_getkey, pareas_cmp); 74 mutex_initialize(&pareas_lock, MUTEX_PASSIVE); 75 } 76 77 /** Initialize physical area structure. 78 * 79 * This should always be called first on the parea structure before 80 * filling in fields and calling ddi_parea_register. 81 * 82 * @param parea Pointer to physical area structure. 83 * 84 */ 85 void ddi_parea_init(parea_t *parea) 86 { 87 memset(parea, 0, sizeof(parea_t)); 71 88 } 72 89 … … 78 95 void ddi_parea_register(parea_t *parea) 79 96 { 80 mutex_lock(&parea _lock);97 mutex_lock(&pareas_lock); 81 98 82 99 /* 83 100 * We don't check for overlaps here as the kernel is pretty sane. 84 101 */ 85 btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL);86 87 mutex_unlock(&parea _lock);102 odict_insert(&parea->lpareas, &pareas, NULL); 103 104 mutex_unlock(&pareas_lock); 88 105 } 89 106 … … 129 146 */ 130 147 131 mutex_lock(&parea _lock);132 btree_node_t *nodep;133 parea_t *parea = (parea_t *) btree_search(&parea_btree,134 (btree_key_t) phys, &nodep);148 mutex_lock(&pareas_lock); 149 odlink_t *odlink = odict_find_eq(&pareas, &phys, NULL); 150 parea_t *parea = odlink != NULL ? 151 odict_get_instance(odlink, parea_t, lpareas) : NULL; 135 152 136 153 if ((parea != NULL) && (parea->frames >= pages)) { 137 154 if ((!priv) && (!parea->unpriv)) { 138 mutex_unlock(&parea _lock);155 mutex_unlock(&pareas_lock); 139 156 return EPERM; 140 157 } … … 144 161 145 162 parea = NULL; 146 mutex_unlock(&parea _lock);163 mutex_unlock(&pareas_lock); 147 164 148 165 /* … … 193 210 194 211 if (parea != NULL) 195 mutex_unlock(&parea _lock);212 mutex_unlock(&pareas_lock); 196 213 197 214 return ENOMEM; … … 204 221 if (parea != NULL) { 205 222 parea->mapped = true; 206 mutex_unlock(&parea _lock);223 mutex_unlock(&pareas_lock); 207 224 } 208 225 … … 255 272 } 256 273 274 /** Get key function for the @c pareas ordered dictionary. 275 * 276 * @param odlink Link 277 * @return Pointer to base address cast as 'void *' 278 */ 279 static void *pareas_getkey(odlink_t *odlink) 280 { 281 parea_t *parea = odict_get_instance(odlink, parea_t, lpareas); 282 return (void *) &parea->pbase; 283 } 284 285 /** Key comparison function for the @c pareas ordered dictionary. 286 * 287 * @param a Pointer to parea A base 288 * @param b Pointer to parea B base 289 * @return -1, 0, 1 iff base of A is less than, equal to, greater than B 290 */ 291 static int pareas_cmp(void *a, void *b) 292 { 293 uintptr_t pa = *(uintptr_t *)a; 294 uintptr_t pb = *(uintptr_t *)b; 295 296 if (pa < pb) 297 return -1; 298 else if (pa == pb) 299 return 0; 300 else 301 return +1; 302 } 303 257 304 /** Enable range of I/O space for task. 258 305 * … … 288 335 } 289 336 290 /* Lock the task and release the lock protecting tasks _btree. */337 /* Lock the task and release the lock protecting tasks dictionary. */ 291 338 irq_spinlock_exchange(&tasks_lock, &task->lock); 292 339 errno_t rc = ddi_iospace_enable_arch(task, ioaddr, size); … … 329 376 } 330 377 331 /* Lock the task and release the lock protecting tasks _btree. */378 /* Lock the task and release the lock protecting tasks dictionary. */ 332 379 irq_spinlock_exchange(&tasks_lock, &task->lock); 333 380 errno_t rc = ddi_iospace_disable_arch(task, ioaddr, size); -
kernel/generic/src/lib/rd.c
r9c26ef0 r6f7071b 59 59 assert((base % FRAME_SIZE) == 0); 60 60 61 ddi_parea_init(&rd_parea); 61 62 rd_parea.pbase = base; 62 63 rd_parea.frames = SIZE2FRAMES(size); -
kernel/generic/src/proc/task.c
r9c26ef0 r6f7071b 48 48 #include <arch.h> 49 49 #include <barrier.h> 50 #include <adt/btree.h>51 50 #include <adt/list.h> 52 51 #include <adt/odict.h> -
kernel/generic/src/time/clock.c
r9c26ef0 r6f7071b 91 91 uptime->useconds = 0; 92 92 93 ddi_parea_init(&clock_parea); 93 94 clock_parea.pbase = faddr; 94 95 clock_parea.frames = 1;
Note:
See TracChangeset
for help on using the changeset viewer.