static int __init xenbus_init(void) { int err = 0; if (!xen_domain()) return -ENODEV; if (xen_hvm_domain()) { uint64_t v = 0; err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (err) goto out_error; xen_store_evtchn = (int)v; err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); if (err) goto out_error; xen_store_mfn = (unsigned long)v; xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); } else { xen_store_evtchn = xen_start_info->store_evtchn; xen_store_mfn = xen_start_info->store_mfn; if (xen_store_evtchn) xenstored_ready = 1; else { err = xenstored_local_init(); if (err) goto out_error; } xen_store_interface = mfn_to_virt(xen_store_mfn); } /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { printk(KERN_WARNING "XENBUS: Error initializing xenstore comms: %i\n", err); goto out_error; } #ifdef CONFIG_XEN_COMPAT_XENFS /* * Create xenfs mountpoint in /proc for compatibility with * utilities that expect to find "xenbus" under "/proc/xen". */ proc_mkdir("xen", NULL); #endif out_error: return err; }
static int xenbus_resume_cb(struct notifier_block *nb, unsigned long action, void *data) { int err = 0; if (xen_hvm_domain()) { uint64_t v = 0; err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (!err && v) xen_store_evtchn = v; else pr_warn("Cannot update xenstore event channel: %d\n", err); } else xen_store_evtchn = xen_start_info->store_evtchn; return err; }
static int __init xenbus_init(void) { int err = 0; uint64_t v = 0; xen_store_domain_type = XS_UNKNOWN; if (!xen_domain()) return -ENODEV; xenbus_ring_ops_init(); if (xen_pv_domain()) xen_store_domain_type = XS_PV; if (xen_hvm_domain()) xen_store_domain_type = XS_HVM; if (xen_hvm_domain() && xen_initial_domain()) xen_store_domain_type = XS_LOCAL; if (xen_pv_domain() && !xen_start_info->store_evtchn) xen_store_domain_type = XS_LOCAL; if (xen_pv_domain() && xen_start_info->store_evtchn) xenstored_ready = 1; switch (xen_store_domain_type) { case XS_LOCAL: err = xenstored_local_init(); if (err) goto out_error; xen_store_interface = gfn_to_virt(xen_store_gfn); break; case XS_PV: xen_store_evtchn = xen_start_info->store_evtchn; xen_store_gfn = xen_start_info->store_mfn; xen_store_interface = gfn_to_virt(xen_store_gfn); break; case XS_HVM: err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (err) goto out_error; xen_store_evtchn = (int)v; err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); if (err) goto out_error; xen_store_gfn = (unsigned long)v; xen_store_interface = xen_remap(xen_store_gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE); break; default: pr_warn("Xenstore state unknown\n"); break; } /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { pr_warn("Error initializing xenstore comms: %i\n", err); goto out_error; } if ((xen_store_domain_type != XS_LOCAL) && (xen_store_domain_type != XS_UNKNOWN)) xen_resume_notifier_register(&xenbus_resume_nb); #ifdef CONFIG_XEN_COMPAT_XENFS /* * Create xenfs mountpoint in /proc for compatibility with * utilities that expect to find "xenbus" under "/proc/xen". */ proc_mkdir("xen", NULL); #endif out_error: return err; }
xsd_port_intf = create_xen_proc_entry("xsd_port", 0400); if (xsd_port_intf) xsd_port_intf->read_proc = xsd_port_read; #endif #else /* dom0 not yet supported */ #endif xen_store_interface = mfn_to_virt(xen_store_mfn); } else { xenstored_ready = 1; #ifndef MODULE xen_store_evtchn = xen_start_info->store_evtchn; xen_store_mfn = xen_start_info->store_mfn; xen_store_interface = mfn_to_virt(xen_store_mfn); #else xen_store_evtchn = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN); xen_store_mfn = hvm_get_parameter(HVM_PARAM_STORE_PFN); xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); #endif } #if defined(CONFIG_XEN) || defined(MODULE) xenbus_dev_init(); #endif /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { printk(KERN_WARNING
static int __init xenbus_init(void) { int err = 0; enum xenstore_init usage = UNKNOWN; uint64_t v = 0; if (!xen_domain()) return -ENODEV; xenbus_ring_ops_init(); if (xen_pv_domain()) usage = PV; if (xen_hvm_domain()) usage = HVM; if (xen_hvm_domain() && xen_initial_domain()) usage = LOCAL; if (xen_pv_domain() && !xen_start_info->store_evtchn) usage = LOCAL; if (xen_pv_domain() && xen_start_info->store_evtchn) xenstored_ready = 1; switch (usage) { case LOCAL: err = xenstored_local_init(); if (err) goto out_error; xen_store_interface = mfn_to_virt(xen_store_mfn); break; case PV: xen_store_evtchn = xen_start_info->store_evtchn; xen_store_mfn = xen_start_info->store_mfn; xen_store_interface = mfn_to_virt(xen_store_mfn); break; case HVM: err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (err) goto out_error; xen_store_evtchn = (int)v; err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); if (err) goto out_error; xen_store_mfn = (unsigned long)v; xen_store_interface = xen_remap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); break; default: pr_warn("Xenstore state unknown\n"); break; } /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { printk(KERN_WARNING "XENBUS: Error initializing xenstore comms: %i\n", err); goto out_error; } #ifdef CONFIG_XEN_COMPAT_XENFS /* * Create xenfs mountpoint in /proc for compatibility with * utilities that expect to find "xenbus" under "/proc/xen". */ proc_mkdir("xen", NULL); #endif out_error: return err; }
static int __init xenbus_init(void) { int err = 0; DPRINTK(""); err = -ENODEV; if (!xen_domain()) goto out_error; /* Register ourselves with the kernel bus subsystem */ err = bus_register(&xenbus_frontend.bus); if (err) goto out_error; err = xenbus_backend_bus_register(); if (err) goto out_unreg_front; /* * Domain0 doesn't have a store_evtchn or store_mfn yet. */ if (xen_initial_domain()) { /* dom0 not yet supported */ } else { if (xen_hvm_domain()) { uint64_t v = 0; err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (err) goto out_error; xen_store_evtchn = (int)v; err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v); if (err) goto out_error; xen_store_mfn = (unsigned long)v; xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); } else { xen_store_evtchn = xen_start_info->store_evtchn; xen_store_mfn = xen_start_info->store_mfn; xen_store_interface = mfn_to_virt(xen_store_mfn); xenstored_ready = 1; } } /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { printk(KERN_WARNING "XENBUS: Error initializing xenstore comms: %i\n", err); goto out_unreg_back; } #ifdef CONFIG_XEN_COMPAT_XENFS /* * Create xenfs mountpoint in /proc for compatibility with * utilities that expect to find "xenbus" under "/proc/xen". */ proc_mkdir("xen", NULL); #endif return 0; out_unreg_back: xenbus_backend_bus_unregister(); out_unreg_front: bus_unregister(&xenbus_frontend.bus); out_error: return err; }