1 /******************************************************************************
4 * Linux-specific hypervisor handling.
6 * Copyright (c) 2002, K A Fraser
11 #ifndef __XEN_HYPERVISOR_H__
12 #define __XEN_HYPERVISOR_H__
14 #include <sys/cdefs.h>
15 #include <sys/systm.h>
16 #include <xen/interface/xen.h>
17 #include <xen/interface/platform.h>
18 #include <xen/interface/event_channel.h>
19 #include <xen/interface/physdev.h>
20 #include <xen/interface/sched.h>
21 #include <xen/interface/callback.h>
22 #include <xen/interface/memory.h>
23 #include <machine/xen/hypercall.h>
25 extern uint64_t get_system_time(int ticks);
28 HYPERVISOR_console_write(const char *str, int count)
30 return HYPERVISOR_console_io(CONSOLEIO_write, count, str);
34 HYPERVISOR_yield(void)
36 int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
38 #if CONFIG_XEN_COMPAT <= 0x030002
40 rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
49 int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
51 #if CONFIG_XEN_COMPAT <= 0x030002
53 rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
60 HYPERVISOR_shutdown(unsigned int reason)
62 struct sched_shutdown sched_shutdown = {
66 HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
67 #if CONFIG_XEN_COMPAT <= 0x030002
68 HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
73 HYPERVISOR_crash(void)
75 HYPERVISOR_shutdown(SHUTDOWN_crash);
77 for (;;) ; /* eliminate noreturn error */
80 /* Transfer control to hypervisor until an event is detected on one */
81 /* of the specified ports or the specified number of ticks elapse */
84 evtchn_port_t *ports, unsigned int nr_ports, int ticks)
87 struct sched_poll sched_poll = {
89 .timeout = get_system_time(ticks)
91 set_xen_guest_handle(sched_poll.ports, ports);
93 rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
94 #if CONFIG_XEN_COMPAT <= 0x030002
96 rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
101 #endif /* __XEN_HYPERVISOR_H__ */