blob: 1e491f3af3178cc123da2ff70aabf97774bf726c [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
Vegard Nossum6330a302008-05-28 09:46:19 +02004#include <asm/ptrace.h>
David Howellsaf170c52012-12-14 22:37:13 +00005#include <uapi/asm/vm86.h>
Cyrill Gorcunov9831bfb2008-05-12 15:43:38 +02006
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/*
8 * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86
9 * mode - the main change is that the old segment descriptors aren't
10 * useful any more and are forced to be zero by the kernel (and the
11 * hardware when a trap occurs), and the real segment descriptors are
12 * at the end of the structure. Look at ptrace.h to see the "normal"
13 * setup. For user space layout see 'struct vm86_regs' above.
14 */
15
16struct kernel_vm86_regs {
17/*
18 * normal regs, with special meaning for the segment descriptors..
19 */
Jeremy Fitzhardinge49d26b62006-12-07 02:14:03 +010020 struct pt_regs pt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/*
22 * these are specific to v86 mode:
23 */
24 unsigned short es, __esh;
25 unsigned short ds, __dsh;
26 unsigned short fs, __fsh;
27 unsigned short gs, __gsh;
28};
29
Brian Gerst9fda6a02015-07-29 01:41:16 -040030struct vm86 {
Brian Gerst13426352015-07-29 01:41:22 -040031 struct vm86plus_struct __user *user_vm86;
Brian Gerst5ed92a82015-07-29 01:41:19 -040032 struct pt_regs regs32;
Brian Gerstdecd2752015-07-29 01:41:23 -040033 unsigned long veflags;
34 unsigned long veflags_mask;
Brian Gerst9fda6a02015-07-29 01:41:16 -040035 unsigned long saved_sp0;
Brian Gerstd4ce0f22015-07-29 01:41:17 -040036
37 unsigned long flags;
38 unsigned long screen_bitmap;
39 unsigned long cpu_type;
40 struct revectored_struct int_revectored;
41 struct revectored_struct int21_revectored;
42 struct vm86plus_info_struct vm86plus;
Brian Gerst9fda6a02015-07-29 01:41:16 -040043};
44
Matt Mackall64ca9002006-01-08 01:05:26 -080045#ifdef CONFIG_VM86
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047void handle_vm86_fault(struct kernel_vm86_regs *, long);
48int handle_vm86_trap(struct kernel_vm86_regs *, long, int);
Brian Gerst5ed92a82015-07-29 01:41:19 -040049void save_v86_state(struct kernel_vm86_regs *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Matt Mackall64ca9002006-01-08 01:05:26 -080051struct task_struct;
Matt Mackall64ca9002006-01-08 01:05:26 -080052
Brian Gerst9fda6a02015-07-29 01:41:16 -040053#define free_vm86(t) do { \
54 struct thread_struct *__t = (t); \
55 if (__t->vm86 != NULL) { \
56 kfree(__t->vm86); \
57 __t->vm86 = NULL; \
58 } \
59} while (0)
60
Ingo Molnaraf3e5652015-07-31 10:59:20 +020061/*
62 * Support for VM86 programs to request interrupts for
63 * real mode hardware drivers:
64 */
65#define FIRST_VM86_IRQ 3
66#define LAST_VM86_IRQ 15
67
68static inline int invalid_vm86_irq(int irq)
69{
70 return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ;
71}
72
73void release_vm86_irqs(struct task_struct *);
74
Matt Mackall64ca9002006-01-08 01:05:26 -080075#else
76
77#define handle_vm86_fault(a, b)
78#define release_vm86_irqs(a)
79
Joe Perches9e8a9352008-03-23 01:03:58 -070080static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)
81{
Matt Mackall64ca9002006-01-08 01:05:26 -080082 return 0;
83}
84
Brian Gerst5ed92a82015-07-29 01:41:19 -040085static inline void save_v86_state(struct kernel_vm86_regs *a, int b) { }
86
Brian Gerst9fda6a02015-07-29 01:41:16 -040087#define free_vm86(t) do { } while(0)
88
Matt Mackall64ca9002006-01-08 01:05:26 -080089#endif /* CONFIG_VM86 */
90
H. Peter Anvin1965aae2008-10-22 22:26:29 -070091#endif /* _ASM_X86_VM86_H */