xref: /linux/arch/x86/include/asm/vm86.h (revision af170c5061dd78512c469e6e2d211980cdb2c193)
11965aae3SH. Peter Anvin #ifndef _ASM_X86_VM86_H
21965aae3SH. Peter Anvin #define _ASM_X86_VM86_H
3bb898558SAl Viro 
4bb898558SAl Viro 
5bb898558SAl Viro #include <asm/ptrace.h>
6*af170c50SDavid Howells #include <uapi/asm/vm86.h>
7bb898558SAl Viro 
8bb898558SAl Viro /*
9bb898558SAl Viro  * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86
10bb898558SAl Viro  * mode - the main change is that the old segment descriptors aren't
11bb898558SAl Viro  * useful any more and are forced to be zero by the kernel (and the
12bb898558SAl Viro  * hardware when a trap occurs), and the real segment descriptors are
13bb898558SAl Viro  * at the end of the structure. Look at ptrace.h to see the "normal"
14bb898558SAl Viro  * setup. For user space layout see 'struct vm86_regs' above.
15bb898558SAl Viro  */
16bb898558SAl Viro 
17bb898558SAl Viro struct kernel_vm86_regs {
18bb898558SAl Viro /*
19bb898558SAl Viro  * normal regs, with special meaning for the segment descriptors..
20bb898558SAl Viro  */
21bb898558SAl Viro 	struct pt_regs pt;
22bb898558SAl Viro /*
23bb898558SAl Viro  * these are specific to v86 mode:
24bb898558SAl Viro  */
25bb898558SAl Viro 	unsigned short es, __esh;
26bb898558SAl Viro 	unsigned short ds, __dsh;
27bb898558SAl Viro 	unsigned short fs, __fsh;
28bb898558SAl Viro 	unsigned short gs, __gsh;
29bb898558SAl Viro };
30bb898558SAl Viro 
31bb898558SAl Viro struct kernel_vm86_struct {
32bb898558SAl Viro 	struct kernel_vm86_regs regs;
33bb898558SAl Viro /*
34bb898558SAl Viro  * the below part remains on the kernel stack while we are in VM86 mode.
35bb898558SAl Viro  * 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we
36bb898558SAl Viro  * get forced back from VM86, the CPU and "SAVE_ALL" will restore the above
37bb898558SAl Viro  * 'struct kernel_vm86_regs' with the then actual values.
38bb898558SAl Viro  * Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct'
39bb898558SAl Viro  * in kernelspace, hence we need not reget the data from userspace.
40bb898558SAl Viro  */
41bb898558SAl Viro #define VM86_TSS_ESP0 flags
42bb898558SAl Viro 	unsigned long flags;
43bb898558SAl Viro 	unsigned long screen_bitmap;
44bb898558SAl Viro 	unsigned long cpu_type;
45bb898558SAl Viro 	struct revectored_struct int_revectored;
46bb898558SAl Viro 	struct revectored_struct int21_revectored;
47bb898558SAl Viro 	struct vm86plus_info_struct vm86plus;
48bb898558SAl Viro 	struct pt_regs *regs32;   /* here we save the pointer to the old regs */
49bb898558SAl Viro /*
50bb898558SAl Viro  * The below is not part of the structure, but the stack layout continues
51bb898558SAl Viro  * this way. In front of 'return-eip' may be some data, depending on
52bb898558SAl Viro  * compilation, so we don't rely on this and save the pointer to 'oldregs'
53bb898558SAl Viro  * in 'regs32' above.
54bb898558SAl Viro  * However, with GCC-2.7.2 and the current CFLAGS you see exactly this:
55bb898558SAl Viro 
56bb898558SAl Viro 	long return-eip;        from call to vm86()
57bb898558SAl Viro 	struct pt_regs oldregs;  user space registers as saved by syscall
58bb898558SAl Viro  */
59bb898558SAl Viro };
60bb898558SAl Viro 
61bb898558SAl Viro #ifdef CONFIG_VM86
62bb898558SAl Viro 
63bb898558SAl Viro void handle_vm86_fault(struct kernel_vm86_regs *, long);
64bb898558SAl Viro int handle_vm86_trap(struct kernel_vm86_regs *, long, int);
65bb898558SAl Viro struct pt_regs *save_v86_state(struct kernel_vm86_regs *);
66bb898558SAl Viro 
67bb898558SAl Viro struct task_struct;
68bb898558SAl Viro void release_vm86_irqs(struct task_struct *);
69bb898558SAl Viro 
70bb898558SAl Viro #else
71bb898558SAl Viro 
72bb898558SAl Viro #define handle_vm86_fault(a, b)
73bb898558SAl Viro #define release_vm86_irqs(a)
74bb898558SAl Viro 
75bb898558SAl Viro static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)
76bb898558SAl Viro {
77bb898558SAl Viro 	return 0;
78bb898558SAl Viro }
79bb898558SAl Viro 
80bb898558SAl Viro #endif /* CONFIG_VM86 */
81bb898558SAl Viro 
821965aae3SH. Peter Anvin #endif /* _ASM_X86_VM86_H */
83