int xencons_ring_init(void) { int irq; if (xencons_irq) unbind_from_irqhandler(xencons_irq, NULL); xencons_irq = 0; if (!is_running_on_xen() || is_initial_xendomain() || !xen_start_info->console.domU.evtchn) return -ENODEV; irq = bind_caller_port_to_irqhandler( xen_start_info->console.domU.evtchn, handle_input, 0, "xencons", NULL); if (irq < 0) { printk(KERN_ERR "XEN console request irq failed %i\n", irq); return irq; } xencons_irq = irq; /* In case we have in-flight data after save/restore... */ notify_daemon(); return 0; }
static int pcifront_publish_info(struct pcifront_device *pdev) { int err = 0; struct xenbus_transaction trans; err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info)); if (err < 0) goto out; pdev->gnt_ref = err; err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn); if (err) goto out; bind_caller_port_to_irqhandler(pdev->evtchn, pcifront_handler_aer, IRQF_SAMPLE_RANDOM, "pcifront", pdev); do_publish: err = xenbus_transaction_start(&trans); if (err) { xenbus_dev_fatal(pdev->xdev, err, "Error writing configuration for backend " "(start transaction)"); goto out; } err = xenbus_printf(trans, pdev->xdev->nodename, "pci-op-ref", "%u", pdev->gnt_ref); if (!err) err = xenbus_printf(trans, pdev->xdev->nodename, "event-channel", "%u", pdev->evtchn); if (!err) err = xenbus_printf(trans, pdev->xdev->nodename, "magic", XEN_PCI_MAGIC); if (err) { xenbus_transaction_end(trans, 1); xenbus_dev_fatal(pdev->xdev, err, "Error writing configuration for backend"); goto out; } else { err = xenbus_transaction_end(trans, 0); if (err == -EAGAIN) goto do_publish; else if (err) { xenbus_dev_fatal(pdev->xdev, err, "Error completing transaction " "for backend"); goto out; } } xenbus_switch_state(pdev->xdev, XenbusStateInitialised); dev_dbg(&pdev->xdev->dev, "publishing successful!\n"); out: return err; }
int xencons_ring_init(void) { int err; if (!xen_start_info->console_evtchn) return 0; err = bind_caller_port_to_irqhandler(xen_start_info->console_evtchn, "xencons", xencons_handle_input, NULL, INTR_TYPE_MISC | INTR_MPSAFE, &console_irq); if (err) { return err; } return 0; }