162306a36Sopenharmony_ci/******************************************************************************
262306a36Sopenharmony_ci * hypervisor.h
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Linux-specific hypervisor handling.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (c) 2002-2004, K A Fraser
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or
962306a36Sopenharmony_ci * modify it under the terms of the GNU General Public License version 2
1062306a36Sopenharmony_ci * as published by the Free Software Foundation; or, when distributed
1162306a36Sopenharmony_ci * separately from the Linux kernel or incorporated into other
1262306a36Sopenharmony_ci * software packages, subject to the following license:
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
1562306a36Sopenharmony_ci * of this source file (the "Software"), to deal in the Software without
1662306a36Sopenharmony_ci * restriction, including without limitation the rights to use, copy, modify,
1762306a36Sopenharmony_ci * merge, publish, distribute, sublicense, and/or sell copies of the Software,
1862306a36Sopenharmony_ci * and to permit persons to whom the Software is furnished to do so, subject to
1962306a36Sopenharmony_ci * the following conditions:
2062306a36Sopenharmony_ci *
2162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
2262306a36Sopenharmony_ci * all copies or substantial portions of the Software.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2762306a36Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2862306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2962306a36Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
3062306a36Sopenharmony_ci * IN THE SOFTWARE.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifndef _ASM_X86_XEN_HYPERVISOR_H
3462306a36Sopenharmony_ci#define _ASM_X86_XEN_HYPERVISOR_H
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciextern struct shared_info *HYPERVISOR_shared_info;
3762306a36Sopenharmony_ciextern struct start_info *xen_start_info;
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#include <asm/bug.h>
4062306a36Sopenharmony_ci#include <asm/processor.h>
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define XEN_SIGNATURE "XenVMMXenVMM"
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cistatic inline uint32_t xen_cpuid_base(void)
4562306a36Sopenharmony_ci{
4662306a36Sopenharmony_ci	return hypervisor_cpuid_base(XEN_SIGNATURE, 2);
4762306a36Sopenharmony_ci}
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_cistruct pci_dev;
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#ifdef CONFIG_XEN_PV_DOM0
5262306a36Sopenharmony_cibool xen_initdom_restore_msi(struct pci_dev *dev);
5362306a36Sopenharmony_ci#else
5462306a36Sopenharmony_cistatic inline bool xen_initdom_restore_msi(struct pci_dev *dev) { return true; }
5562306a36Sopenharmony_ci#endif
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#ifdef CONFIG_HOTPLUG_CPU
5862306a36Sopenharmony_civoid xen_arch_register_cpu(int num);
5962306a36Sopenharmony_civoid xen_arch_unregister_cpu(int num);
6062306a36Sopenharmony_ci#endif
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#ifdef CONFIG_PVH
6362306a36Sopenharmony_civoid __init xen_pvh_init(struct boot_params *boot_params);
6462306a36Sopenharmony_civoid __init mem_map_via_hcall(struct boot_params *boot_params_p);
6562306a36Sopenharmony_ci#endif
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* Lazy mode for batching updates / context switch */
6862306a36Sopenharmony_cienum xen_lazy_mode {
6962306a36Sopenharmony_ci	XEN_LAZY_NONE,
7062306a36Sopenharmony_ci	XEN_LAZY_MMU,
7162306a36Sopenharmony_ci	XEN_LAZY_CPU,
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciDECLARE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode);
7562306a36Sopenharmony_ciDECLARE_PER_CPU(unsigned int, xen_lazy_nesting);
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_cistatic inline void enter_lazy(enum xen_lazy_mode mode)
7862306a36Sopenharmony_ci{
7962306a36Sopenharmony_ci	enum xen_lazy_mode old_mode = this_cpu_read(xen_lazy_mode);
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci	if (mode == old_mode) {
8262306a36Sopenharmony_ci		this_cpu_inc(xen_lazy_nesting);
8362306a36Sopenharmony_ci		return;
8462306a36Sopenharmony_ci	}
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci	BUG_ON(old_mode != XEN_LAZY_NONE);
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci	this_cpu_write(xen_lazy_mode, mode);
8962306a36Sopenharmony_ci}
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cistatic inline void leave_lazy(enum xen_lazy_mode mode)
9262306a36Sopenharmony_ci{
9362306a36Sopenharmony_ci	BUG_ON(this_cpu_read(xen_lazy_mode) != mode);
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci	if (this_cpu_read(xen_lazy_nesting) == 0)
9662306a36Sopenharmony_ci		this_cpu_write(xen_lazy_mode, XEN_LAZY_NONE);
9762306a36Sopenharmony_ci	else
9862306a36Sopenharmony_ci		this_cpu_dec(xen_lazy_nesting);
9962306a36Sopenharmony_ci}
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cienum xen_lazy_mode xen_get_lazy_mode(void);
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI)
10462306a36Sopenharmony_civoid xen_sanitize_proc_cap_bits(uint32_t *buf);
10562306a36Sopenharmony_ci#else
10662306a36Sopenharmony_cistatic inline void xen_sanitize_proc_cap_bits(uint32_t *buf)
10762306a36Sopenharmony_ci{
10862306a36Sopenharmony_ci	BUG();
10962306a36Sopenharmony_ci}
11062306a36Sopenharmony_ci#endif
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#endif /* _ASM_X86_XEN_HYPERVISOR_H */
113