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; }
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; }