1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2011 NetApp, Inc. 5 * Copyright (C) 2015 Mihai Carabas <mihai.carabas@gmail.com> 6 * All rights reserved. 7 */ 8 9 #ifndef _DEV_VMM_DEV_H_ 10 #define _DEV_VMM_DEV_H_ 11 12 #include <sys/types.h> 13 #include <sys/ioccom.h> 14 #include <machine/vmm_dev.h> 15 16 #ifdef _KERNEL 17 struct thread; 18 struct vm; 19 struct vcpu; 20 21 int vmmdev_init(void); 22 int vmmdev_cleanup(void); 23 int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd, 24 caddr_t data, int fflag, struct thread *td); 25 26 /* 27 * Entry in an ioctl handler table. A number of generic ioctls are defined, 28 * plus a table of machine-dependent ioctls. The flags indicate the 29 * required preconditions for a given ioctl. 30 * 31 * Some ioctls encode a vcpuid as the first member of their ioctl structure. 32 * These ioctls must specify one of the following flags: 33 * - ALLOC_VCPU: create the vCPU if it does not already exist 34 * - LOCK_ONE_VCPU: create the vCPU if it does not already exist 35 * and lock the vCPU for the duration of the ioctl 36 * - MAYBE_ALLOC_VCPU: if the vcpuid is -1, do nothing, otherwise 37 * create the vCPU if it does not already exist 38 */ 39 struct vmmdev_ioctl { 40 unsigned long cmd; 41 #define VMMDEV_IOCTL_SLOCK_MEMSEGS 0x01 42 #define VMMDEV_IOCTL_XLOCK_MEMSEGS 0x02 43 #define VMMDEV_IOCTL_LOCK_ONE_VCPU 0x04 44 #define VMMDEV_IOCTL_LOCK_ALL_VCPUS 0x08 45 #define VMMDEV_IOCTL_ALLOC_VCPU 0x10 46 #define VMMDEV_IOCTL_MAYBE_ALLOC_VCPU 0x20 47 int flags; 48 }; 49 50 #define VMMDEV_IOCTL(_cmd, _flags) { .cmd = (_cmd), .flags = (_flags) } 51 52 extern const struct vmmdev_ioctl vmmdev_machdep_ioctls[]; 53 extern const size_t vmmdev_machdep_ioctl_count; 54 55 #endif /* _KERNEL */ 56 57 struct vmmctl_vm_create { 58 char name[VM_MAX_NAMELEN + 1]; 59 int reserved[16]; 60 }; 61 62 struct vmmctl_vm_destroy { 63 char name[VM_MAX_NAMELEN + 1]; 64 int reserved[16]; 65 }; 66 67 #define VMMCTL_VM_CREATE _IOWR('V', 0, struct vmmctl_vm_create) 68 #define VMMCTL_VM_DESTROY _IOWR('V', 1, struct vmmctl_vm_destroy) 69 70 #endif /* _DEV_VMM_DEV_H_ */ 71