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