aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-i386/vm86.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-i386/vm86.h')
-rw-r--r--include/asm-i386/vm86.h208
1 files changed, 208 insertions, 0 deletions
diff --git a/include/asm-i386/vm86.h b/include/asm-i386/vm86.h
new file mode 100644
index 000000000000..40ec82c6914d
--- /dev/null
+++ b/include/asm-i386/vm86.h
@@ -0,0 +1,208 @@
1#ifndef _LINUX_VM86_H
2#define _LINUX_VM86_H
3
4/*
5 * I'm guessing at the VIF/VIP flag usage, but hope that this is how
6 * the Pentium uses them. Linux will return from vm86 mode when both
7 * VIF and VIP is set.
8 *
9 * On a Pentium, we could probably optimize the virtual flags directly
10 * in the eflags register instead of doing it "by hand" in vflags...
11 *
12 * Linus
13 */
14
15#define TF_MASK 0x00000100
16#define IF_MASK 0x00000200
17#define IOPL_MASK 0x00003000
18#define NT_MASK 0x00004000
19#define VM_MASK 0x00020000
20#define AC_MASK 0x00040000
21#define VIF_MASK 0x00080000 /* virtual interrupt flag */
22#define VIP_MASK 0x00100000 /* virtual interrupt pending */
23#define ID_MASK 0x00200000
24
25#define BIOSSEG 0x0f000
26
27#define CPU_086 0
28#define CPU_186 1
29#define CPU_286 2
30#define CPU_386 3
31#define CPU_486 4
32#define CPU_586 5
33
34/*
35 * Return values for the 'vm86()' system call
36 */
37#define VM86_TYPE(retval) ((retval) & 0xff)
38#define VM86_ARG(retval) ((retval) >> 8)
39
40#define VM86_SIGNAL 0 /* return due to signal */
41#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */
42#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */
43#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */
44
45/*
46 * Additional return values when invoking new vm86()
47 */
48#define VM86_PICRETURN 4 /* return due to pending PIC request */
49#define VM86_TRAP 6 /* return due to DOS-debugger request */
50
51/*
52 * function codes when invoking new vm86()
53 */
54#define VM86_PLUS_INSTALL_CHECK 0
55#define VM86_ENTER 1
56#define VM86_ENTER_NO_BYPASS 2
57#define VM86_REQUEST_IRQ 3
58#define VM86_FREE_IRQ 4
59#define VM86_GET_IRQ_BITS 5
60#define VM86_GET_AND_RESET_IRQ 6
61
62/*
63 * This is the stack-layout seen by the user space program when we have
64 * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout
65 * is 'kernel_vm86_regs' (see below).
66 */
67
68struct vm86_regs {
69/*
70 * normal regs, with special meaning for the segment descriptors..
71 */
72 long ebx;
73 long ecx;
74 long edx;
75 long esi;
76 long edi;
77 long ebp;
78 long eax;
79 long __null_ds;
80 long __null_es;
81 long __null_fs;
82 long __null_gs;
83 long orig_eax;
84 long eip;
85 unsigned short cs, __csh;
86 long eflags;
87 long esp;
88 unsigned short ss, __ssh;
89/*
90 * these are specific to v86 mode:
91 */
92 unsigned short es, __esh;
93 unsigned short ds, __dsh;
94 unsigned short fs, __fsh;
95 unsigned short gs, __gsh;
96};
97
98struct revectored_struct {
99 unsigned long __map[8]; /* 256 bits */
100};
101
102struct vm86_struct {
103 struct vm86_regs regs;
104 unsigned long flags;
105 unsigned long screen_bitmap;
106 unsigned long cpu_type;
107 struct revectored_struct int_revectored;
108 struct revectored_struct int21_revectored;
109};
110
111/*
112 * flags masks
113 */
114#define VM86_SCREEN_BITMAP 0x0001
115
116struct vm86plus_info_struct {
117 unsigned long force_return_for_pic:1;
118 unsigned long vm86dbg_active:1; /* for debugger */
119 unsigned long vm86dbg_TFpendig:1; /* for debugger */
120 unsigned long unused:28;
121 unsigned long is_vm86pus:1; /* for vm86 internal use */
122 unsigned char vm86dbg_intxxtab[32]; /* for debugger */
123};
124
125struct vm86plus_struct {
126 struct vm86_regs regs;
127 unsigned long flags;
128 unsigned long screen_bitmap;
129 unsigned long cpu_type;
130 struct revectored_struct int_revectored;
131 struct revectored_struct int21_revectored;
132 struct vm86plus_info_struct vm86plus;
133};
134
135#ifdef __KERNEL__
136/*
137 * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86
138 * mode - the main change is that the old segment descriptors aren't
139 * useful any more and are forced to be zero by the kernel (and the
140 * hardware when a trap occurs), and the real segment descriptors are
141 * at the end of the structure. Look at ptrace.h to see the "normal"
142 * setup. For user space layout see 'struct vm86_regs' above.
143 */
144
145struct kernel_vm86_regs {
146/*
147 * normal regs, with special meaning for the segment descriptors..
148 */
149 long ebx;
150 long ecx;
151 long edx;
152 long esi;
153 long edi;
154 long ebp;
155 long eax;
156 long __null_ds;
157 long __null_es;
158 long orig_eax;
159 long eip;
160 unsigned short cs, __csh;
161 long eflags;
162 long esp;
163 unsigned short ss, __ssh;
164/*
165 * these are specific to v86 mode:
166 */
167 unsigned short es, __esh;
168 unsigned short ds, __dsh;
169 unsigned short fs, __fsh;
170 unsigned short gs, __gsh;
171};
172
173struct kernel_vm86_struct {
174 struct kernel_vm86_regs regs;
175/*
176 * the below part remains on the kernel stack while we are in VM86 mode.
177 * 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we
178 * get forced back from VM86, the CPU and "SAVE_ALL" will restore the above
179 * 'struct kernel_vm86_regs' with the then actual values.
180 * Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct'
181 * in kernelspace, hence we need not reget the data from userspace.
182 */
183#define VM86_TSS_ESP0 flags
184 unsigned long flags;
185 unsigned long screen_bitmap;
186 unsigned long cpu_type;
187 struct revectored_struct int_revectored;
188 struct revectored_struct int21_revectored;
189 struct vm86plus_info_struct vm86plus;
190 struct pt_regs *regs32; /* here we save the pointer to the old regs */
191/*
192 * The below is not part of the structure, but the stack layout continues
193 * this way. In front of 'return-eip' may be some data, depending on
194 * compilation, so we don't rely on this and save the pointer to 'oldregs'
195 * in 'regs32' above.
196 * However, with GCC-2.7.2 and the current CFLAGS you see exactly this:
197
198 long return-eip; from call to vm86()
199 struct pt_regs oldregs; user space registers as saved by syscall
200 */
201};
202
203void handle_vm86_fault(struct kernel_vm86_regs *, long);
204int handle_vm86_trap(struct kernel_vm86_regs *, long, int);
205
206#endif /* __KERNEL__ */
207
208#endif