t_status interface_thread_priority(o_syscall* message) { t_status error; error = thread_priority(message->u.request.u.thread_priority.arg1, message->u.request.u.thread_priority.arg2); message->u.reply.error = error; return (STATUS_OK); }
static void * intrthread(void *arg) { struct irq *irq = arg; mach_port_t delivery_port; mach_port_t pset, psetcntl; int ret; int val; rumpuser_component_kthread(); ret = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &delivery_port); if (ret) err(ret, "mach_port_allocate"); ret = thread_get_assignment (mach_thread_self (), &pset); if (ret) err(ret, "thread_get_assignment"); ret = host_processor_set_priv (master_host, pset, &psetcntl); if (ret) err(ret, "host_processor_set_priv"); thread_max_priority (mach_thread_self (), psetcntl, 0); ret = thread_priority (mach_thread_self (), RUMP_IRQ_PRIO, 0); if (ret) err(ret, "thread_priority"); ret = device_intr_register(master_device, irq->intrline, 0, 0x04000000, delivery_port, MACH_MSG_TYPE_MAKE_SEND); if (ret) { warn("device_intr_register"); return 0; } device_intr_enable (master_device, irq->intrline, TRUE); int irq_server (mach_msg_header_t *inp, mach_msg_header_t *outp) { mach_intr_notification_t *intr_header = (mach_intr_notification_t *) inp; ((mig_reply_header_t *) outp)->RetCode = MIG_NO_REPLY; if (inp->msgh_id != MACH_INTR_NOTIFY) return 0; /* It's an interrupt not for us. It shouldn't happen. */ if (intr_header->line != irq->intrline) { printf ("We get interrupt %d, %d is expected", intr_header->line, irq->intrline); return 1; } rumpcomp_pci_confread(0, irq->device, 0, 0x04, &val); if (val & 0x400) { printf("interrupt disabled!\n"); val &= ~0x400; rumpcomp_pci_confwrite(0, irq->device, 0, 0x04, val); } rumpuser_component_schedule(NULL); irq->handler(irq->data); rumpuser_component_unschedule(); /* If the irq has been disabled by the linux device, * we don't need to reenable the real one. */ device_intr_enable (master_device, irq->intrline, TRUE); return 1; }