From 7ae251bd9cdc26e03eb3300ace23209bc50493e6 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Sat, 27 Feb 2016 23:49:57 +0100 Subject: Drop new notification, the old one is fine and turned out to be extensible --- device/intr.c | 116 +++++----------------------------------------------------- 1 file changed, 9 insertions(+), 107 deletions(-) (limited to 'device/intr.c') diff --git a/device/intr.c b/device/intr.c index 5033d93..20a888c 100644 --- a/device/intr.c +++ b/device/intr.c @@ -36,7 +36,6 @@ struct intr_entry ipc_port_t port; /* We receive notifications on this port. */ queue_chain_t chain; ipc_port_t dest; - int new_style; /* version2 notifications?. */ int line; /* The number of interrupts occur since last run of intr_thread. */ int interrupts; @@ -65,7 +64,6 @@ queue_intr (struct intr_entry *e) kern_return_t insert_intr_entry (int line, ipc_port_t dest, - int new_style, /* version2 notifications? */ struct intr_entry **entry) { kern_return_t err = 0; @@ -92,7 +90,6 @@ insert_intr_entry (int line, new->line = line; new->dest = dest; - new->new_style = new_style; new->interrupts = 0; /* Register a dead-name notification so that we are notified if the @@ -209,6 +206,7 @@ intr_entry_notify (mach_msg_header_t *msg) ipc_port_release_send (entry->dest); kmem_cache_free (&intr_entry_cache, (vm_offset_t) entry); + /* XXX cancel no-senders notification here */ printf ("irq handler %d: userspace handler died\n", line); return TRUE; } @@ -225,7 +223,7 @@ static void init_mach_intr_notification (mach_intr_notification_t *n) { mach_msg_header_t *m = &n->intr_header; - mach_msg_type_t *t = &n->intr_type; + mach_msg_type_t *t = &n->line_type; m->msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_PORT_SEND, MACH_MSG_TYPE_PORT_SEND); @@ -282,89 +280,6 @@ deliver_intr (int line, ipc_port_t dest_port, ipc_port_t interrupt_port) return TRUE; } -mach_intr_notification2_t mach_intr_notification2_template; - -static void -init_mach_intr_notification2 (mach_intr_notification2_t *n) -{ - mach_msg_header_t *m = &n->intr_header; - mach_msg_type_t *t = &n->line_type; - - m->msgh_bits = - MACH_MSGH_BITS_COMPLEX | MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0); - m->msgh_size = sizeof *n; - m->msgh_seqno = INTR_NOTIFY_MSGH_SEQNO; - m->msgh_local_port = MACH_PORT_NULL; - m->msgh_remote_port = MACH_PORT_NULL; - m->msgh_id = MACH_INTR_NOTIFY2; - - t->msgt_name = MACH_MSG_TYPE_INTEGER_32; - t->msgt_size = 32; - t->msgt_number = 1; - t->msgt_inline = TRUE; - t->msgt_longform = FALSE; - t->msgt_deallocate = FALSE; - t->msgt_unused = 0; - - t = &n->count_type; - t->msgt_name = MACH_MSG_TYPE_INTEGER_32; - t->msgt_size = 32; - t->msgt_number = 1; - t->msgt_inline = TRUE; - t->msgt_longform = FALSE; - t->msgt_deallocate = FALSE; - t->msgt_unused = 0; - - t = &n->port_type; - t->msgt_name = MACH_MSG_TYPE_MOVE_SEND; - t->msgt_size = 32; - t->msgt_number = 1; - t->msgt_inline = TRUE; - t->msgt_longform = FALSE; - t->msgt_deallocate = FALSE; - t->msgt_unused = 0; -} - -static boolean_t -deliver_intr_notification2 (ipc_port_t notification_port, - int line, int count, - ipc_port_t interrupt_port) -{ - ipc_kmsg_t kmsg; - ipc_port_t sright, sonce, old; - mach_intr_notification2_t *n; - - assert (notification_port); - assert (interrupt_port); - - kmsg = ikm_alloc(sizeof *n); - if (kmsg == IKM_NULL) - return FALSE; - - ikm_init(kmsg, sizeof *n); - n = (mach_intr_notification2_t *) &kmsg->ikm_header; - *n = mach_intr_notification2_template; - - /* Arrange no-senders notification. */ - sright = ipc_port_make_send (interrupt_port); - sonce = ipc_port_make_sonce (interrupt_port); - ip_lock (interrupt_port); - ipc_port_nsrequest (interrupt_port, interrupt_port->ip_mscount, - sonce, &old); - if (old != IP_NULL) - ipc_port_release_sonce (old); - - n->intr_header.msgh_remote_port = (mach_port_t) notification_port; - n->line = line; - n->count = count; - n->interrupt_port = (mach_port_t) sright; - - ipc_port_copy_send (notification_port); - ipc_mqueue_send_always(kmsg); - - return TRUE; -} - void intr_thread () { @@ -373,7 +288,6 @@ intr_thread () ipc_port_t dest; queue_init (&intr_queue); init_mach_intr_notification (&mach_intr_notification_template); - init_mach_intr_notification2 (&mach_intr_notification2_template); kmem_cache_init (&intr_entry_cache, "intr_entry", sizeof (struct intr_entry), 0, NULL, 0); @@ -393,25 +307,13 @@ intr_thread () int count = e->interrupts; line = e->line; dest = e->dest; - if (e->new_style) - { - e->interrupts = 0; - - cpu_intr_restore (flags); - ok = deliver_intr_notification2 (dest, line, count, interrupt_port); - printf ("new: count? %d ok? %d\n", count, ok); - cpu_intr_save (&flags); - } - else - { - e->interrupts--; - - cpu_intr_restore (flags); - deliver_intr (line, dest, interrupt_port); - cpu_intr_save (&flags); - - assert (e->interrupts == 0); - } + assert (e->interrupts == 1); + e->interrupts--; + + cpu_intr_restore (flags); + deliver_intr (line, dest, interrupt_port); + cpu_intr_save (&flags); + /* We cannot assume that e still exists at this point because we released the lock. Hence we restart the -- cgit v1.2.3