]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/i386/xen/setup.c
xen: Core Xen implementation
[mirror_ubuntu-artful-kernel.git] / arch / i386 / xen / setup.c
CommitLineData
5ead97c8
JF
1/*
2 * Machine specific setup for xen
3 *
4 * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
5 */
6
7#include <linux/module.h>
8#include <linux/sched.h>
9#include <linux/mm.h>
10#include <linux/pm.h>
11
12#include <asm/elf.h>
13#include <asm/e820.h>
14#include <asm/setup.h>
15#include <asm/xen/hypervisor.h>
16#include <asm/xen/hypercall.h>
17
18#include <xen/interface/physdev.h>
19#include <xen/features.h>
20
21#include "xen-ops.h"
22
23/* These are code, but not functions. Defined in entry.S */
24extern const char xen_hypervisor_callback[];
25extern const char xen_failsafe_callback[];
26
27static __initdata struct shared_info init_shared;
28
29/*
30 * Point at some empty memory to start with. We map the real shared_info
31 * page as soon as fixmap is up and running.
32 */
33struct shared_info *HYPERVISOR_shared_info = &init_shared;
34
35unsigned long *phys_to_machine_mapping;
36EXPORT_SYMBOL(phys_to_machine_mapping);
37
38/**
39 * machine_specific_memory_setup - Hook for machine specific memory setup.
40 **/
41
42char * __init xen_memory_setup(void)
43{
44 unsigned long max_pfn = xen_start_info->nr_pages;
45
46 e820.nr_map = 0;
47 add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
48
49 return "Xen";
50}
51
52static void xen_idle(void)
53{
54 local_irq_disable();
55
56 if (need_resched())
57 local_irq_enable();
58 else {
59 current_thread_info()->status &= ~TS_POLLING;
60 smp_mb__after_clear_bit();
61 safe_halt();
62 current_thread_info()->status |= TS_POLLING;
63 }
64}
65
66void __init xen_arch_setup(void)
67{
68 struct physdev_set_iopl set_iopl;
69 int rc;
70
71 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
72 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
73
74 if (!xen_feature(XENFEAT_auto_translated_physmap))
75 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
76
77 HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
78 __KERNEL_CS, (unsigned long)xen_failsafe_callback);
79
80 set_iopl.iopl = 1;
81 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
82 if (rc != 0)
83 printk(KERN_INFO "physdev_op failed %d\n", rc);
84
85#ifdef CONFIG_ACPI
86 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
87 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
88 disable_acpi();
89 }
90#endif
91
92 memcpy(boot_command_line, xen_start_info->cmd_line,
93 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
94 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
95
96 pm_idle = xen_idle;
97}