1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21ccbf534SJeremy Fitzhardinge #ifndef _XEN_XEN_H
31ccbf534SJeremy Fitzhardinge #define _XEN_XEN_H
41ccbf534SJeremy Fitzhardinge
511987fbeSJani Nikula #include <linux/types.h>
611987fbeSJani Nikula
71ccbf534SJeremy Fitzhardinge enum xen_domain_type {
81ccbf534SJeremy Fitzhardinge XEN_NATIVE, /* running on bare hardware */
91ccbf534SJeremy Fitzhardinge XEN_PV_DOMAIN, /* running in a PV domain */
101ccbf534SJeremy Fitzhardinge XEN_HVM_DOMAIN, /* running in a Xen hvm domain */
111ccbf534SJeremy Fitzhardinge };
121ccbf534SJeremy Fitzhardinge
131ccbf534SJeremy Fitzhardinge #ifdef CONFIG_XEN
141ccbf534SJeremy Fitzhardinge extern enum xen_domain_type xen_domain_type;
151ccbf534SJeremy Fitzhardinge #else
161ccbf534SJeremy Fitzhardinge #define xen_domain_type XEN_NATIVE
171ccbf534SJeremy Fitzhardinge #endif
181ccbf534SJeremy Fitzhardinge
19b4feaeb0SJuergen Gross #ifdef CONFIG_XEN_PVH
20b4feaeb0SJuergen Gross extern bool xen_pvh;
21b4feaeb0SJuergen Gross #else
22b4feaeb0SJuergen Gross #define xen_pvh 0
23b4feaeb0SJuergen Gross #endif
24b4feaeb0SJuergen Gross
251ccbf534SJeremy Fitzhardinge #define xen_domain() (xen_domain_type != XEN_NATIVE)
26b4feaeb0SJuergen Gross #define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN)
27b4feaeb0SJuergen Gross #define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)
28b4feaeb0SJuergen Gross #define xen_pvh_domain() (xen_pvh)
291ccbf534SJeremy Fitzhardinge
301fe83888SRoger Pau Monne extern uint32_t xen_start_flags;
311fe83888SRoger Pau Monne
32*358cd9afSJuergen Gross #ifdef CONFIG_XEN_PV
33*358cd9afSJuergen Gross extern bool xen_pv_pci_possible;
34*358cd9afSJuergen Gross #else
35*358cd9afSJuergen Gross #define xen_pv_pci_possible 0
36*358cd9afSJuergen Gross #endif
37*358cd9afSJuergen Gross
388cee3974SMaran Wilson #include <xen/interface/hvm/start_info.h>
398cee3974SMaran Wilson extern struct hvm_start_info pvh_start_info;
40fb9b7b4bSArnd Bergmann void xen_prepare_pvh(void);
41fb9b7b4bSArnd Bergmann struct pt_regs;
42fb9b7b4bSArnd Bergmann void xen_pv_evtchn_do_upcall(struct pt_regs *regs);
438cee3974SMaran Wilson
441ccbf534SJeremy Fitzhardinge #ifdef CONFIG_XEN_DOM0
451ccbf534SJeremy Fitzhardinge #include <xen/interface/xen.h>
461ccbf534SJeremy Fitzhardinge #include <asm/xen/hypervisor.h>
471ccbf534SJeremy Fitzhardinge
484c071ee5SStefano Stabellini #define xen_initial_domain() (xen_domain() && \
491fe83888SRoger Pau Monne (xen_start_flags & SIF_INITDOMAIN))
501ccbf534SJeremy Fitzhardinge #else /* !CONFIG_XEN_DOM0 */
511ccbf534SJeremy Fitzhardinge #define xen_initial_domain() (0)
521ccbf534SJeremy Fitzhardinge #endif /* CONFIG_XEN_DOM0 */
531ccbf534SJeremy Fitzhardinge
5420e32676SChristoph Hellwig struct bio_vec;
550383ad43SMing Lei struct page;
560383ad43SMing Lei
5720e32676SChristoph Hellwig bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
580383ad43SMing Lei const struct page *page);
5920e32676SChristoph Hellwig
601d988ed4SJuergen Gross #if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_XEN_BALLOON)
611d988ed4SJuergen Gross extern u64 xen_saved_max_mem_size;
621d988ed4SJuergen Gross #endif
631d988ed4SJuergen Gross
649dd060afSOleksandr Tyshchenko #ifdef CONFIG_XEN_UNPOPULATED_ALLOC
659e2369c0SRoger Pau Monne int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
669e2369c0SRoger Pau Monne void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
67d1a928eaSOleksandr Tyshchenko #include <linux/ioport.h>
68d1a928eaSOleksandr Tyshchenko int arch_xen_unpopulated_init(struct resource **res);
699dd060afSOleksandr Tyshchenko #else
709dd060afSOleksandr Tyshchenko #include <xen/balloon.h>
xen_alloc_unpopulated_pages(unsigned int nr_pages,struct page ** pages)719dd060afSOleksandr Tyshchenko static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages,
729dd060afSOleksandr Tyshchenko struct page **pages)
739dd060afSOleksandr Tyshchenko {
749dd060afSOleksandr Tyshchenko return xen_alloc_ballooned_pages(nr_pages, pages);
759dd060afSOleksandr Tyshchenko }
xen_free_unpopulated_pages(unsigned int nr_pages,struct page ** pages)769dd060afSOleksandr Tyshchenko static inline void xen_free_unpopulated_pages(unsigned int nr_pages,
779dd060afSOleksandr Tyshchenko struct page **pages)
789dd060afSOleksandr Tyshchenko {
799dd060afSOleksandr Tyshchenko xen_free_ballooned_pages(nr_pages, pages);
809dd060afSOleksandr Tyshchenko }
819dd060afSOleksandr Tyshchenko #endif
829e2369c0SRoger Pau Monne
83073828e9SRoger Pau Monne #if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI) && defined(CONFIG_X86)
84073828e9SRoger Pau Monne bool __init xen_processor_present(uint32_t acpi_id);
85073828e9SRoger Pau Monne #else
86073828e9SRoger Pau Monne #include <linux/bug.h>
xen_processor_present(uint32_t acpi_id)87073828e9SRoger Pau Monne static inline bool xen_processor_present(uint32_t acpi_id)
88073828e9SRoger Pau Monne {
89073828e9SRoger Pau Monne BUG();
90073828e9SRoger Pau Monne return false;
91073828e9SRoger Pau Monne }
92073828e9SRoger Pau Monne #endif
93073828e9SRoger Pau Monne
941ccbf534SJeremy Fitzhardinge #endif /* _XEN_XEN_H */
95