Stefano Stabellini | 4c071ee | 2012-09-14 13:53:39 +0000 | [diff] [blame] | 1 | #include <xen/xen.h> |
| 2 | #include <xen/interface/xen.h> |
| 3 | #include <xen/interface/memory.h> |
| 4 | #include <xen/platform_pci.h> |
| 5 | #include <asm/xen/hypervisor.h> |
| 6 | #include <asm/xen/hypercall.h> |
| 7 | #include <linux/module.h> |
Stefano Stabellini | 2e01f16 | 2012-09-14 10:47:52 +0000 | [diff] [blame^] | 8 | #include <linux/of.h> |
| 9 | #include <linux/of_irq.h> |
| 10 | #include <linux/of_address.h> |
Stefano Stabellini | 4c071ee | 2012-09-14 13:53:39 +0000 | [diff] [blame] | 11 | |
| 12 | struct start_info _xen_start_info; |
| 13 | struct start_info *xen_start_info = &_xen_start_info; |
| 14 | EXPORT_SYMBOL_GPL(xen_start_info); |
| 15 | |
| 16 | enum xen_domain_type xen_domain_type = XEN_NATIVE; |
| 17 | EXPORT_SYMBOL_GPL(xen_domain_type); |
| 18 | |
| 19 | struct shared_info xen_dummy_shared_info; |
| 20 | struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; |
| 21 | |
| 22 | DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); |
| 23 | |
| 24 | /* TODO: to be removed */ |
| 25 | __read_mostly int xen_have_vector_callback; |
| 26 | EXPORT_SYMBOL_GPL(xen_have_vector_callback); |
| 27 | |
| 28 | int xen_platform_pci_unplug = XEN_UNPLUG_ALL; |
| 29 | EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); |
| 30 | |
| 31 | int xen_remap_domain_mfn_range(struct vm_area_struct *vma, |
| 32 | unsigned long addr, |
| 33 | unsigned long mfn, int nr, |
| 34 | pgprot_t prot, unsigned domid) |
| 35 | { |
| 36 | return -ENOSYS; |
| 37 | } |
| 38 | EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); |
Stefano Stabellini | 2e01f16 | 2012-09-14 10:47:52 +0000 | [diff] [blame^] | 39 | |
| 40 | /* |
| 41 | * see Documentation/devicetree/bindings/arm/xen.txt for the |
| 42 | * documentation of the Xen Device Tree format. |
| 43 | */ |
| 44 | static int __init xen_guest_init(void) |
| 45 | { |
| 46 | struct xen_add_to_physmap xatp; |
| 47 | static struct shared_info *shared_info_page = 0; |
| 48 | struct device_node *node; |
| 49 | int len; |
| 50 | const char *s = NULL; |
| 51 | const char *version = NULL; |
| 52 | const char *xen_prefix = "xen,xen-"; |
| 53 | |
| 54 | node = of_find_compatible_node(NULL, NULL, "xen,xen"); |
| 55 | if (!node) { |
| 56 | pr_debug("No Xen support\n"); |
| 57 | return 0; |
| 58 | } |
| 59 | s = of_get_property(node, "compatible", &len); |
| 60 | if (strlen(xen_prefix) + 3 < len && |
| 61 | !strncmp(xen_prefix, s, strlen(xen_prefix))) |
| 62 | version = s + strlen(xen_prefix); |
| 63 | if (version == NULL) { |
| 64 | pr_debug("Xen version not found\n"); |
| 65 | return 0; |
| 66 | } |
| 67 | xen_domain_type = XEN_HVM_DOMAIN; |
| 68 | |
| 69 | if (!shared_info_page) |
| 70 | shared_info_page = (struct shared_info *) |
| 71 | get_zeroed_page(GFP_KERNEL); |
| 72 | if (!shared_info_page) { |
| 73 | pr_err("not enough memory\n"); |
| 74 | return -ENOMEM; |
| 75 | } |
| 76 | xatp.domid = DOMID_SELF; |
| 77 | xatp.idx = 0; |
| 78 | xatp.space = XENMAPSPACE_shared_info; |
| 79 | xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT; |
| 80 | if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) |
| 81 | BUG(); |
| 82 | |
| 83 | HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; |
| 84 | |
| 85 | /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info |
| 86 | * page, we use it in the event channel upcall and in some pvclock |
| 87 | * related functions. We don't need the vcpu_info placement |
| 88 | * optimizations because we don't use any pv_mmu or pv_irq op on |
| 89 | * HVM. |
| 90 | * The shared info contains exactly 1 CPU (the boot CPU). The guest |
| 91 | * is required to use VCPUOP_register_vcpu_info to place vcpu info |
| 92 | * for secondary CPUs as they are brought up. */ |
| 93 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; |
| 94 | return 0; |
| 95 | } |
| 96 | core_initcall(xen_guest_init); |