Changeset 24abb85d in mainline for kernel/generic/src
- Timestamp:
- 2017-08-18T23:27:08Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4d76cfc
- Parents:
- e9d15d9
- Location:
- kernel/generic/src
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
re9d15d9 r24abb85d 55 55 #include <str.h> 56 56 #include <sysinfo/sysinfo.h> 57 #include <ddi/device.h>58 57 #include <symtab.h> 59 58 #include <errno.h> -
kernel/generic/src/ddi/irq.c
re9d15d9 r24abb85d 59 59 * Note about the irq_hash_table. 60 60 * 61 * The hash table is configured to use two keys: inr and devno. However, the 62 * hash index is computed only from inr. Moreover, if devno is -1, the match is 63 * based on the return value of the claim() function instead of on devno. 61 * The hash table is configured to use two keys: inr and mode. However, the 62 * hash index is computed only from inr. Moreover, if mode is IRQ_HT_MODE_CLAIM, 63 * the match is based also on the return value of the claim(). Otherwise the 64 * the keys do not match. 64 65 */ 65 66 … … 73 74 #include <mem.h> 74 75 #include <arch.h> 75 76 #define KEY_INR 077 #define KEY_DEVNO 178 76 79 77 /** Spinlock protecting the kernel IRQ hash table. … … 174 172 link_initialize(&irq->notif_cfg.link); 175 173 irq->inr = -1; 176 irq->devno = -1;177 174 178 175 irq_initialize_arch(irq); … … 190 187 { 191 188 sysarg_t key[] = { 192 (sysarg_t) irq->inr,193 (sysarg_t) irq->devno189 [IRQ_HT_KEY_INR] = (sysarg_t) irq->inr, 190 [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_NO_CLAIM 194 191 }; 195 192 … … 208 205 link_t *lnk; 209 206 sysarg_t key[] = { 210 (sysarg_t) inr,211 (sysarg_t) -1 /* Search will use claim() instead of devno */207 [IRQ_HT_KEY_INR] = (sysarg_t) inr, 208 [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_CLAIM 212 209 }; 213 210 … … 231 228 link_t *lnk; 232 229 sysarg_t key[] = { 233 (sysarg_t) inr,234 (sysarg_t) -1 /* Search will use claim() instead of devno */230 [IRQ_HT_KEY_INR] = (sysarg_t) inr, 231 [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_CLAIM 235 232 }; 236 233 … … 290 287 * be collisions between different INRs. 291 288 * 292 * The devnois not used to compute the hash.293 * 294 * @param key The first of the keys is inr and the second is devno or -1.289 * The mode is not used to compute the hash. 290 * 291 * @param key The first of the keys is inr and the second is mode. 295 292 * 296 293 * @return Index into the hash table. … … 299 296 size_t irq_ht_hash(sysarg_t key[]) 300 297 { 301 inr_t inr = (inr_t) key[ KEY_INR];298 inr_t inr = (inr_t) key[IRQ_HT_KEY_INR]; 302 299 return inr % buckets; 303 300 } … … 308 305 * more complex architecture setup in which there are way too many interrupt 309 306 * numbers (i.e. inr's) to arrange the hash table so that collisions occur only 310 * among same inrs of different dev nos. So the explicit check for inr match must311 * be done. Second, if devno is -1, the second key (i.e. devno) is not used for312 * the match and the result of the claim() function is used instead.307 * among same inrs of different devices. So the explicit check for inr match 308 * must be done. Second, if mode is IRQ_HT_MODE_CLAIM, the result of the 309 * claim() function is used for the match. Otherwise the key does not match. 313 310 * 314 311 * This function assumes interrupts are already disabled. 315 312 * 316 * @param key Keys (i.e. inr and devno).313 * @param key Keys (i.e. inr and mode). 317 314 * @param keys This is 2. 318 315 * @param item The item to compare the key with. … … 325 322 { 326 323 irq_t *irq = hash_table_get_instance(item, irq_t, link); 327 inr_t inr = (inr_t) key[ KEY_INR];328 devno_t devno = (devno_t) key[KEY_DEVNO];324 inr_t inr = (inr_t) key[IRQ_HT_KEY_INR]; 325 irq_ht_mode_t mode = (irq_ht_mode_t) key[IRQ_HT_KEY_MODE]; 329 326 330 327 bool rv; 331 328 332 329 irq_spinlock_lock(&irq->lock, false); 333 if ( devno == -1) {330 if (mode == IRQ_HT_MODE_CLAIM) { 334 331 /* Invoked by irq_dispatch_and_lock(). */ 335 rv = ((irq->inr == inr) && 336 (irq->claim(irq) == IRQ_ACCEPT)); 332 rv = ((irq->inr == inr) && (irq->claim(irq) == IRQ_ACCEPT)); 337 333 } else { 338 334 /* Invoked by irq_find_and_lock(). */ 339 rv = ((irq->inr == inr) && (irq->devno == devno));335 rv = false; 340 336 } 341 337 … … 363 359 * no collisions between different INRs. 364 360 * 365 * @param key The first of the keys is inr and the second is devno or -1.361 * @param key The first of the keys is inr and the second is mode. 366 362 * 367 363 * @return Index into the hash table. … … 370 366 size_t irq_lin_hash(sysarg_t key[]) 371 367 { 372 inr_t inr = (inr_t) key[ KEY_INR];368 inr_t inr = (inr_t) key[IRQ_HT_KEY_INR]; 373 369 return inr; 374 370 } … … 385 381 * This function assumes interrupts are already disabled. 386 382 * 387 * @param key Keys (i.e. inr and devno).383 * @param key Keys (i.e. inr and mode). 388 384 * @param keys This is 2. 389 385 * @param item The item to compare the key with. … … 396 392 { 397 393 irq_t *irq = list_get_instance(item, irq_t, link); 398 devno_t devno = (devno_t) key[KEY_DEVNO];394 irq_ht_mode_t mode = (irq_ht_mode_t) key[IRQ_HT_KEY_MODE]; 399 395 bool rv; 400 396 401 397 irq_spinlock_lock(&irq->lock, false); 402 if ( devno == -1) {398 if (mode == IRQ_HT_MODE_CLAIM) { 403 399 /* Invoked by irq_dispatch_and_lock() */ 404 400 rv = (irq->claim(irq) == IRQ_ACCEPT); 405 401 } else { 406 402 /* Invoked by irq_find_and_lock() */ 407 rv = (irq->devno == devno);403 rv = false; 408 404 } 409 405 -
kernel/generic/src/ipc/irq.c
re9d15d9 r24abb85d 294 294 * @param box Receiving answerbox. 295 295 * @param inr IRQ number. 296 * @param devno Device number.297 296 * @param imethod Interface and method to be associated with the 298 297 * notification. … … 303 302 * 304 303 */ 305 int ipc_irq_subscribe(answerbox_t *box, inr_t inr, devno_t devno,306 sysarg_t imethod,irq_code_t *ucode)304 int ipc_irq_subscribe(answerbox_t *box, inr_t inr, sysarg_t imethod, 305 irq_code_t *ucode) 307 306 { 308 307 sysarg_t key[] = { 309 (sysarg_t) inr,310 (sysarg_t) devno308 [IRQ_HT_KEY_INR] = (sysarg_t) inr, 309 [IRQ_HT_KEY_MODE] = (sysarg_t) IRQ_HT_MODE_NO_CLAIM 311 310 }; 312 311 … … 334 333 irq_t *irq = &kobj->irq; 335 334 irq_initialize(irq); 336 irq->devno = devno;337 335 irq->inr = inr; 338 336 irq->claim = ipc_irq_top_half_claim; … … 349 347 */ 350 348 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); 351 352 link_t *hlp = hash_table_find(&irq_uspace_hash_table, key);353 if (hlp) {354 irq_t *hirq = hash_table_get_instance(hlp, irq_t, link);355 356 /* hirq is locked */357 irq_spinlock_unlock(&hirq->lock, false);358 code_free(code);359 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);360 361 kobject_free(TASK, cap);362 return EEXIST;363 }364 365 /* Locking is not really necessary, but paranoid */366 349 irq_spinlock_lock(&irq->lock, false); 367 350 irq_spinlock_lock(&box->irq_lock, false); -
kernel/generic/src/ipc/sysipc.c
re9d15d9 r24abb85d 801 801 * 802 802 * @param inr IRQ number. 803 * @param devno Device number.804 803 * @param imethod Interface and method to be associated with the notification. 805 804 * @param ucode Uspace pointer to the top-half pseudocode. … … 810 809 * 811 810 */ 812 sysarg_t sys_ipc_irq_subscribe(inr_t inr, devno_t devno, sysarg_t imethod, 813 irq_code_t *ucode) 811 sysarg_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode) 814 812 { 815 813 if (!(perm_get(TASK) & PERM_IRQ_REG)) 816 814 return EPERM; 817 815 818 return ipc_irq_subscribe(&TASK->answerbox, inr, devno,imethod, ucode);816 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode); 819 817 } 820 818 -
kernel/generic/src/syscall/syscall.c
re9d15d9 r24abb85d 45 45 #include <arch.h> 46 46 #include <debug.h> 47 #include <ddi/device.h>48 47 #include <interrupt.h> 49 48 #include <ipc/sysipc.h> … … 175 174 176 175 /* DDI related syscalls. */ 177 [SYS_DEVICE_ASSIGN_DEVNO] = (syshandler_t) sys_device_assign_devno,178 176 [SYS_PHYSMEM_MAP] = (syshandler_t) sys_physmem_map, 179 177 [SYS_PHYSMEM_UNMAP] = (syshandler_t) sys_physmem_unmap,
Note:
See TracChangeset
for help on using the changeset viewer.