Changeset 24abb85d in mainline for kernel/generic/src/ddi/irq.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.