* Sleep until an ithread finishes executing an interrupt handler. * * XXX Doesn't currently handle interrupt filters or fast interrupt * handlers. This is intended for compatibility with linux drivers * only. Do not use in BSD code. */
| 787 | * only. Do not use in BSD code. |
| 788 | */ |
| 789 | void |
| 790 | _intr_drain(int irq) |
| 791 | { |
| 792 | struct intr_event *ie; |
| 793 | struct intr_thread *ithd; |
| 794 | struct thread *td; |
| 795 | |
| 796 | ie = intr_lookup(irq); |
| 797 | if (ie == NULL) |
| 798 | return; |
| 799 | if (ie->ie_thread == NULL) |
| 800 | return; |
| 801 | ithd = ie->ie_thread; |
| 802 | td = ithd->it_thread; |
| 803 | /* |
| 804 | * We set the flag and wait for it to be cleared to avoid |
| 805 | * long delays with potentially busy interrupt handlers |
| 806 | * were we to only sample TD_AWAITING_INTR() every tick. |
| 807 | */ |
| 808 | thread_lock(td); |
| 809 | if (!TD_AWAITING_INTR(td)) { |
| 810 | ithd->it_flags |= IT_WAIT; |
| 811 | while (ithd->it_flags & IT_WAIT) { |
| 812 | thread_unlock(td); |
| 813 | pause("idrain", 1); |
| 814 | thread_lock(td); |
| 815 | } |
| 816 | } |
| 817 | thread_unlock(td); |
| 818 | return; |
| 819 | } |
| 820 | |
| 821 | int |
| 822 | intr_event_remove_handler(void *cookie) |
nothing calls this directly
no test coverage detected