struct consfront_dev *xencons_ring_init(void) { int err; struct consfront_dev *dev; if (!start_info.console.domU.evtchn) return 0; dev = bmk_memcalloc(1, sizeof(struct consfront_dev)); dev->nodename = "device/console"; dev->dom = 0; dev->backend = 0; dev->ring_ref = 0; dev->evtchn = start_info.console.domU.evtchn; dev->ring = (struct xencons_interface *) mfn_to_virt(start_info.console.domU.mfn); err = minios_bind_evtchn(dev->evtchn, console_handle_input, dev); if (err <= 0) { minios_printk("XEN console request chn bind failed %i\n", err); bmk_memfree(dev); return NULL; } minios_unmask_evtchn(dev->evtchn); /* In case we have in-flight data after save/restore... */ notify_daemon(dev); return dev; }
evtchn_port_t minios_bind_virq(uint32_t virq, evtchn_handler_t handler, void *data) { evtchn_bind_virq_t op; int rc; /* Try to bind the virq to a port */ op.virq = virq; op.vcpu = smp_processor_id(); if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op)) != 0 ) { minios_printk("Failed to bind virtual IRQ %d with rc=%d\n", virq, rc); return -1; } minios_bind_evtchn(op.port, handler, data); return op.port; }
evtchn_port_t minios_bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data) { evtchn_bind_pirq_t op; int rc; /* Try to bind the pirq to a port */ op.pirq = pirq; op.flags = will_share ? BIND_PIRQ__WILL_SHARE : 0; if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op)) != 0 ) { minios_printk("Failed to bind physical IRQ %d with rc=%d\n", pirq, rc); return -1; } minios_bind_evtchn(op.port, handler, data); return op.port; }