xref: /freebsd/sys/x86/include/xen/xen-os.h (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1 /*****************************************************************************
2  * x86/xen/xen-os.h
3  *
4  * Random collection of macros and definition
5  *
6  * Copyright (c) 2003, 2004 Keir Fraser (on behalf of the Xen team)
7  * All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to
11  * deal in the Software without restriction, including without limitation the
12  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13  * sell copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  *
27  * $FreeBSD$
28  */
29 
30 #ifndef _MACHINE_X86_XEN_XEN_OS_H_
31 #define _MACHINE_X86_XEN_XEN_OS_H_
32 
33 #ifndef _XEN_XEN_OS_H_
34 #error "do not #include machine/xen/xen-os.h, #include xen/xen-os.h instead"
35 #endif
36 
37 /* Shared memory needs write-back as its cache attribute for coherency. */
38 #define VM_MEMATTR_XEN VM_MEMATTR_WRITE_BACK
39 
40 /* Everything below this point is not included by assembler (.S) files. */
41 #ifndef __ASSEMBLY__
42 
43 /* If non-zero, the hypervisor has been configured to use a direct vector */
44 extern int xen_vector_callback_enabled;
45 
46 /* tunable for disabling PV disks */
47 extern int xen_disable_pv_disks;
48 
49 /* tunable for disabling PV nics */
50 extern int xen_disable_pv_nics;
51 
52 static inline bool
53 xen_has_percpu_evtchn(void)
54 {
55 
56 	return (!xen_hvm_domain() || xen_vector_callback_enabled);
57 }
58 
59 static inline bool
60 xen_pv_shutdown_handler(void)
61 {
62 
63 	return (xen_pv_domain());
64 }
65 
66 static inline bool
67 xen_pv_disks_disabled(void)
68 {
69 
70 	return (xen_hvm_domain() && xen_disable_pv_disks != 0);
71 }
72 
73 static inline bool
74 xen_pv_nics_disabled(void)
75 {
76 
77 	return (xen_hvm_domain() && xen_disable_pv_nics != 0);
78 }
79 
80 #endif /* !__ASSEMBLY__ */
81 
82 #endif /* _MACHINE_X86_XEN_XEN_OS_H_ */
83