1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 1997 Jonathan Lemon 5 * All rights reserved. 6 * 7 * Derived from register.h, which is 8 * Copyright (c) 1996 Michael Smith. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * 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 AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $FreeBSD$ 32 */ 33 34 #ifndef _MACHINE_VM86_H_ 35 #define _MACHINE_VM86_H_ 1 36 37 /* standard register representation */ 38 typedef union { 39 u_int r_ex; 40 struct { 41 u_short r_x; 42 u_int :16; 43 } r_w; 44 struct { 45 u_char r_l; 46 u_char r_h; 47 u_int :16; 48 } r_b; 49 } reg86_t; 50 51 /* layout must match definition of struct trapframe_vm86 in <machine/frame.h> */ 52 53 struct vm86frame { 54 int kernel_fs; 55 int kernel_es; 56 int kernel_ds; 57 reg86_t edi; 58 reg86_t esi; 59 reg86_t ebp; 60 reg86_t isp; 61 reg86_t ebx; 62 reg86_t edx; 63 reg86_t ecx; 64 reg86_t eax; 65 int vmf_trapno; 66 int vmf_err; 67 reg86_t eip; 68 reg86_t cs; 69 reg86_t eflags; 70 reg86_t esp; 71 reg86_t ss; 72 reg86_t es; 73 reg86_t ds; 74 reg86_t fs; 75 reg86_t gs; 76 #define vmf_ah eax.r_b.r_h 77 #define vmf_al eax.r_b.r_l 78 #define vmf_ax eax.r_w.r_x 79 #define vmf_eax eax.r_ex 80 #define vmf_bh ebx.r_b.r_h 81 #define vmf_bl ebx.r_b.r_l 82 #define vmf_bx ebx.r_w.r_x 83 #define vmf_ebx ebx.r_ex 84 #define vmf_ch ecx.r_b.r_h 85 #define vmf_cl ecx.r_b.r_l 86 #define vmf_cx ecx.r_w.r_x 87 #define vmf_ecx ecx.r_ex 88 #define vmf_dh edx.r_b.r_h 89 #define vmf_dl edx.r_b.r_l 90 #define vmf_dx edx.r_w.r_x 91 #define vmf_edx edx.r_ex 92 #define vmf_si esi.r_w.r_x 93 #define vmf_di edi.r_w.r_x 94 #define vmf_cs cs.r_w.r_x 95 #define vmf_ds ds.r_w.r_x 96 #define vmf_es es.r_w.r_x 97 #define vmf_ss ss.r_w.r_x 98 #define vmf_bp ebp.r_w.r_x 99 #define vmf_sp esp.r_w.r_x 100 #define vmf_ip eip.r_w.r_x 101 #define vmf_flags eflags.r_w.r_x 102 #define vmf_eflags eflags.r_ex 103 }; 104 105 #define VM86_PMAPSIZE 24 106 #define VMAP_MALLOC 1 /* page was malloced by us */ 107 108 struct vm86context { 109 int npages; 110 struct vm86pmap { 111 int flags; 112 int pte_num; 113 vm_offset_t kva; 114 u_int old_pte; 115 } pmap[VM86_PMAPSIZE]; 116 }; 117 118 #define VM_USERCHANGE (PSL_USERCHANGE) 119 #define VME_USERCHANGE (VM_USERCHANGE | PSL_VIP | PSL_VIF) 120 121 struct vm86_kernel { 122 caddr_t vm86_intmap; /* interrupt map */ 123 u_int vm86_eflags; /* emulated flags */ 124 int vm86_has_vme; /* VME support */ 125 int vm86_inited; /* we were initialized */ 126 int vm86_debug; 127 caddr_t vm86_sproc; /* address of sproc */ 128 }; 129 130 #define VM86_INIT 1 131 #define VM86_SET_VME 2 132 #define VM86_GET_VME 3 133 #define VM86_INTCALL 4 134 135 struct vm86_init_args { 136 int debug; /* debug flag */ 137 int cpu_type; /* cpu type to emulate */ 138 u_char int_map[32]; /* interrupt map */ 139 }; 140 141 struct vm86_vme_args { 142 int state; /* status */ 143 }; 144 145 struct vm86_intcall_args { 146 int intnum; 147 struct vm86frame vmf; 148 }; 149 150 #ifdef _KERNEL 151 extern int vm86paddr; 152 153 struct thread; 154 extern int vm86_emulate(struct vm86frame *); 155 extern int vm86_sysarch(struct thread *, char *); 156 extern void vm86_trap(struct vm86frame *); 157 extern int vm86_intcall(int, struct vm86frame *); 158 extern int vm86_datacall(int, struct vm86frame *, struct vm86context *); 159 extern void vm86_initialize(void); 160 extern vm_offset_t vm86_getpage(struct vm86context *, int); 161 extern vm_offset_t vm86_addpage(struct vm86context *, int, vm_offset_t); 162 extern int vm86_getptr(struct vm86context *, vm_offset_t, u_short *, u_short *); 163 164 extern vm_offset_t vm86_getaddr(struct vm86context *, u_short, u_short); 165 #endif /* _KERNEL */ 166 167 #endif /* _MACHINE_VM86_H_ */ 168