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