2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
24 #include <xen/xen-os.h>
25 #include <xen/hypervisor.h>
27 #include <xen/interface/hvm/params.h>
30 * \brief Wrapper function to obtain a HVM parameter value.
32 * \param index HVM parameter index; see <xen/interface/hvm/params.h>.
34 * \returns 0 on failure; the value of the parameter otherwise.
36 static inline unsigned long
37 hvm_get_parameter(int index)
39 struct xen_hvm_param xhv;
42 xhv.domid = DOMID_SELF;
44 error = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
46 printf("%s: error %d trying to get %d\n", __func__,
53 /** The callback method types for Hypervisor event delivery to our domain. */
58 HVM_CB_TYPE_MASK = 0xFF,
59 HVM_CB_TYPE_SHIFT = 56
62 /** Format for specifying a GSI type callback. */
64 HVM_CB_GSI_GSI_MASK = 0xFFFFFFFF,
65 HVM_CB_GSI_GSI_SHIFT = 0
67 #define HVM_CALLBACK_GSI(gsi) \
68 (((uint64_t)HVM_CB_TYPE_GSI << HVM_CB_TYPE_SHIFT) \
69 | ((gsi) & HVM_CB_GSI_GSI_MASK) << HVM_CB_GSI_GSI_SHIFT)
71 /** Format for specifying a virtual PCI interrupt line GSI style callback. */
73 HVM_CB_PCI_INTX_INTPIN_MASK = 0x3,
74 HVM_CB_PCI_INTX_INTPIN_SHIFT = 0,
75 HVM_CB_PCI_INTX_SLOT_MASK = 0x1F,
76 HVM_CB_PCI_INTX_SLOT_SHIFT = 11,
78 #define HVM_CALLBACK_PCI_INTX(slot, pin) \
79 (((uint64_t)HVM_CB_TYPE_PCI_INTX << HVM_CB_TYPE_SHIFT) \
80 | (((slot) & HVM_CB_PCI_INTX_SLOT_MASK) << HVM_CB_PCI_INTX_SLOT_SHIFT) \
81 | (((pin) & HVM_CB_PCI_INTX_INTPIN_MASK) << HVM_CB_PCI_INTX_INTPIN_SHIFT))
83 /** Format for specifying a direct IDT vector injection style callback. */
85 HVM_CB_VECTOR_VECTOR_MASK = 0xFFFFFFFF,
86 HVM_CB_VECTOR_VECTOR_SHIFT = 0
88 #define HVM_CALLBACK_VECTOR(vector) \
89 (((uint64_t)HVM_CB_TYPE_VECTOR << HVM_CB_TYPE_SHIFT) \
90 | (((vector) & HVM_CB_GSI_GSI_MASK) << HVM_CB_GSI_GSI_SHIFT))
92 enum xen_hvm_init_type {
95 XEN_HVM_INIT_CANCELLED_SUSPEND,
99 int xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type);
100 void xen_hvm_set_callback(device_t);
101 void xen_hvm_suspend(void);
102 void xen_hvm_resume(bool suspend_cancelled);
104 extern uint32_t hvm_start_flags;
105 extern bool xen_evtchn_needs_ack;
107 #endif /* __XEN_HVM_H__ */