Changeset ee50130 in mainline
- Timestamp:
- 2017-06-28T19:32:20Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4ae95a
- Parents:
- 39b0a51
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/irq.c
r39b0a51 ree50130 34 34 * @brief IRQ dispatcher. 35 35 * 36 * This file provides means of connecting IRQs with particular 37 * devices and logic for dispatching interrupts to IRQ handlers 38 * defined by those devices. 36 * This file provides means of connecting IRQs with particular devices and logic 37 * for dispatching interrupts to IRQ handlers defined by those devices. 39 38 * 40 39 * This code is designed to support: … … 46 45 * Note about architectures. 47 46 * 48 * Some architectures has the term IRQ well defined. Examples 49 * of such architectures include amd64, ia32 and mips32. Some 50 * other architectures, such as sparc64, don't use the term 51 * at all. In those cases, we boldly step forward and define what 52 * an IRQ is. 53 * 54 * The implementation is generic enough and still allows the 55 * architectures to use the hardware layout effectively. 56 * For instance, on amd64 and ia32, where there is only 16 57 * IRQs, the irq_hash_table can be optimized to a one-dimensional 58 * array. Next, when it is known that the IRQ numbers (aka INR's) 59 * are unique, the claim functions can always return IRQ_ACCEPT. 47 * Some architectures have the term IRQ well defined. Examples of such 48 * architectures include amd64, ia32 and mips32. Some other architectures, such 49 * as sparc64, don't use the term at all. In those cases, we boldly step forward 50 * and define what an IRQ is. 51 * 52 * The implementation is generic enough and still allows the architectures to 53 * use the hardware layout effectively. For instance, on amd64 and ia32, where 54 * there is only 16 IRQs, the irq_hash_table can be optimized to a 55 * one-dimensional array. Next, when it is known that the IRQ numbers (aka 56 * INR's) are unique, the claim functions can always return IRQ_ACCEPT. 60 57 * 61 58 * 62 59 * Note about the irq_hash_table. 63 60 * 64 * The hash table is configured to use two keys: inr and devno. 65 * However, the hash index is computed only from inr. Moreover, 66 * if devno is -1, the match is based on the return value of 67 * the claim() function instead of on devno. 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. 68 64 */ 69 65 … … 102 98 103 99 /** 104 * Hash table operations for cases when we know that 105 * there will be collisions between different keys. 106 * 100 * Hash table operations for cases when we know that there will be collisions 101 * between different keys. 107 102 */ 108 103 static size_t irq_ht_hash(sysarg_t *key); … … 117 112 118 113 /** 119 * Hash table operations for cases when we know that 120 * there will be no collisions between different keys. 121 * However, there might be still collisions among 114 * Hash table operations for cases when we know that there will be no collisions 115 * between different keys. However, there might be still collisions among 122 116 * elements with single key (sharing of one IRQ). 123 *124 117 */ 125 118 static size_t irq_lin_hash(sysarg_t *key); … … 151 144 152 145 /* 153 * Be smart about the choice of the hash table operations. 154 * In cases in which inrs equals the requested number of155 * chains (i.e. where there is no collision between156 * different keys), we can use optimized set ofoperations.146 * Be smart about the choice of the hash table operations. In cases in 147 * which inrs equals the requested number of chains (i.e. where there is 148 * no collision between different keys), we can use optimized set of 149 * operations. 157 150 */ 158 151 if (inrs == chains) { … … 188 181 /** Register IRQ for device. 189 182 * 190 * The irq structure must be filled with information 191 * about the interrupt source and with the claim() 192 * function pointer and handler() function pointer. 183 * The irq structure must be filled with information about the interrupt source 184 * and with the claim() function pointer and handler() function pointer. 193 185 * 194 186 * @param irq IRQ structure belonging to a device. 195 *196 * @return True on success, false on failure.197 187 * 198 188 */ … … 259 249 /** Dispatch the IRQ. 260 250 * 261 * We assume this function is only called from interrupt 262 * context (i.e. that interrupts are disabled prior to 263 * this call). 264 * 265 * This function attempts to lookup a fitting IRQ 266 * structure. In case of success, return with interrupts 267 * disabled and holding the respective structure. 251 * We assume this function is only called from interrupt context (i.e. that 252 * interrupts are disabled prior to this call). 253 * 254 * This function attempts to lookup a fitting IRQ structure. In case of success, 255 * return with interrupts disabled and holding the respective structure. 268 256 * 269 257 * @param inr Interrupt number (aka inr or irq). 270 258 * 271 * @return IRQ structure of the respective device or NULL. 259 * @return IRQ structure of the respective device 260 * @return NULL if no IRQ structure found 272 261 * 273 262 */ … … 275 264 { 276 265 /* 277 * If the kernel console override is on, 278 * then try first the kernel handlers 279 * and eventually fall back to uspace 280 * handlers. 266 * If the kernel console override is on, then try first the kernel 267 * handlers and eventually fall back to uspace handlers. 281 268 * 282 * In the usual case the uspace handlers 283 * have precedence. 269 * In the usual case the uspace handlers have precedence. 284 270 */ 285 271 … … 301 287 /** Compute hash index for the key. 302 288 * 303 * This function computes hash index into 304 * the IRQ hash table for which there 305 * can be collisions between different 306 * INRs. 289 * This function computes hash index into the IRQ hash table for which there can 290 * be collisions between different INRs. 307 291 * 308 292 * The devno is not used to compute the hash. … … 321 305 /** Compare hash table element with a key. 322 306 * 323 * There are two things to note about this function. 324 * First, it is used for the more complex architecture setup 325 * in which there are way too many interrupt numbers (i.e. inr's) 326 * to arrange the hash table so that collisions occur only 327 * among same inrs of different devnos. So the explicit check 328 * for inr match must be done. 329 * Second, if devno is -1, the second key (i.e. devno) is not 330 * used for the match and the result of the claim() function 331 * is used instead. 307 * There are two things to note about this function. First, it is used for the 308 * more complex architecture setup in which there are way too many interrupt 309 * numbers (i.e. inr's) to arrange the hash table so that collisions occur only 310 * among same inrs of different devnos. So the explicit check for inr match must 311 * be done. Second, if devno is -1, the second key (i.e. devno) is not used for 312 * the match and the result of the claim() function is used instead. 332 313 * 333 314 * This function assumes interrupts are already disabled. 334 315 * 335 316 * @param key Keys (i.e. inr and devno). 336 * @param keys This is 2. 317 * @param keys This is 2. 337 318 * @param item The item to compare the key with. 338 319 * 339 * @return True on match or false otherwise. 320 * @return true on match 321 * @return false on no match 340 322 * 341 323 */ … … 378 360 /** Compute hash index for the key. 379 361 * 380 * This function computes hash index into 381 * the IRQ hash table for which there 382 * are no collisions between different 383 * INRs. 362 * This function computes hash index into the IRQ hash table for which there are 363 * no collisions between different INRs. 384 364 * 385 365 * @param key The first of the keys is inr and the second is devno or -1. … … 396 376 /** Compare hash table element with a key. 397 377 * 398 * There are two things to note about this function. 399 * First, it is used for the less complex architecture setup 400 * in which there are not too many interrupt numbers (i.e. inr's) 401 * to arrange the hash table so that collisions occur only 402 * among same inrs of different devnos. So the explicit check 403 * for inr match is not done. 404 * Second, if devno is -1, the second key (i.e. devno) is not 405 * used for the match and the result of the claim() function 406 * is used instead. 378 * There are two things to note about this function. First, it is used for the 379 * less complex architecture setup in which there are not too many interrupt 380 * numbers (i.e. inr's) to arrange the hash table so that collisions occur only 381 * among same inrs of different devnos. So the explicit check for inr match is 382 * not done. Second, if devno is -1, the second key (i.e. devno) is not used 383 * for the match and the result of the claim() function is used instead. 407 384 * 408 385 * This function assumes interrupts are already disabled. 409 386 * 410 387 * @param key Keys (i.e. inr and devno). 411 * @param keys This is 2. 388 * @param keys This is 2. 412 389 * @param item The item to compare the key with. 413 390 * 414 * @return True on match or false otherwise. 391 * @return true on match 392 * @return false on no match 415 393 * 416 394 */
Note:
See TracChangeset
for help on using the changeset viewer.