H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_VM86_H |
| 2 | #define _ASM_X86_VM86_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
Vegard Nossum | 6330a30 | 2008-05-28 09:46:19 +0200 | [diff] [blame] | 4 | #include <asm/ptrace.h> |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame] | 5 | #include <uapi/asm/vm86.h> |
Cyrill Gorcunov | 9831bfb | 2008-05-12 15:43:38 +0200 | [diff] [blame] | 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | /* |
| 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 | |
| 16 | struct kernel_vm86_regs { |
| 17 | /* |
| 18 | * normal regs, with special meaning for the segment descriptors.. |
| 19 | */ |
Jeremy Fitzhardinge | 49d26b6 | 2006-12-07 02:14:03 +0100 | [diff] [blame] | 20 | struct pt_regs pt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | /* |
| 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 Gerst | 9fda6a0 | 2015-07-29 01:41:16 -0400 | [diff] [blame] | 30 | struct vm86 { |
Brian Gerst | 1342635 | 2015-07-29 01:41:22 -0400 | [diff] [blame] | 31 | struct vm86plus_struct __user *user_vm86; |
Brian Gerst | 5ed92a8 | 2015-07-29 01:41:19 -0400 | [diff] [blame] | 32 | struct pt_regs regs32; |
Brian Gerst | decd275 | 2015-07-29 01:41:23 -0400 | [diff] [blame] | 33 | unsigned long veflags; |
| 34 | unsigned long veflags_mask; |
Brian Gerst | 9fda6a0 | 2015-07-29 01:41:16 -0400 | [diff] [blame] | 35 | unsigned long saved_sp0; |
Brian Gerst | d4ce0f2 | 2015-07-29 01:41:17 -0400 | [diff] [blame] | 36 | |
| 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 Gerst | 9fda6a0 | 2015-07-29 01:41:16 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 45 | #ifdef CONFIG_VM86 |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | void handle_vm86_fault(struct kernel_vm86_regs *, long); |
| 48 | int handle_vm86_trap(struct kernel_vm86_regs *, long, int); |
Brian Gerst | 5ed92a8 | 2015-07-29 01:41:19 -0400 | [diff] [blame] | 49 | void save_v86_state(struct kernel_vm86_regs *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 51 | struct task_struct; |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 52 | |
Brian Gerst | 9fda6a0 | 2015-07-29 01:41:16 -0400 | [diff] [blame] | 53 | #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 Molnar | af3e565 | 2015-07-31 10:59:20 +0200 | [diff] [blame] | 61 | /* |
| 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 | |
| 68 | static inline int invalid_vm86_irq(int irq) |
| 69 | { |
| 70 | return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ; |
| 71 | } |
| 72 | |
| 73 | void release_vm86_irqs(struct task_struct *); |
| 74 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 75 | #else |
| 76 | |
| 77 | #define handle_vm86_fault(a, b) |
| 78 | #define release_vm86_irqs(a) |
| 79 | |
Joe Perches | 9e8a935 | 2008-03-23 01:03:58 -0700 | [diff] [blame] | 80 | static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) |
| 81 | { |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
Brian Gerst | 5ed92a8 | 2015-07-29 01:41:19 -0400 | [diff] [blame] | 85 | static inline void save_v86_state(struct kernel_vm86_regs *a, int b) { } |
| 86 | |
Brian Gerst | 9fda6a0 | 2015-07-29 01:41:16 -0400 | [diff] [blame] | 87 | #define free_vm86(t) do { } while(0) |
| 88 | |
Matt Mackall | 64ca900 | 2006-01-08 01:05:26 -0800 | [diff] [blame] | 89 | #endif /* CONFIG_VM86 */ |
| 90 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 91 | #endif /* _ASM_X86_VM86_H */ |