home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / v86.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-24  |  10.3 KB  |  221 lines

  1. /*
  2.  *    @(#) v86.h 1.3 88/06/24 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  *
  10.  *     NOTE: This file is part of the ECT.
  11.  */
  12.  
  13. /*
  14.  *  Move the following definition to proc.h stat code definitions
  15.  */
  16.  
  17. #define NV86TASKS       20              /* Maximum number of V86 tasks  */
  18.  
  19. #define V86VIRTSIZE     0x0100  /* Size of virtual 8086 in pages ( 1M bytes)*/
  20. #define V86WRAPSIZE     0x0010  /* Size of copy/wrap in pages    (64K bytes)*/
  21. #define V86XTSSSIZE     0x0010  /* Size of Xtss in pages         (64K bytes)*/
  22. #define V86SIZE         0x0400  /* Size of v86 region            ( 4M bytes)*/
  23.  
  24. /*
  25.  * Definitions for Lotus/Intel/Microsoft Expanded Memory Emulation
  26.  */
  27.  
  28. #define V86EMM_PGSIZE       0x4000  /* Size of Expanded memory page         */
  29. #define V86EMM_LBASE    0x00200000  /* Expected lowest EMM logical page addr*/
  30. #define V86EMM_LENGTH   0x00200000  /* Expected size EMM logical pages      */
  31. #define V86EMM_PBASE    0x000D0000  /* EMM physical page address            */
  32. #define V86EMM_PBASE0   0x000D0000  /* EMM physical page address            */
  33. #define V86EMM_PBASE1   0x000D4000  /* EMM physical page address            */
  34. #define V86EMM_PBASE2   0x000D8000  /* EMM physical page address            */
  35. #define V86EMM_PBASE3   0x000DC000  /* EMM physical page address            */
  36. #define V86EMM_NUMPGS            4  /* Number of EMM physical pages         */
  37.  
  38. /*  
  39.  * General definitions for a dual mode process
  40.  */
  41.  
  42. #define XTSSADDR        ((caddr_t)0x110000L)    /* XTSS addr in user mem*/
  43. #define ARPL            0x63            /* ARPL inst, V86 invalid opcode*/
  44. #define V86_RCS         0xF000          /* Reset CS for V86 mode        */
  45. #define V86_RIP         0xFFF0          /* Reset IP for V86 mode        */
  46. #define V86_SLICE       20              /* Default time slice           */
  47. #define V86_SLICE_SHIFT 4               /* Max shift for time slice     */
  48. #define V86_SHIFT_PAT   0x78            /* Pattern for v86 slice shift  */
  49. #define V86_DELTA_NICE  10              /* Preferential nice for v86    */
  50. #define V86_TIMER_BOUND 10              /* Pending ticks limit for ECT  */
  51.  
  52. /*  
  53.  *  The maximum number of arguments that can be used for v86() system
  54.  *  call is dependent on the maximum number of arguments allowed for
  55.  *  the sysi86 call in sysent.c. Since the v86() system call is a sub-
  56.  *  function (SI86V86) of the sysi86 call and v86() itself has sub-
  57.  *  functions, the maximum arguments for each sub-function of the v86()
  58.  *  system call is two less than the maximum allowed for the sysi86
  59.  *  system call. The value defined here is assumed in the library.
  60.  */
  61.  
  62. #define V86SC_MAXARGS   3               /* Includes sub-func # of v86() */
  63.  
  64. /*  
  65.  *  SI86V86 is a sub system call of the system call "sysi86". The following
  66.  *  definitions are sub system calls for SI86V86 and are processed in v86.c
  67.  */
  68.  
  69. #define V86SC_INIT      1               /* v86init() system call        */
  70. #define V86SC_SLEEP     2               /* v86sleep() system call       */
  71. #define V86SC_MEMFUNC   3               /* v86memfunc() system call     */
  72. #define V86SC_IOPL      4               /* v86iopriv () system call     */
  73.  
  74. /*
  75.  *  The V86 timer has a frequency of 18.2 times a second. The XENIX
  76.  *  timer has a frequency of 50 times a second. So the following
  77.  *  value ensures that the ECT gets an interrupt at least as often
  78.  *  as it needs one.
  79.  */
  80.  
  81. #define V86TIMER        2               /* Every 40 ms (25 times a second) */
  82.  
  83. /*  
  84.  * Software Interrupt mask bit array definitions
  85.  */
  86.  
  87. #define V86_IMASKSIZE   256             /* Max number of software INTs  */
  88. #define V86_IMASKBITS   ((V86_IMASKSIZE + 31) / 32)
  89.                     /* # of bits for software INTs  */
  90.  
  91. /*  
  92.  *  The offsets of members "xt_viflag", "xt_signo" and "xt_hdlr" are
  93.  *  hard coded in the file "v86enter.s". So any changes to the 
  94.  *  structure that changes these offsets have to be reflected 
  95.  *  in this file.  
  96.  *
  97.  *  NOTE: The value of "xt_intr_pin" should be 0xFF or 0.
  98.  */
  99.  
  100. typedef struct v86xtss
  101. {   struct tss xt_tss;                  /* Normal TSS structure         */
  102.     unsigned int *xt_vflptr;        /* Ptr to 8086 virtual flags    */
  103.     unsigned char xt_magictrap;         /* Saved byte of virt intr      */
  104.     unsigned char xt_magicstat;         /* Status of magic byte         */
  105.     unsigned char xt_tslice_shft;       /* Time slice shift requested   */
  106.     unsigned char xt_intr_pin;          /* Interrupt to virtual machine */
  107.     time_t xt_lbolt;                    /* Ligthening bolt value        */
  108.     unsigned int xt_viflag;             /* Virtual interrupt flag       */
  109.     unsigned int xt_vimask;             /* Mask for virtual interrupts  */
  110.     unsigned int xt_signo;              /* Sig number on V86VI_SIGHDL   */
  111.     int (* xt_hdlr)();                  /* Sig handler for V86VI_SIGHDL */
  112.     unsigned int xt_timer_count;        /* Number of pending timer ticks*/
  113.     unsigned int xt_timer_bound;        /* Ticks before forcing ECT in  */
  114.     unsigned int xt_imaskbits[V86_IMASKBITS]; /* Bit map for software INTs    */
  115. }   xtss_t;
  116.  
  117. /*  
  118.  *  Definitions for the field "xt_magicstat". The location "xt_magictrap"
  119.  *  is valid only when "xt_magicstat" field is set to XT_MSTAT_OPSAVED.
  120.  */
  121.  
  122. #define XT_MSTAT_NOPROCESS      0       /* Do not process virtual intr  */
  123. #define XT_MSTAT_PROCESS        1       /* Process virtual intr         */
  124. #define XT_MSTAT_OPSAVED        2       /* v86 program opcode saved     */
  125. #define XT_MSTAT_POSTING        3       /* Phoenix defined              */
  126.  
  127. struct v86parm
  128. {   xtss_t   *xtssp;                    /* Ptr to XTSS in user data     */
  129.     unsigned long szxtss;               /* Length in bytes of XTSS      */
  130.     int xtss_off;
  131. };
  132.  
  133. typedef    dev_t (*dev_t_funcp_t)();
  134.  
  135. typedef struct v86memory
  136. {   int      vmem_cmd;                  /* Sub command for screen func  */
  137.     paddr_t  vmem_physaddr;             /* Physical memory base for map */
  138.     caddr_t  vmem_membase;              /* Screen memory base           */
  139.     int      vmem_memlen;               /* Length of screen memory      */
  140. } v86memory_t;
  141.  
  142. /*  
  143.  * Definitions for the field "vmem_cmd".
  144.  */
  145.  
  146. #define V86MEM_MAP      1               /* Map virt addr to physical    */
  147. #define V86MEM_TRACK    2               /* Track memory modifications   */
  148. #define V86MEM_UNTRACK  3               /* Untrack memory modifications */
  149. #define V86MEM_UNMAP    4               /* Unmap virt addr              */
  150. #define V86MEM_EMM      5               /* LIM expanded memory emulation*/
  151. #define V86MEM_GROW     6               /* Grow Lim expanded memory     */
  152.  
  153. typedef struct v86dat
  154. {   struct proc *vp_procp;              /* Ptr to process's proc struc  */
  155.     ushort   vp_oldtr;                  /* Old task register            */
  156.     unsigned short vp_szxtss;           /* Size of XTSS in user space   */
  157.     unsigned int vp_viflag;             /* Virtual interrupt flag       */
  158.     v86memory_t vp_mem;                 /* Memory map/track definitions */
  159.     long     vp_emm[V86EMM_NUMPGS];     /* Current EMM regs emulation   */
  160.     unsigned int vp_vimask;             /* Mask of virt ints for wakeup */
  161.     char     vp_wakeup;                 /* Wakeup process on virt intr  */
  162.     char     vp_slice_shft;             /* Saved time slice shift       */
  163.     char     vp_nice;                   /* Requested nice from sys call */
  164.     char     vp_filler;                 /* Use these when chars needed  */
  165.     dev_t    vp_dev_id;
  166.     xtss_t   *vp_xtssptr;              /* kernel ptr to xTSS structure */
  167. }   v86_t;
  168.  
  169. /*  
  170.  *  Virtual interrupt bit definitions for the field "vp_viflag".
  171.  *  The low order 16 bits reflect the setting of the AT hardware
  172.  *  interrupts. The high order 16 bits are used for other 
  173.  *  interrupts.
  174.  *
  175.  *  NOTE: The value of V86VI_SIGHDL is hard coded in the file
  176.  *  "v86enter.s". Any change to this value has to reflected in
  177.  *  this file. 
  178.  */
  179.  
  180. #define V86VI_NONE      0x00000000      /* No interrupts                */
  181. #define V86VI_TIMER     0x00000001      /* Virtual timer interrupt      */
  182. #define V86VI_KBD       0x00000002      /* Scancode rcvd when buf empty */
  183. #define V86VI_SLAVE     0x00000004      /* Can be reused when needed    */
  184. #define V86VI_SERIAL1   0x00000008      /* Serial port 1 state change   */
  185. #define V86VI_SERIAL0   0x00000010      /* Serial port 0 state change   */
  186. #define V86VI_PRL1      0x00000020      /* Parallel port 1 state change */
  187. #define V86VI_MOUSE     0x00000020      /* Microsoft mouse              */
  188. #define V86VI_DISK      0x00000040      /* Fixed and floppy disk        */
  189. #define V86VI_PRL0      0x00000080      /* Parallel port 0 state change */
  190.  
  191. #define V86VI_RCLOCK    0x00000100      /* Realtime Clock interrupt     */
  192. #define V86VI_NET       0x00000200      /* Network interrupts           */
  193. #define V86VI_RSVD_1    0x00000400      /* Reserved 1                   */
  194. #define V86VI_RSVD_2    0x00000800      /* Reserved 2                   */
  195. #define V86VI_RSVD_3    0x00001000      /* Reserved 3                   */
  196. #define V86VI_COPROC    0x00002000      /* Coprocessor interrupt        */
  197. #define V86VI_FDISK     0x00004000      /* Fixed disk controller        */
  198. #define V86VI_RSVD_4    0x00008000      /* Reserved 4                   */
  199.  
  200. #define V86VI_DIV0      0x00010000      /* Divide by 0 (vector 0)       */
  201. #define V86VI_SGLSTP    0x00020000      /* Single step intr (vector 1)  */
  202. #define V86VI_BRKPT     0x00040000      /* Break point intr (vector 3)  */
  203. #define V86VI_OVERFLOW  0x00080000      /* Overflow fault (vector 4)    */
  204. #define V86VI_BOUND     0x00100000      /* Bound exception (vector 5)   */
  205. #define V86VI_INVOP     0x00200000      /* Invalid opcode (vector 6)    */
  206. #define V86VI_SIGHDL    0x00400000      /* Virtual signal hdlr interrupt*/
  207. #define V86VI_MEMORY    0x00800000      /* Tracking memory has changed  */
  208. #define V86VI_LBOLT    0x01000000    /* fake virtual interrupt    */
  209.  
  210. /* 
  211.  * Virtual interrupt subcodes for V86VI_SERIAL[01] interrupts.  
  212.  * These values appear in  the fields "xt_s[01]flag".
  213.  */
  214. #define V86SI_DATA      0x00000001      /* New data available from kbd  */
  215. #define V86SI_MODEM     0x00000002      /* Modem status line[s] changed */
  216.  
  217. /* 
  218.  *  Are we a v86 proc? - look at proc structure
  219.  */
  220. #define    V86PROC(p)    ((p)->p_v86)
  221.