FreeBSD/Linux Kernel Cross Reference
sys/xen/hypervisor.h
1 /******************************************************************************
2 * hypervisor.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002, K A Fraser
7 *
8 * $FreeBSD$
9 */
10
11 #ifndef __XEN_HYPERVISOR_H__
12 #define __XEN_HYPERVISOR_H__
13
14 #include <sys/cdefs.h>
15 #include <sys/systm.h>
16 #include <contrib/xen/xen.h>
17 #include <contrib/xen/platform.h>
18 #include <contrib/xen/event_channel.h>
19 #include <contrib/xen/physdev.h>
20 #include <contrib/xen/sched.h>
21 #include <contrib/xen/callback.h>
22 #include <contrib/xen/memory.h>
23 #include <contrib/xen/hvm/dm_op.h>
24 #include <machine/xen/hypercall.h>
25
26 extern uint64_t get_system_time(int ticks);
27
28 static inline int
29 HYPERVISOR_console_write(const char *str, int count)
30 {
31 return HYPERVISOR_console_io(CONSOLEIO_write, count, str);
32 }
33
34 static inline int
35 HYPERVISOR_yield(void)
36 {
37 int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
38
39 #if CONFIG_XEN_COMPAT <= 0x030002
40 if (rc == -ENOXENSYS)
41 rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
42 #endif
43 return (rc);
44 }
45
46 static inline int
47 HYPERVISOR_block(
48 void)
49 {
50 int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
51
52 #if CONFIG_XEN_COMPAT <= 0x030002
53 if (rc == -ENOXENSYS)
54 rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
55 #endif
56 return (rc);
57 }
58
59 static inline void
60 HYPERVISOR_shutdown(unsigned int reason)
61 {
62 struct sched_shutdown sched_shutdown = {
63 .reason = reason
64 };
65
66 HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
67 #if CONFIG_XEN_COMPAT <= 0x030002
68 HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
69 #endif
70 }
71
72 static inline void
73 HYPERVISOR_crash(void)
74 {
75 HYPERVISOR_shutdown(SHUTDOWN_crash);
76 /* NEVER REACHED */
77 for (;;) ; /* eliminate noreturn error */
78 }
79
80 /* Transfer control to hypervisor until an event is detected on one */
81 /* of the specified ports or the specified number of ticks elapse */
82 static inline int
83 HYPERVISOR_poll(
84 evtchn_port_t *ports, unsigned int nr_ports, int ticks)
85 {
86 int rc;
87 struct sched_poll sched_poll = {
88 .nr_ports = nr_ports,
89 .timeout = get_system_time(ticks)
90 };
91 set_xen_guest_handle(sched_poll.ports, ports);
92
93 rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
94 #if CONFIG_XEN_COMPAT <= 0x030002
95 if (rc == -ENOXENSYS)
96 rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
97 #endif
98 return (rc);
99 }
100
101 #endif /* __XEN_HYPERVISOR_H__ */
Cache object: 5f05551435c9a7665972d6f51d7bace8
|