vm86.h 5.5 KB

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