#include <xen/types.h>
#include <asm/cache.h>
-#include <asm/guest/hypervisor.h>
+#include <asm/guest.h>
static const struct hypervisor_ops *__read_mostly ops;
const char *__init hypervisor_probe(void)
{
+ if ( !cpu_has_hypervisor )
+ return NULL;
+
+ ops = xg_probe();
+ if ( ops )
+ return ops->name;
+
return NULL;
}
+void __init hypervisor_setup(void)
+{
+ if ( ops && ops->setup )
+ ops->setup();
+}
+
+void hypervisor_ap_setup(void)
+{
+ if ( ops && ops->ap_setup )
+ ops->ap_setup();
+}
+
+void hypervisor_resume(void)
+{
+ if ( ops && ops->resume )
+ ops->resume();
+}
+
/*
* Local variables:
* mode: C
{
convert_pvh_info(mbi, mod);
- probe_hypervisor();
+ hypervisor_probe();
ASSERT(xen_guest);
get_memory_map();
}
}
-void __init probe_hypervisor(void)
-{
- if ( xen_guest || !cpu_has_hypervisor )
- return;
-
- find_xen_leaves();
-
- if ( !xen_cpuid_base )
- return;
-
- /* Fill the hypercall page. */
- wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page));
-
- xen_guest = true;
-}
-
static void map_shared_info(void)
{
mfn_t mfn;
}
}
-void __init hypervisor_setup(void)
+static void __init setup(void)
{
init_memmap();
init_evtchn();
}
-void hypervisor_ap_setup(void)
+static void ap_setup(void)
{
set_vcpu_id();
map_vcpuinfo();
init_evtchn();
}
-void hypervisor_resume(void)
+static void resume(void)
{
/* Reset shared info page. */
map_shared_info();
pv_console_init();
}
+static const struct hypervisor_ops ops = {
+ .name = "Xen",
+ .setup = setup,
+ .ap_setup = ap_setup,
+ .resume = resume,
+};
+
+const struct hypervisor_ops *__init xg_probe(void)
+{
+ if ( xen_guest )
+ return &ops;
+
+ find_xen_leaves();
+
+ if ( !xen_cpuid_base )
+ return NULL;
+
+ /* Fill the hypercall page. */
+ wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page));
+
+ xen_guest = true;
+
+ return &ops;
+}
+
/*
* Local variables:
* mode: C
* allocing any xenheap structures wanted in lower memory. */
kexec_early_calculations();
- probe_hypervisor();
+ hypervisor_probe();
parse_video_info();
#include <asm/e820.h>
#include <asm/fixmap.h>
+#include <asm/guest/hypervisor.h>
#define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_INFO))
extern bool pv_console;
extern uint32_t xen_cpuid_base;
-void probe_hypervisor(void);
+const struct hypervisor_ops *xg_probe(void);
int xg_alloc_unused_page(mfn_t *mfn);
int xg_free_unused_page(mfn_t mfn);
#define xen_guest 0
#define pv_console 0
-static inline void probe_hypervisor(void) {}
+static inline const struct hypervisor_ops *xg_probe(void) { return NULL; }
#endif /* CONFIG_XEN_GUEST */
#endif /* __X86_GUEST_XEN_H__ */