xref: /freebsd/lib/libvmmapi/internal.h (revision 99127fd103624de593c7d1d885387e7d3667d73d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2022 John Baldwin <jhb@FreeBSD.org>
5  */
6 
7 #ifndef __VMMAPI_INTERNAL_H__
8 #define	__VMMAPI_INTERNAL_H__
9 
10 #include <sys/types.h>
11 
12 enum {
13 	VM_MEMSEG_LOW,
14 	VM_MEMSEG_HIGH,
15 	VM_MEMSEG_COUNT,
16 };
17 
18 struct vmctx {
19 	int	fd;		/* device file descriptor */
20 	int	ctlfd;		/* vmm control descriptor */
21 	struct {
22 		vm_paddr_t base;
23 		vm_size_t size;
24 	} memsegs[VM_MEMSEG_COUNT];
25 	int	memflags;
26 	char	*baseaddr;
27 	char	*name;
28 };
29 
30 struct vcpu {
31 	struct vmctx *ctx;
32 	int vcpuid;
33 };
34 
35 int	vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg);
36 
37 extern const char *vm_capstrmap[];
38 
39 #define	VM_COMMON_IOCTLS	\
40 	VM_RUN,			\
41 	VM_SUSPEND,		\
42 	VM_REINIT,		\
43 	VM_ALLOC_MEMSEG,	\
44 	VM_GET_MEMSEG,		\
45 	VM_MMAP_MEMSEG,		\
46 	VM_MMAP_MEMSEG,		\
47 	VM_MMAP_GETNEXT,	\
48 	VM_MUNMAP_MEMSEG,	\
49 	VM_SET_REGISTER,	\
50 	VM_GET_REGISTER,	\
51 	VM_SET_REGISTER_SET,	\
52 	VM_GET_REGISTER_SET,	\
53 	VM_INJECT_EXCEPTION,	\
54 	VM_SET_CAPABILITY,	\
55 	VM_GET_CAPABILITY,	\
56 	VM_STATS,		\
57 	VM_STAT_DESC,		\
58 	VM_GLA2GPA_NOFAULT,	\
59 	VM_ACTIVATE_CPU,	\
60 	VM_GET_CPUS,		\
61 	VM_SUSPEND_CPU,		\
62 	VM_RESUME_CPU,		\
63 	VM_SET_TOPOLOGY,	\
64 	VM_GET_TOPOLOGY
65 
66 #define	VM_PPT_IOCTLS		\
67 	VM_BIND_PPTDEV,		\
68 	VM_UNBIND_PPTDEV,	\
69 	VM_MAP_PPTDEV_MMIO,	\
70 	VM_PPTDEV_MSI,		\
71 	VM_PPTDEV_MSIX,		\
72 	VM_UNMAP_PPTDEV_MMIO,	\
73 	VM_PPTDEV_DISABLE_MSIX
74 
75 extern const cap_ioctl_t vm_ioctl_cmds[];
76 extern size_t vm_ioctl_ncmds;
77 
78 #endif /* !__VMMAPI_INTERNAL_H__ */
79