home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / v86.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  12.9 KB  |  280 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_V86_H
  11. #define _SYS_V86_H
  12.  
  13. #ident    "@(#)/usr/include/sys/v86.h.sl 1.1 4.0 12/08/90 22147 AT&T-USL"
  14.  
  15. /*
  16.  * LIM 4.0 changes:
  17.  * Dual-Mode Floating Point support:
  18.  * Selectable OPcode emulation hook:
  19.  * Copyright (c) 1989 Phoenix Technologies Ltd.
  20.  * All Rights Reserved.
  21. */
  22.  
  23. #include    <sys/seg.h>
  24.  
  25. typedef    unsigned char    uchar;
  26.  
  27. #define NV86TASKS       20              /* Maximum number of V86 tasks  */
  28.  
  29. #define V86VIRTSIZE     0x0100  /* Size of virtual 8086 in pages ( 1M bytes)*/
  30. #define V86WRAPSIZE     0x0010  /* Size of copy/wrap in pages    (64K bytes)*/
  31. #define V86SIZE         0x0400  /* Max size of v86 segment       ( 4M bytes)*/
  32.  
  33. /*
  34.  * Definitions for Lotus/Intel/Microsoft Expanded Memory Emulation
  35. */
  36. #define V86EMM_PGSIZE       0x4000  /* Size of Expanded memory page         */
  37. #define V86EMM_LBASE    0x00200000  /* Expected lowest EMM logical page addr*/
  38. #define V86EMM_LENGTH   0x00200000  /* Expected size EMM logical pages      */
  39.  
  40. /*
  41.  * LIM 3 definitions -- for backward compatibility.
  42. */
  43. #define V86EMM_PBASE    0x000D0000  /* EMM physical page address            */
  44. #define V86EMM_PBASE0   0x000D0000  /* EMM physical page address            */
  45. #define V86EMM_PBASE1   0x000D4000  /* EMM physical page address            */
  46. #define V86EMM_PBASE2   0x000D8000  /* EMM physical page address            */
  47. #define V86EMM_PBASE3   0x000DC000  /* EMM physical page address            */
  48. #define V86EMM_NUMPGS    4        /* # LIM 3 EMM physical pages           */
  49.  
  50. /*
  51.  *  General definitions for a dual mode process
  52. */
  53.  
  54. #define XTSSADDR        ((caddr_t)0x110000L)    /* XTSS addr in user mem*/
  55. #define ARPL            0x63            /* ARPL inst, V86 invalid opcode*/
  56. #define V86_RCS         0xF000          /* Reset CS for V86 mode        */
  57. #define V86_RIP         0xFFF0          /* Reset IP for V86 mode        */
  58. #define V86_DELTA_NICE  10              /* Preferential nice for v86    */
  59. #define V86_TIMER_BOUND 10              /* Pending ticks limit for ECT  */
  60.  
  61. #define V86_SLICE       25              /* Default timeslice, >1 v86proc*/
  62. #define V86_SLICE_SHIFT 3               /* Max shift for time slice     */
  63.  
  64. #define    V86_PRI_NORM    0        /* Normal priority state    */
  65. #define    V86_PRI_LO    1        /* Low priority state, busywait    */
  66. #define    V86_PRI_HI    2        /* Hi priority state, pseudorupt*/
  67. #define V86_PRI_XHI     3               /* Extra high, urgent pseudorupt*/
  68. #define    V86_SHIFT_NORM    0        /* Timeslice shift for norm pri    */
  69. #define    V86_SHIFT_LO    V86_SLICE_SHIFT    /* Timeslice shift for lo   pri */
  70. #define    V86_SHIFT_HI    V86_SLICE_SHIFT    /* Timeslice shift for hi   pri */
  71.  
  72. /*  The maximum number of arguments that can be used for v86() system
  73. **  call is dependent on the maximum number of arguments allowed for
  74. **  the sysi86 call in sysent.c. Since the v86() system call is a sub-
  75. **  function (SI86V86) of the sysi86 call and v86() itself has sub-
  76. **  functions, the maximum arguments for each sub-function of the v86()
  77. **  system call is two less than the maximum allowed for the sysi86
  78. **  system call. The value defined here is assumed in the library.
  79. */
  80.  
  81. #define V86SC_MAXARGS   3               /* Includes sub-func # of v86() */
  82.  
  83. /*  SI86V86 is a sub system call of the system call "sysi86". The following
  84. **  definitions are sub system calls for SI86V86 and are processed in v86.c
  85. */
  86.  
  87. #define V86SC_INIT      1               /* v86init() system call        */
  88. #define V86SC_SLEEP     2               /* v86sleep() system call       */
  89. #define V86SC_MEMFUNC   3               /* v86memfunc() system call     */
  90. #define V86SC_IOPL      4               /* v86iopriv () system call     */
  91. /*
  92. **  The V86 timer has a frequency of 18.2 times a second. The Unix
  93. **  timer has a frequency of 100 times a second. So the following
  94. **  value ensures that the ECT gets an interrupt at least as often
  95. **  as it needs one.
  96. */
  97.  
  98. #define V86TIMER        5               /* Every 50 ms (20 times a second) */
  99.  
  100. /*  Software Interrupt mask bit array definitions
  101. */
  102.  
  103. #define V86_IMASKSIZE   256             /* Max number of software INTs  */
  104. #define V86_IMASKBITS   ((V86_IMASKSIZE + 31) / 32)
  105.                     /* # of bits for software INTs  */
  106.  
  107. /*  The offsets of members "xt_viflag", "xt_signo" and "xt_hdlr" are
  108. **  hard coded in the file "v86enter.s". So any changes to the struc-
  109. **  that changes these offsets have to be reflected in this file.
  110. **  This file is part of the ECT.
  111. **
  112. **  NOTE: The value of "xt_intr_pin" should be 0xFF or 0.
  113. */
  114.  
  115. typedef struct v86xtss
  116. {   struct tss386 xt_tss;               /* Normal TSS structure         */
  117.     unsigned int *xt_vflptr;        /* Ptr to 8086 virtual flags    */
  118.     unsigned char xt_magictrap;         /* Saved byte of virt intr      */
  119.     unsigned char xt_magicstat;         /* Status of magic byte         */
  120.     unsigned char xt_tslice_shft;       /* Time slice shift requested   */
  121.     unsigned char xt_intr_pin;          /* Interrupt to virtual machine */
  122.     time_t xt_lbolt;                    /* Lightning bolt value         */
  123.     unsigned int xt_viflag;             /* Virtual interrupt flag       */
  124.     unsigned int xt_vimask;             /* Mask for virtual interrupts  */
  125.     unsigned int xt_signo;              /* Sig number on V86VI_SIGHDL   */
  126.     int (* xt_hdlr)();                  /* Sig handler for V86VI_SIGHDL */
  127.     unsigned int xt_timer_count;        /* Number of pending timer ticks*/
  128.     unsigned int xt_timer_bound;        /* Ticks before forcing ECT in  */
  129.     uint xt_imaskbits[V86_IMASKBITS];   /* Bit map for software INTs    */
  130.     unsigned int xt_oldbitmap[32];      /* For I/O bitmap on old ECTs   */
  131.     unsigned char xt_magic[4];          /* XTSS version indicator       */
  132.     unsigned int xt_viurgent;           /* Mask for urgent interrupts   */
  133.     unsigned int xt_vitoect;            /* Mask for interrupts to ECT   */
  134.     ushort xt_vp_relcode;        /* VP/ix release code number    */
  135.     ushort xt_oemcode;            /* OEM code number              */
  136.     ushort xt_op_emul;            /* OPcode emulation enable mask */
  137.     ushort xt_rsvd0;            /* Reserved for future expansion*/
  138.     unsigned int xt_reserved[8];        /* Reserved for future expansion*/
  139. }   xtss_t;
  140.  
  141. /*
  142.  * VP/ix release code (refers to kernel,
  143.  * but non-driver based, supported functionality).
  144.  *
  145.  * 1 = D-M FP + LIM 4.0
  146.  * 2 = Ver.1 + OPcode emulation xtss hook.
  147.  *
  148.  * set into xt_vp_relcode in vx/v86.c:v86init()
  149. */
  150. #define    VP_RELCODE    2
  151.  
  152. /* OPcode emulation bit defines (one bit/OPcode). */
  153. #define EN_VTR        0x0001        /* CGA status port read */
  154.  
  155. /* DEFINE for CGA status emulation table (allocated in vx/space.c) */
  156. #define CS_MAX        32
  157.  
  158. /*  Definitions for the field "xt_magicstat". The location "xt_magictrap"
  159. **  is valid only when "xt_magicstat" field is set to XT_MSTAT_OPSAVED.
  160. */
  161.  
  162. #define XT_MSTAT_NOPROCESS      0       /* Do not process virtual intr  */
  163. #define XT_MSTAT_PROCESS        1       /* Process virtual intr         */
  164. #define XT_MSTAT_OPSAVED        2       /* v86 program opcode saved     */
  165. #define XT_MSTAT_POSTING        3       /* Phoenix defined              */
  166.  
  167. struct v86parm
  168. {   xtss_t   *xtssp;                    /* Ptr to XTSS in user data     */
  169.     unsigned long szxtss;               /* Length in bytes of XTSS      */
  170.     unsigned char magic[4];             /* XTSS version indicator       */
  171.     unsigned long szbitmap;             /* Length in bytes of I/O bitmap*/
  172. };
  173.  
  174. typedef struct v86memory
  175. {   int      vmem_cmd;                  /* Sub command for screen func  */
  176.     paddr_t  vmem_physaddr;             /* Physical memory base for map */
  177.     caddr_t  vmem_membase;              /* Screen memory base           */
  178.     int      vmem_memlen;               /* Length of screen memory      */
  179. } v86memory_t;
  180.  
  181. /*  Definitions for the field "vmem_cmd".
  182. */
  183.  
  184. #define V86MEM_MAP      1               /* Map virt addr to physical    */
  185. #define V86MEM_TRACK    2               /* Track memory modifications   */
  186. #define V86MEM_UNTRACK  3               /* Untrack memory modifications */
  187. #define V86MEM_UNMAP    4               /* Unmap virt addr              */
  188. #define V86MEM_EMM      5               /* LIM expanded memory emulation*/
  189. #define V86MEM_GROW     6               /* Grow Lim expanded memory     */
  190.  
  191. typedef struct v86dat
  192. {
  193.     proc_t  *vp_procp;                  /* Ptr to process's proc struc  */
  194.     sel_t    vp_oldtr;                  /* Old task register            */
  195.     unsigned short vp_szxtss;           /* Size of XTSS in user space   */
  196.     xtss_t  *vp_xtss;                   /* Address of nailed XTSS       */
  197.     v86memory_t vp_mem;                 /* Memory map/track definitions */
  198.     char     vp_wakeup;                 /* Wakeup process on virt intr  */
  199.     char     vp_slice_shft;             /* Last slice shift from xtss   */
  200.     char     vp_nice;                   /* Requested nice from sys call */
  201.     char     vp_hpnice;                 /* Nice value for high priority */
  202.     char     vp_new_nice;        /* New nice value from v86setint*/
  203.     char     vp_pri_state;        /* Priority state = hi,norm,lo    */
  204.                     /* Virtual86 task fp save area  */
  205.     uchar    vp_fpvalid;        /* Flag if saved state is valid */
  206.     uchar    vp_fpproc;            /* Which task used the floating */
  207.                     /* point last.                  */
  208.     union {
  209.         struct    vfpstate {        /* floating point extension state */
  210.             int    state[27];    /* 287/387 saved state */
  211.             int    status;        /* status word saved at exception */
  212.         } vp_fpstate;
  213.         struct    vfpemul {        /* FP emulator state */
  214.             char    fp_emul[246];    /* (extras for emulator) */
  215.             char    fp_epad[2];
  216.         } vp_fpemul;
  217.     } vp_fpu;
  218.     struct seg_desc    vp_xtss_desc;    /* Segment descriptor for xtss  */
  219. }   v86_t;
  220.  
  221. /*
  222.  * vp_fpvalid and vp_fpproc flag defines.
  223. */
  224. #define    V86FPV_NOTVALID    0x00        /* V86 fp save area is not valid */
  225. #define    V86FPV_VALID    0x01        /* V86 fp save area is valid */
  226. #define    V86FPP_V86LAST    0x01        /* V86 task last to use FPU */
  227. #define    V86FPP_ECTLAST    0x02        /* ECT task last to use FPU */
  228.  
  229. /*  Virtual interrupt bit definitions for the field "vp_viflag".
  230. **  The low order 16 bits reflect the setting of the AT hardware
  231. **  interrupts. The high order 16 bits are used for other inter-
  232. **  rupts.
  233. **
  234. **  NOTE: The value of V86VI_SIGHDL is hard coded in the file
  235. **  "v86enter.s". Any change to this value has to reflected in
  236. **  this file. This file is part of the ECT.
  237. */
  238.  
  239. #define V86VI_NONE      0x00000000      /* No interrupts                */
  240. #define V86VI_TIMER     0x00000001      /* Virtual timer interrupt      */
  241. #define V86VI_KBD       0x00000002      /* Scancode rcvd when buf empty */
  242. #define V86VI_SLAVE     0x00000004      /* Can be reused when needed    */
  243. #define V86VI_SERIAL1   0x00000008      /* Serial port 1 state change   */
  244. #define V86VI_SERIAL0   0x00000010      /* Serial port 0 state change   */
  245. #define V86VI_PRL1      0x00000020      /* Parallel port 1 state change */
  246. #define V86VI_MOUSE     0x00000020      /* Microsoft mouse              */
  247. #define V86VI_DISK      0x00000040      /* Fixed and floppy disk        */
  248. #define V86VI_PRL0      0x00000080      /* Parallel port 0 state change */
  249.  
  250. #define V86VI_RCLOCK    0x00000100      /* Realtime Clock interrupt     */
  251. #define V86VI_NET       0x00000200      /* Network interrupts           */
  252. #define V86VI_RSVD_1    0x00000400      /* Reserved 1                   */
  253. #define V86VI_RSVD_2    0x00000800      /* Reserved 2                   */
  254. #define V86VI_RSVD_3    0x00001000      /* Reserved 3                   */
  255. #define V86VI_COPROC    0x00002000      /* Coprocessor interrupt        */
  256. #define V86VI_FDISK     0x00004000      /* Fixed disk controller        */
  257. #define V86VI_RSVD_4    0x00008000      /* Reserved 4                   */
  258.  
  259. #define V86VI_DIV0      0x00010000      /* Divide by 0 (vector 0)       */
  260. #define V86VI_SGLSTP    0x00020000      /* Single step intr (vector 1)  */
  261. #define V86VI_BRKPT     0x00040000      /* Break point intr (vector 3)  */
  262. #define V86VI_OVERFLOW  0x00080000      /* Overflow fault (vector 4)    */
  263. #define V86VI_BOUND     0x00100000      /* Bound exception (vector 5)   */
  264. #define V86VI_INVOP     0x00200000      /* Invalid opcode (vector 6)    */
  265. #define V86VI_SIGHDL    0x00400000      /* Virtual signal hdlr interrupt*/
  266. #define V86VI_MEMORY    0x00800000      /* Tracking memory has changed  */
  267. #define V86VI_LBOLT     0x01000000      /* Lbolt value has changed      */
  268.  
  269. /* Virtual interrupt subcodes for V86VI_SERIAL[01] interrupts.  These values
  270. ** appear in  the fields "xt_s[01]flag".
  271. */
  272. #define V86SI_DATA      0x00000001      /* New data available from kbd  */
  273. #define V86SI_MODEM     0x00000002      /* Modem status line[s] changed */
  274.  
  275. #define V86_MAGIC0      'X'             /* Byte for XTSS magic[0]       */
  276. #define V86_MAGIC1      'T'             /* Byte for XTSS magic[1]       */
  277.  
  278. #endif    /*  _SYS_V86_H */
  279.  
  280.