static int __init balloon_init(void) { #if defined(CONFIG_X86) && defined(CONFIG_XEN) unsigned long pfn; struct page *page; #endif if (!is_running_on_xen()) return -ENODEV; IPRINTK("Initialising balloon driver.\n"); #ifdef CONFIG_XEN current_pages = min(xen_start_info->nr_pages, max_pfn); totalram_pages = current_pages; #else current_pages = totalram_pages; #endif target_pages = current_pages; balloon_low = 0; balloon_high = 0; driver_pages = 0UL; hard_limit = ~0UL; init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; /* don't include on bare-metal & FV guest */ #if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN) if ((balloon_pde = create_xen_proc_entry("balloon", 0644)) == NULL) { WPRINTK("Unable to create /proc/xen/balloon.\n"); return -1; } balloon_pde->read_proc = balloon_read; balloon_pde->write_proc = balloon_write; #endif #if defined(CONFIG_X86) && defined(CONFIG_XEN) /* Initialise the balloon with excess memory space. */ for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) { page = pfn_to_page(pfn); balloon_append(page); } #endif target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
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 {