18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _XEN_XEN_H
38c2ecf20Sopenharmony_ci#define _XEN_XEN_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_cienum xen_domain_type {
68c2ecf20Sopenharmony_ci	XEN_NATIVE,		/* running on bare hardware    */
78c2ecf20Sopenharmony_ci	XEN_PV_DOMAIN,		/* running in a PV domain      */
88c2ecf20Sopenharmony_ci	XEN_HVM_DOMAIN,		/* running in a Xen hvm domain */
98c2ecf20Sopenharmony_ci};
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN
128c2ecf20Sopenharmony_ciextern enum xen_domain_type xen_domain_type;
138c2ecf20Sopenharmony_ci#else
148c2ecf20Sopenharmony_ci#define xen_domain_type		XEN_NATIVE
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_PVH
188c2ecf20Sopenharmony_ciextern bool xen_pvh;
198c2ecf20Sopenharmony_ci#else
208c2ecf20Sopenharmony_ci#define xen_pvh			0
218c2ecf20Sopenharmony_ci#endif
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define xen_domain()		(xen_domain_type != XEN_NATIVE)
248c2ecf20Sopenharmony_ci#define xen_pv_domain()		(xen_domain_type == XEN_PV_DOMAIN)
258c2ecf20Sopenharmony_ci#define xen_hvm_domain()	(xen_domain_type == XEN_HVM_DOMAIN)
268c2ecf20Sopenharmony_ci#define xen_pvh_domain()	(xen_pvh)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <linux/types.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciextern uint32_t xen_start_flags;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#include <xen/interface/hvm/start_info.h>
338c2ecf20Sopenharmony_ciextern struct hvm_start_info pvh_start_info;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_DOM0
368c2ecf20Sopenharmony_ci#include <xen/interface/xen.h>
378c2ecf20Sopenharmony_ci#include <asm/xen/hypervisor.h>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define xen_initial_domain()	(xen_domain() && \
408c2ecf20Sopenharmony_ci				 (xen_start_flags & SIF_INITDOMAIN))
418c2ecf20Sopenharmony_ci#else  /* !CONFIG_XEN_DOM0 */
428c2ecf20Sopenharmony_ci#define xen_initial_domain()	(0)
438c2ecf20Sopenharmony_ci#endif	/* CONFIG_XEN_DOM0 */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct bio_vec;
468c2ecf20Sopenharmony_cistruct page;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cibool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
498c2ecf20Sopenharmony_ci		const struct page *page);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
528c2ecf20Sopenharmony_ciextern u64 xen_saved_max_mem_size;
538c2ecf20Sopenharmony_ci#endif
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
568c2ecf20Sopenharmony_ciint xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
578c2ecf20Sopenharmony_civoid xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
588c2ecf20Sopenharmony_ci#else
598c2ecf20Sopenharmony_ci#define xen_alloc_unpopulated_pages alloc_xenballooned_pages
608c2ecf20Sopenharmony_ci#define xen_free_unpopulated_pages free_xenballooned_pages
618c2ecf20Sopenharmony_ci#include <xen/balloon.h>
628c2ecf20Sopenharmony_ci#endif
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI) && defined(CONFIG_X86)
658c2ecf20Sopenharmony_cibool __init xen_processor_present(uint32_t acpi_id);
668c2ecf20Sopenharmony_ci#else
678c2ecf20Sopenharmony_ci#include <linux/bug.h>
688c2ecf20Sopenharmony_cistatic inline bool xen_processor_present(uint32_t acpi_id)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	BUG();
718c2ecf20Sopenharmony_ci	return false;
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci#endif
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#endif	/* _XEN_XEN_H */
76