1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-01 08:27:59 +00:00
freebsd/sys/xen/hypervisor.h
Elliott Mitchell ad7dd51499 xen: switch to use headers in contrib
These headers originate with the Xen project and shouldn't be mixed with
the main portion of the FreeBSD kernel. Notably they shouldn't be the
target of clean-up commits.

Switch to use the headers in sys/contrib/xen.

Reviewed by: royger
2022-02-07 10:11:56 +01:00

102 lines
2.3 KiB
C

/******************************************************************************
* hypervisor.h
*
* Linux-specific hypervisor handling.
*
* Copyright (c) 2002, K A Fraser
*
* $FreeBSD$
*/
#ifndef __XEN_HYPERVISOR_H__
#define __XEN_HYPERVISOR_H__
#include <sys/cdefs.h>
#include <sys/systm.h>
#include <contrib/xen/xen.h>
#include <contrib/xen/platform.h>
#include <contrib/xen/event_channel.h>
#include <contrib/xen/physdev.h>
#include <contrib/xen/sched.h>
#include <contrib/xen/callback.h>
#include <contrib/xen/memory.h>
#include <contrib/xen/hvm/dm_op.h>
#include <machine/xen/hypercall.h>
extern uint64_t get_system_time(int ticks);
static inline int
HYPERVISOR_console_write(const char *str, int count)
{
return HYPERVISOR_console_io(CONSOLEIO_write, count, str);
}
static inline int
HYPERVISOR_yield(void)
{
int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
#if CONFIG_XEN_COMPAT <= 0x030002
if (rc == -ENOXENSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
#endif
return (rc);
}
static inline int
HYPERVISOR_block(
void)
{
int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
#if CONFIG_XEN_COMPAT <= 0x030002
if (rc == -ENOXENSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
#endif
return (rc);
}
static inline void
HYPERVISOR_shutdown(unsigned int reason)
{
struct sched_shutdown sched_shutdown = {
.reason = reason
};
HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
#if CONFIG_XEN_COMPAT <= 0x030002
HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
#endif
}
static inline void
HYPERVISOR_crash(void)
{
HYPERVISOR_shutdown(SHUTDOWN_crash);
/* NEVER REACHED */
for (;;) ; /* eliminate noreturn error */
}
/* Transfer control to hypervisor until an event is detected on one */
/* of the specified ports or the specified number of ticks elapse */
static inline int
HYPERVISOR_poll(
evtchn_port_t *ports, unsigned int nr_ports, int ticks)
{
int rc;
struct sched_poll sched_poll = {
.nr_ports = nr_ports,
.timeout = get_system_time(ticks)
};
set_xen_guest_handle(sched_poll.ports, ports);
rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
#if CONFIG_XEN_COMPAT <= 0x030002
if (rc == -ENOXENSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
#endif
return (rc);
}
#endif /* __XEN_HYPERVISOR_H__ */