blob: 1d8de3f3fecade2fc63bdab01582f566aa1d47d5 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_VM86_H
2#define _ASM_X86_VM86_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
Cyrill Gorcunov9831bfb2008-05-12 15:43:38 +02004
Vegard Nossum6330a302008-05-28 09:46:19 +02005#include <asm/ptrace.h>
David Howellsaf170c52012-12-14 22:37:13 +00006#include <uapi/asm/vm86.h>
Cyrill Gorcunov9831bfb2008-05-12 15:43:38 +02007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008/*
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
17struct kernel_vm86_regs {
18/*
19 * normal regs, with special meaning for the segment descriptors..
20 */
Jeremy Fitzhardinge49d26b62006-12-07 02:14:03 +010021 struct pt_regs pt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/*
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
31struct 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
Matt Mackall64ca9002006-01-08 01:05:26 -080061#ifdef CONFIG_VM86
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063void handle_vm86_fault(struct kernel_vm86_regs *, long);
64int handle_vm86_trap(struct kernel_vm86_regs *, long, int);
Harvey Harrisone04f99c2008-02-04 16:48:04 +010065struct pt_regs *save_v86_state(struct kernel_vm86_regs *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Matt Mackall64ca9002006-01-08 01:05:26 -080067struct task_struct;
68void release_vm86_irqs(struct task_struct *);
69
70#else
71
72#define handle_vm86_fault(a, b)
73#define release_vm86_irqs(a)
74
Joe Perches9e8a9352008-03-23 01:03:58 -070075static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)
76{
Matt Mackall64ca9002006-01-08 01:05:26 -080077 return 0;
78}
79
80#endif /* CONFIG_VM86 */
81
H. Peter Anvin1965aae2008-10-22 22:26:29 -070082#endif /* _ASM_X86_VM86_H */