In the read/write irq scheme, a program may open multiple irq devices. When wrting (acking), we need to find the user_intr_t that both points to the device port and has the correct interrupt. Thus the search_intr function need to match the interrupt id. For the device_intr_ack method, the id passed to search_intr will be -1.
--- device/intr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/device/intr.c b/device/intr.c index ba86bc2d..359384c7 100644 --- a/device/intr.c +++ b/device/intr.c @@ -41,13 +41,13 @@ extern void free_irq (unsigned int irq, void *dev_id); } static user_intr_t * -search_intr (struct irqdev *dev, ipc_port_t dst_port) +search_intr (struct irqdev *dev, int id, ipc_port_t dst_port) { user_intr_t *e; simple_lock(&dev->lock); queue_iterate (&dev->intr_queue, e, user_intr_t *, chain) { - if (e->dst_port == dst_port) + if (e->dst_port == dst_port && (id == -1 || e->id == id)) { simple_unlock(&dev->lock); return e; @@ -64,7 +64,7 @@ irq_acknowledge (ipc_port_t receive_port) kern_return_t ret = 0; spl_t s = splhigh (); - e = search_intr (&irqtab, receive_port); + e = search_intr (&irqtab, -1, receive_port); if (!e) printf("didn't find user intr for interrupt !?\n"); @@ -118,7 +118,7 @@ insert_intr_entry (struct irqdev *dev, int id, ipc_port_t dst_port) /* check whether the intr entry has been in the queue. */ spl_t s = splhigh (); - e = search_intr (dev, dst_port); + e = search_intr (dev, id, dst_port); if (e) { printf ("the interrupt entry for irq[%d] and port %p has already been inserted\n", id, dst_port); -- 2.28.0.rc1