Changeset a5d0143 in mainline
- Timestamp:
- 2017-09-03T19:45:52Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 30c27e9
- Parents:
- 3422fb6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/irq.c
r3422fb6 ra5d0143 37 37 * 38 38 * This framework allows applications to subscribe to receive a notification 39 * when interrupt is detected. The application may provide a simple 'top-half' 40 * handler as part of its registration, which can perform simple operations 41 * (read/write port/memory, add information to notification IPC message). 39 * when an interrupt is detected. The application may provide a simple 40 * 'top-half' handler as part of its registration, which can perform simple 41 * operations (read/write port/memory, add information to notification IPC 42 * message). 42 43 * 43 44 * The structure of a notification message is as follows: … … 50 51 * - in_phone_hash: interrupt counter (may be needed to assure correct order 51 52 * in multithreaded drivers) 52 *53 * Note on synchronization for ipc_irq_subscribe(), ipc_irq_unsubscribe(),54 * ipc_irq_cleanup() and IRQ handlers:55 *56 * By always taking all of the uspace IRQ hash table lock, IRQ structure lock57 * and answerbox lock, we can rule out race conditions between the58 * registration functions and also the cleanup function. Thus the observer can59 * either see the IRQ structure present in both the hash table and the60 * answerbox list or absent in both. Views in which the IRQ structure would be61 * linked in the hash table but not in the answerbox list, or vice versa, are62 * not possible.63 *64 * By always taking the hash table lock and the IRQ structure lock, we can65 * rule out a scenario in which we would free up an IRQ structure, which is66 * still referenced by, for example, an IRQ handler. The locking scheme forces67 * us to lock the IRQ structure only after any progressing IRQs on that68 * structure are finished. Because we hold the hash table lock, we prevent new69 * IRQs from taking new references to the IRQ structure.70 *71 53 */ 72 54 … … 119 101 } 120 102 121 /* Rewrite the pseudocode addresses from physical to kernel virtual. */103 /* Rewrite the IRQ code addresses from physical to kernel virtual. */ 122 104 for (size_t i = 0; i < cmdcount; i++) { 123 105 uintptr_t addr; … … 177 159 } 178 160 179 /** Statically check the top-half pseudocode 180 * 181 * Check the top-half pseudocode for invalid or unsafe 182 * constructs. 161 /** Statically check the top-half IRQ code 162 * 163 * Check the top-half IRQ code for invalid or unsafe constructs. 183 164 * 184 165 */ … … 217 198 } 218 199 219 /** Free the top-half pseudocode.220 * 221 * @param code Pointer to the top-half pseudocode.200 /** Free the top-half IRQ code. 201 * 202 * @param code Pointer to the top-half IRQ code. 222 203 * 223 204 */ … … 232 213 } 233 214 234 /** Copy the top-half pseudocode from userspace into the kernel.235 * 236 * @param ucode Userspace address of the top-half pseudocode.237 * 238 * @return Kernel address of the copied pseudocode.215 /** Copy the top-half IRQ code from userspace into the kernel. 216 * 217 * @param ucode Userspace address of the top-half IRQ code. 218 * 219 * @return Kernel address of the copied IRQ code. 239 220 * 240 221 */ … … 294 275 * @param box Receiving answerbox. 295 276 * @param inr IRQ number. 296 * @param imethod Interface and method to be associated with the 297 * notification. 298 * @param ucode Uspace pointer to top-half pseudocode. 277 * @param imethod Interface and method to be associated with the notification. 278 * @param ucode Uspace pointer to top-half IRQ code. 299 279 * 300 280 * @return IRQ capability handle. … … 342 322 343 323 /* 344 * Enlist the IRQ structure in the uspace IRQ hash table and the 345 * answerbox's list and make the IRQ capability valid. 324 * Insert the IRQ structure into the uspace IRQ hash table and retype 325 * the capability. By retyping the capability inside the critical 326 * section, we make sure another thread cannot attempt to unregister the 327 * IRQ before it is inserted into the hash table. 346 328 */ 347 329 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); … … 373 355 return ENOENT; 374 356 } 357 /* Make sure only one thread can win the race to unsubscribe. */ 375 358 cap->type = CAP_TYPE_ALLOCATED; 376 359 irq_spinlock_unlock(&TASK->lock, true); … … 389 372 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 390 373 391 /* Free up the pseudocode and associated structures. */374 /* Free up the IRQ code and associated structures. */ 392 375 code_free(irq->notif_cfg.code); 393 376 … … 415 398 } 416 399 417 /** Apply the top-half pseudocode to find out whether to accept the IRQ or not.400 /** Apply the top-half IRQ code to find out whether to accept the IRQ or not. 418 401 * 419 402 * @param irq IRQ structure. 420 403 * 421 * @return IRQ_ACCEPT if the interrupt is accepted by the 422 * pseudocode, IRQ_DECLINE otherwise.404 * @return IRQ_ACCEPT if the interrupt is accepted by the IRQ code. 405 * @return IRQ_DECLINE if the interrupt is not accepted byt the IRQ code. 423 406 * 424 407 */
Note:
See TracChangeset
for help on using the changeset viewer.