vm86.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #ifndef _LINUX_VM86_H
  2. #define _LINUX_VM86_H
  3. /*
  4. * I'm guessing at the VIF/VIP flag usage, but hope that this is how
  5. * the Pentium uses them. Linux will return from vm86 mode when both
  6. * VIF and VIP is set.
  7. *
  8. * On a Pentium, we could probably optimize the virtual flags directly
  9. * in the eflags register instead of doing it "by hand" in vflags...
  10. *
  11. * Linus
  12. */
  13. #define TF_MASK 0x00000100
  14. #define IF_MASK 0x00000200
  15. #define IOPL_MASK 0x00003000
  16. #define NT_MASK 0x00004000
  17. #ifdef CONFIG_VM86
  18. #define VM_MASK 0x00020000
  19. #else
  20. #define VM_MASK 0 /* ignored */
  21. #endif
  22. #define AC_MASK 0x00040000
  23. #define VIF_MASK 0x00080000 /* virtual interrupt flag */
  24. #define VIP_MASK 0x00100000 /* virtual interrupt pending */
  25. #define ID_MASK 0x00200000
  26. #define BIOSSEG 0x0f000
  27. #define CPU_086 0
  28. #define CPU_186 1
  29. #define CPU_286 2
  30. #define CPU_386 3
  31. #define CPU_486 4
  32. #define CPU_586 5
  33. /*
  34. * Return values for the 'vm86()' system call
  35. */
  36. #define VM86_TYPE(retval) ((retval) & 0xff)
  37. #define VM86_ARG(retval) ((retval) >> 8)
  38. #define VM86_SIGNAL 0 /* return due to signal */
  39. #define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */
  40. #define VM86_INTx 2 /* int3/int x instruction (ARG = x) */
  41. #define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */
  42. /*
  43. * Additional return values when invoking new vm86()
  44. */
  45. #define VM86_PICRETURN 4 /* return due to pending PIC request */
  46. #define VM86_TRAP 6 /* return due to DOS-debugger request */
  47. /*
  48. * function codes when invoking new vm86()
  49. */
  50. #define VM86_PLUS_INSTALL_CHECK 0
  51. #define VM86_ENTER 1
  52. #define VM86_ENTER_NO_BYPASS 2
  53. #define VM86_REQUEST_IRQ 3
  54. #define VM86_FREE_IRQ 4
  55. #define VM86_GET_IRQ_BITS 5
  56. #define VM86_GET_AND_RESET_IRQ 6
  57. /*
  58. * This is the stack-layout seen by the user space program when we have
  59. * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout
  60. * is 'kernel_vm86_regs' (see below).
  61. */
  62. struct vm86_regs {
  63. /*
  64. * normal regs, with special meaning for the segment descriptors..
  65. */
  66. long ebx;
  67. long ecx;
  68. long edx;
  69. long esi;
  70. long edi;
  71. long ebp;
  72. long eax;
  73. long __null_ds;
  74. long __null_es;
  75. long __null_fs;
  76. long __null_gs;
  77. long orig_eax;
  78. long eip;
  79. unsigned short cs, __csh;
  80. long eflags;
  81. long esp;
  82. unsigned short ss, __ssh;
  83. /*
  84. * these are specific to v86 mode:
  85. */
  86. unsigned short es, __esh;
  87. unsigned short ds, __dsh;
  88. unsigned short fs, __fsh;
  89. unsigned short gs, __gsh;
  90. };
  91. struct revectored_struct {
  92. unsigned long __map[8]; /* 256 bits */
  93. };
  94. struct vm86_struct {
  95. struct vm86_regs regs;
  96. unsigned long flags;
  97. unsigned long screen_bitmap;
  98. unsigned long cpu_type;
  99. struct revectored_struct int_revectored;
  100. struct revectored_struct int21_revectored;
  101. };
  102. /*
  103. * flags masks
  104. */
  105. #define VM86_SCREEN_BITMAP 0x0001
  106. struct vm86plus_info_struct {
  107. unsigned long force_return_for_pic:1;
  108. unsigned long vm86dbg_active:1; /* for debugger */
  109. unsigned long vm86dbg_TFpendig:1; /* for debugger */
  110. unsigned long unused:28;
  111. unsigned long is_vm86pus:1; /* for vm86 internal use */
  112. unsigned char vm86dbg_intxxtab[32]; /* for debugger */
  113. };
  114. struct vm86plus_struct {
  115. struct vm86_regs regs;
  116. unsigned long flags;
  117. unsigned long screen_bitmap;
  118. unsigned long cpu_type;
  119. struct revectored_struct int_revectored;
  120. struct revectored_struct int21_revectored;
  121. struct vm86plus_info_struct vm86plus;
  122. };
  123. #ifdef __KERNEL__
  124. /*
  125. * This is the (kernel) stack-layout when we have done a "SAVE_ALL" from vm86
  126. * mode - the main change is that the old segment descriptors aren't
  127. * useful any more and are forced to be zero by the kernel (and the
  128. * hardware when a trap occurs), and the real segment descriptors are
  129. * at the end of the structure. Look at ptrace.h to see the "normal"
  130. * setup. For user space layout see 'struct vm86_regs' above.
  131. */
  132. #include <asm/ptrace.h>
  133. struct kernel_vm86_regs {
  134. /*
  135. * normal regs, with special meaning for the segment descriptors..
  136. */
  137. struct pt_regs pt;
  138. /*
  139. * these are specific to v86 mode:
  140. */
  141. unsigned short es, __esh;
  142. unsigned short ds, __dsh;
  143. unsigned short fs, __fsh;
  144. unsigned short gs, __gsh;
  145. };
  146. struct kernel_vm86_struct {
  147. struct kernel_vm86_regs regs;
  148. /*
  149. * the below part remains on the kernel stack while we are in VM86 mode.
  150. * 'tss.esp0' then contains the address of VM86_TSS_ESP0 below, and when we
  151. * get forced back from VM86, the CPU and "SAVE_ALL" will restore the above
  152. * 'struct kernel_vm86_regs' with the then actual values.
  153. * Therefore, pt_regs in fact points to a complete 'kernel_vm86_struct'
  154. * in kernelspace, hence we need not reget the data from userspace.
  155. */
  156. #define VM86_TSS_ESP0 flags
  157. unsigned long flags;
  158. unsigned long screen_bitmap;
  159. unsigned long cpu_type;
  160. struct revectored_struct int_revectored;
  161. struct revectored_struct int21_revectored;
  162. struct vm86plus_info_struct vm86plus;
  163. struct pt_regs *regs32; /* here we save the pointer to the old regs */
  164. /*
  165. * The below is not part of the structure, but the stack layout continues
  166. * this way. In front of 'return-eip' may be some data, depending on
  167. * compilation, so we don't rely on this and save the pointer to 'oldregs'
  168. * in 'regs32' above.
  169. * However, with GCC-2.7.2 and the current CFLAGS you see exactly this:
  170. long return-eip; from call to vm86()
  171. struct pt_regs oldregs; user space registers as saved by syscall
  172. */
  173. };
  174. #ifdef CONFIG_VM86
  175. void handle_vm86_fault(struct kernel_vm86_regs *, long);
  176. int handle_vm86_trap(struct kernel_vm86_regs *, long, int);
  177. struct task_struct;
  178. void release_vm86_irqs(struct task_struct *);
  179. #else
  180. #define handle_vm86_fault(a, b)
  181. #define release_vm86_irqs(a)
  182. static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) {
  183. return 0;
  184. }
  185. #endif /* CONFIG_VM86 */
  186. #endif /* __KERNEL__ */
  187. #endif