static int __devinit xenbus_probe_init(void) #endif { int err = 0; #if defined(CONFIG_XEN) || defined(MODULE) unsigned long page = 0; #endif DPRINTK(""); if (!is_running_on_xen()) return -ENODEV; /* Register ourselves with the kernel bus subsystem */ xenbus_frontend.error = bus_register(&xenbus_frontend.bus); if (xenbus_frontend.error) printk(KERN_WARNING "XENBUS: Error registering frontend bus: %i\n", xenbus_frontend.error); xenbus_backend_bus_register(); /* * Domain0 doesn't have a store_evtchn or store_mfn yet. */ if (is_initial_xendomain()) { #if defined(CONFIG_XEN) || defined(MODULE) struct evtchn_alloc_unbound alloc_unbound; /* Allocate page. */ page = get_zeroed_page(GFP_KERNEL); if (!page) return -ENOMEM; xen_store_mfn = xen_start_info->store_mfn = pfn_to_mfn(virt_to_phys((void *)page) >> PAGE_SHIFT); /* Next allocate a local port which xenstored can bind to */ alloc_unbound.dom = DOMID_SELF; alloc_unbound.remote_dom = 0; err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc_unbound); if (err == -ENOSYS) goto err; BUG_ON(err); xen_store_evtchn = xen_start_info->store_evtchn = alloc_unbound.port; #if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST) /* And finally publish the above info in /proc/xen */ xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0600); if (xsd_kva_intf) { memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops, sizeof(xsd_kva_fops)); xsd_kva_fops.mmap = xsd_kva_mmap; xsd_kva_intf->proc_fops = &xsd_kva_fops; xsd_kva_intf->read_proc = xsd_kva_read; } 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 {
static int __init xenbus_probe_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 { xenstored_ready = 1; 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); /* 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; } if (!xen_initial_domain()) xenbus_probe(NULL); #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; }
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; }