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