|
| 1 | +/* |
| 2 | + * Copyright (c) 2011 Intel Corporation |
| 3 | + * Copyright (c) 2018 Kamil Rytarowski |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * |
| 8 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | + * this list of conditions and the following disclaimer. |
| 10 | + * |
| 11 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | + * notice, this list of conditions and the following disclaimer in the |
| 13 | + * documentation and/or other materials provided with the distribution. |
| 14 | + * |
| 15 | + * 3. Neither the name of the copyright holder nor the names of its |
| 16 | + * contributors may be used to endorse or promote products derived from |
| 17 | + * this software without specific prior written permission. |
| 18 | + * |
| 19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | + * POSSIBILITY OF SUCH DAMAGE. |
| 30 | + */ |
| 31 | + |
| 32 | +#ifndef HAX_NETBSD_HAX_INTERFACE_NETBSD_H_ |
| 33 | +#define HAX_NETBSD_HAX_INTERFACE_NETBSD_H_ |
| 34 | + |
| 35 | +#include <sys/param.h> |
| 36 | +#include <sys/types.h> |
| 37 | +#include <sys/ioctl.h> |
| 38 | +#include <sys/ioccom.h> |
| 39 | + |
| 40 | +/* The mac specific interface to qemu because of mac's |
| 41 | + * special handling like hax tunnel allocation etc */ |
| 42 | +/* HAX model level ioctl */ |
| 43 | +#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version) |
| 44 | +#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, uint32_t) |
| 45 | +#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, uint32_t) |
| 46 | +#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo) |
| 47 | +#define HAX_IOCTL_SET_MEMLIMIT _IOWR(0, 0x24, struct hax_set_memlimit) |
| 48 | + |
| 49 | +// Only for backward compatibility with old Qemu. |
| 50 | +#define HAX_VM_IOCTL_VCPU_CREATE_ORIG _IOR(0, 0x80, int) |
| 51 | + |
| 52 | +#define HAX_VM_IOCTL_VCPU_CREATE _IOWR(0, 0x80, uint32_t) |
| 53 | +#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info) |
| 54 | +#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info) |
| 55 | +#define HAX_VM_IOCTL_VCPU_DESTROY _IOR(0, 0x83, uint32_t) |
| 56 | +#define HAX_VM_IOCTL_ADD_RAMBLOCK _IOW(0, 0x85, struct hax_ramblock_info) |
| 57 | +#define HAX_VM_IOCTL_SET_RAM2 _IOWR(0, 0x86, struct hax_set_ram_info2) |
| 58 | +#define HAX_VM_IOCTL_PROTECT_RAM _IOWR(0, 0x87, struct hax_protect_ram_info) |
| 59 | + |
| 60 | +#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0) |
| 61 | +#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data) |
| 62 | +#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data) |
| 63 | + |
| 64 | +#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout) |
| 65 | +#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout) |
| 66 | + |
| 67 | +#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info) |
| 68 | +#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t) |
| 69 | +#define HAX_VCPU_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t) |
| 70 | +#define HAX_VCPU_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t) |
| 71 | + |
| 72 | +/* API 2.0 */ |
| 73 | +#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version) |
| 74 | + |
| 75 | +#define HAX_IOCTL_VCPU_DEBUG _IOW(0, 0xc9, struct hax_debug_t) |
| 76 | + |
| 77 | +#define HAX_KERNEL64_CS 0x80 |
| 78 | +#define HAX_KERNEL32_CS 0x08 |
| 79 | + |
| 80 | +#define is_compatible() 0 |
| 81 | + |
| 82 | +struct hax_vm_netbsd_t; |
| 83 | + |
| 84 | +struct hax_vm_softc { |
| 85 | + device_t sc_dev; |
| 86 | + struct hax_vm_netbsd_t *vm; |
| 87 | +}; |
| 88 | + |
| 89 | +struct hax_vcpu_netbsd_t; |
| 90 | + |
| 91 | +struct hax_vcpu_softc { |
| 92 | + device_t sc_dev; |
| 93 | + struct hax_vcpu_netbsd_t *vcpu; |
| 94 | +}; |
| 95 | + |
| 96 | +#define HAX_MAX_VMS 8 |
| 97 | + |
| 98 | +struct vm_t; |
| 99 | + |
| 100 | +typedef struct hax_vm_netbsd_t { |
| 101 | + struct vm_t *cvm; |
| 102 | + int id; |
| 103 | +} hax_vm_netbsd_t; |
| 104 | + |
| 105 | +struct vcpu_t; |
| 106 | + |
| 107 | +typedef struct hax_vcpu_netbsd_t { |
| 108 | + struct vcpu_t *cvcpu; |
| 109 | + struct hax_vm_netbsd_t *vm; |
| 110 | + int id; |
| 111 | +} hax_vcpu_netbsd_t; |
| 112 | + |
| 113 | +#define unit2vmmid(u) (__SHIFTOUT(u, __BITS(4,6))) |
| 114 | +#define unit2vcpuid(u) (__SHIFTOUT(u, __BITS(0,3))) |
| 115 | + |
| 116 | +#endif // HAX_NETBSD_HAX_INTERFACE_NETBSD_H_ |
0 commit comments