xref: /freebsd/lib/libvmmapi/internal.h (revision 9bc300465e48e19d794d88d0c158a2adb92c7197)
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;
20 	struct {
21 		vm_paddr_t base;
22 		vm_size_t size;
23 	} memsegs[VM_MEMSEG_COUNT];
24 	int	memflags;
25 	char	*baseaddr;
26 	char	*name;
27 };
28 
29 struct vcpu {
30 	struct vmctx *ctx;
31 	int vcpuid;
32 };
33 
34 int	vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg);
35 
36 extern const char *vm_capstrmap[];
37 
38 #define	VM_COMMON_IOCTLS	\
39 	VM_RUN,			\
40 	VM_SUSPEND,		\
41 	VM_REINIT,		\
42 	VM_ALLOC_MEMSEG,	\
43 	VM_GET_MEMSEG,		\
44 	VM_MMAP_MEMSEG,		\
45 	VM_MMAP_MEMSEG,		\
46 	VM_MMAP_GETNEXT,	\
47 	VM_MUNMAP_MEMSEG,	\
48 	VM_SET_REGISTER,	\
49 	VM_GET_REGISTER,	\
50 	VM_SET_REGISTER_SET,	\
51 	VM_GET_REGISTER_SET,	\
52 	VM_INJECT_EXCEPTION,	\
53 	VM_SET_CAPABILITY,	\
54 	VM_GET_CAPABILITY,	\
55 	VM_STATS,		\
56 	VM_STAT_DESC,		\
57 	VM_GLA2GPA_NOFAULT,	\
58 	VM_ACTIVATE_CPU,	\
59 	VM_GET_CPUS,		\
60 	VM_SUSPEND_CPU,		\
61 	VM_RESUME_CPU,		\
62 	VM_SET_TOPOLOGY,	\
63 	VM_GET_TOPOLOGY
64 
65 #define	VM_PPT_IOCTLS		\
66 	VM_BIND_PPTDEV,		\
67 	VM_UNBIND_PPTDEV,	\
68 	VM_MAP_PPTDEV_MMIO,	\
69 	VM_PPTDEV_MSI,		\
70 	VM_PPTDEV_MSIX,		\
71 	VM_UNMAP_PPTDEV_MMIO,	\
72 	VM_PPTDEV_DISABLE_MSIX
73 
74 extern const cap_ioctl_t vm_ioctl_cmds[];
75 extern size_t vm_ioctl_ncmds;
76 
77 #endif /* !__VMMAPI_INTERNAL_H__ */
78