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 * This is the stack-layout when we have done a "SAVE_ALL" from vm86
47 * mode - the main change is that the old segment descriptors aren't
48 * useful any more and are forced to be zero by the kernel (and the
49 * hardware when a trap occurs), and the real segment descriptors are
50 * at the end of the structure. Look at ptrace.h to see the "normal"
51 * setup.
52 */
53
54 struct vm86_regs {
55 /*
56 * normal regs, with special meaning for the segment descriptors..
57 */
58 long ebx;
59 long ecx;
60 long edx;
61 long esi;
62 long edi;
63 long ebp;
64 long eax;
65 long __null_ds;
66 long __null_es;
67 long __null_fs;
68 long __null_gs;
69 long orig_eax;
70 long eip;
71 unsigned short cs, __csh;
72 long eflags;
73 long esp;
74 unsigned short ss, __ssh;
75 /*
76 * these are specific to v86 mode:
77 */
78 unsigned short es, __esh;
79 unsigned short ds, __dsh;
80 unsigned short fs, __fsh;
81 unsigned short gs, __gsh;
82 };
83
84 struct revectored_struct {
85 unsigned long __map[8]; /* 256 bits */
86 };
87
88 struct vm86_struct {
89 struct vm86_regs regs;
90 unsigned long flags;
91 unsigned long screen_bitmap;
92 unsigned long cpu_type;
93 struct revectored_struct int_revectored;
94 struct revectored_struct int21_revectored;
95 };
96
97 /*
98 * flags masks
99 */
100 #define VM86_SCREEN_BITMAP 0x0001
101
102 #ifdef __KERNEL__
103
104 void handle_vm86_fault(struct vm86_regs *, long);
105 void handle_vm86_debug(struct vm86_regs *, long);
106
107 #endif
108
109 #endif