home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / vid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-03  |  11.7 KB  |  371 lines

  1. /* 
  2.  *      @(#) vid.h 1.1 88/11/03 
  3.  *
  4.  *      Copyright (C) The Santa Cruz Operation, 1985, 1986, 1987, 1988.
  5.  * 
  6.  *      This Module contains Proprietary Information of the Santa
  7.  *      Cruz Operation, and should be treated as confidential. 
  8.  *
  9.  */
  10.  
  11. #ifndef MAXFK
  12. #include "../h/comcrt.h"
  13. #endif
  14.  
  15. #define TRUE    1
  16. #define FALSE    0
  17.  
  18. /*
  19.  * Maximum nunmber of multiscreens.
  20.  */
  21. #define    MAXSCRN        12    /* max number of screens */
  22.  
  23. /*
  24.  * maximum number of allowed.
  25.  */
  26. #define MAXADAPTERS    16
  27.  
  28. /*
  29.  * Maximum number of control sequence parameters in
  30.  * an escape sequence.
  31.  */
  32. #define NCSPARAMS    3
  33.  
  34. /*
  35.  * Maximum number of keyboard scan codes that can
  36.  * be saved in the read ahead buffer.
  37.  */
  38. #define    MAXRA    8
  39.  
  40. /*
  41.  * Commands to the (*v_sgr)() routine.
  42.  * Defined by ANSI
  43.  */
  44. #define SGR_NORMAL    0    /* return attributes to normal    */
  45. #define SGR_BOLD    1    /* called INTENSE in video'ese    */
  46. #define SGR_FAINT    2    /* NOT-supported        */
  47. #define SGR_PRCOLORS    2    /* PR's set the normal colors    */
  48. #define SGR_ITALIC    3    /* NOT-supported        */
  49. #define SGR_PRBLKCTL    3    /* PR's blink bit control    */
  50. #define SGR_UNDERL    4    /* underline            */
  51. #define SGR_BLINK    5    /* blink            */
  52. #define SGR_FBLINK    6    /* NOT-supported        */
  53. #define SGR_REVERSE    7    /* reverse video w/ setcolor    */
  54. #define SGR_CONCEALED    8    /* hide characters        */
  55. #define SGR_CROSSED    9    /* NOT-supported        */
  56. #define SGR_FONT    10    /* fonts 0 through 9 w/ 10-19    */
  57. #define SGR_GOTHIC    20    /* NOT-supported        */
  58. #define SGR_DLBUNDERL    21    /* NOT-supported        */
  59. #define SGR_NORMCI    22    /* NOT-supported        */
  60. #define SGR_0ITALIC    23    /* NOT-supported        */
  61. #define SGR_0UNDERL    24    /* NOT-supported        */
  62. #define SGR_0BLINK    25    /* NOT-supported        */
  63. #define SGR_RES1    26    /* RESERVED by ANSI        */
  64. #define SGR_0REVERSE    27    /* NOT-supported        */
  65. #define SGR_0CONCEALED    28    /* NOT-supported        */
  66. #define SGR_0CROSSED    29    /* NOT-supported        */
  67. #define SGR_FORECOLOR    30    /* ANSI forground colors 30-37    */
  68. #define SGR_RES2    38    /* RESERVED by ANSI         */
  69. #define SGR_DEFFOREFOL    39    /* NOT-supported        */
  70. #define SGR_BACKCOLOR    40    /* ANSI background colors 40-47    */
  71. #define SGR_RES3    48    /* RESERVED by ANSI        */
  72. #define SGR_DEFBACKCOL    49    /* NOT-supported        */
  73.  
  74. /*
  75.  * Commands to the (*v_adapctl)() routine.
  76.  * Defined by SCO
  77.  */
  78. #define    AC_BLINKB    0    /* Clear or Set the blink bit    */
  79. #define    AC_FONTCHAR    1    /* display font character    */
  80. #define    AC_DEFCSR    2    /* define Cursor type        */
  81. #define AC_BOLDBKG    3    /* turn on intense bg color    */
  82. #define    AC_DEFNF    10    /* define normal forground    */
  83. #define    AC_DEFNB    11    /* define normal background    */
  84. #define    AC_ONN        12    /* begin using normal colors    */
  85. #define    AC_DEFRF    13    /* define reverse forground    */
  86. #define    AC_DEFRB    14    /* define reverse background    */
  87. #define    AC_ONR        15    /* turn on reverse colors    */
  88. #define    AC_DEFGF    16    /* define graphic forground    */
  89. #define    AC_DEFGB    17    /* define graphic background    */
  90. #define    AC_ONG        18    /* turn on graphic colors    */
  91. #define    AC_SETOS    30    /* set overscan colors        */
  92. #define AC_PRIMODE    100    /* return primary text mode    */
  93. #define AC_SAVSZQRY    101    /* return size (bytes) of state    */
  94. #define AC_SAVSCRN    102    /* save screen            */
  95. #define AC_RESSCRN    103    /* restore screen        */
  96. #define AC_CSRCTL    104    /* arg=0 hide cursor, arg=1 show cursor    */
  97. #define AC_USERFONT    105    /* load or dump the soft font    */
  98. #define AC_IOPRIVL    106    /* grant or revoke IO privl    */
  99. #define AC_SOFTRESET    107    /* reset text mode (keep colors)*/
  100. #define AC_SENDSCRN    108    /* write screen chars to stdin    */
  101.  
  102. #ifdef VPIX
  103. #define AC_VTKDPARAM    200    /* get VPIX display parameters    */
  104. #define AC_TXTRECVR    201    /* recover text mode from DOS    */
  105. #define AC_TXTRELSE    202    /* release text mode to DOS    */
  106. #endif
  107.  
  108. typedef struct {
  109.     int cmd, flg;        /* weird data structure to make loadable */
  110.     faddr_t faddr;        /* fonts easier to implement    */
  111. } pgiofontarg_t;
  112.  
  113. #ifdef M_I386
  114. typedef short *strixp_t;    /* pointer to function key text index's    */
  115. typedef uchar_t *strtabp_t;    /* pointer to function key text table    */
  116. typedef short *vseg_t;        /* pointer to a video segment of 'short's */
  117. typedef long *vecp_t;
  118. #else
  119. typedef short far *strixp_t;    /* pointer to key/scrn table of chars    */
  120. typedef uchar_t far *strtabp_t;    /* pointer to function key text table    */
  121. typedef short far *vseg_t;    /* pointer to a video segment of 'short's */
  122. typedef long far *vecp_t;
  123. #endif
  124.  
  125. extern char    ansicolormap[];
  126.  
  127. struct colors {
  128.     char fore;            /* foreground colors    */
  129.     char back;            /* background colors    */
  130. };
  131.  
  132. /*
  133.  * Structure for listing valid
  134.  * adapter IO addresses
  135.  */
  136. struct portrange {
  137.     ushort first;        /* first port */
  138.     ushort count;        /* number of valid right after 'first' */
  139. };
  140.  
  141. /*
  142.  * Structure for a user virtual address.
  143.  */
  144. struct userva {
  145.     faddr_t addr;
  146.     unsigned size;
  147. };
  148.  
  149. #define    BLACK        0x0
  150. #define    BLUE        0x1
  151. #define    GREEN        0x2
  152. #define    CYAN        0x3
  153. #define    RED        0x4
  154. #define    MAGENTA        0x5
  155. #define    BROWN        0x6
  156. #define    WHITE        0x7
  157. #define    GRAY        0x8
  158. #define    LT_BLUE        0x9
  159. #define    LT_GREEN    0xA
  160. #define    LT_CYAN        0xB
  161. #define    LT_RED        0xC
  162. #define    LT_MAGENTA    0xD
  163. #define    YELLOW        0xE
  164. #define    HI_WHITE    0xF
  165.  
  166. /*
  167.  * A keyboard group is a set of Multiscreens,
  168.  * a set of video adapter drivers and the global
  169.  * state of one keyboard.
  170.  */
  171. struct kbgrp {
  172.     struct mscrn *kg_m0;    /* multi-screens[] for the keyboard grp    */
  173.     struct adapter *kg_a0;    /* adaptsw[] for the keyboard grp    */
  174.     int (*kg_in)();        /* keybd grp line displn in() routine    */
  175.     struct map *kg_memmap;    /* keybd grp multiscreen save area map    */
  176.     short kg_dtoa[MAXADAPTERS];/* device # to adapter index table    */
  177.     short kg_curscrn;    /* Current screen            */
  178.     short kg_maxscrn;    /* Maximum valid screen in keyboard grp    */
  179.     struct keymap *kg_keymap;    /* ScanCode translation map    */
  180.     char kg_rabuf[MAXRA];    /* keyboard scan code read ahead buffer    */
  181.     uchar_t *kg_rafp;    /* read ahead buf front pointer        */
  182.     uchar_t *kg_rabp;    /* read ahead buf back pointer        */
  183.     uchar_t kg_break;    /* was last Scan Code a break?        */
  184.     short    kg_down;    /* Which state keys are down        */
  185.     uchar_t kg_state;    /* Local keyboard state            */
  186.     uchar_t kg_gblklk;    /* Global key lock keyboard state    */
  187.     uchar_t    kg_kbmode;    /* keyboard mode AT vs. XT        */
  188.     int (*kg_scrsend)();    /* kb command sender (leds) S001    */
  189.     int (*kg_scrdrain)();    /* clear any keyboard data  S001    */
  190.     int (*kg_scrgetkey)();    /* fetch key from keyboard  S001    */
  191.     int (*kg_scrmode)();    /* put kb in AT or XT mode  S001    */
  192.     int (*kg_bell)();    /* activate bell        S003    */ 
  193.     int kg_extmode;        /* Extended mode flag         S005    */
  194.     int kg_altseq;        /* ALT key sequence        S005    */
  195. #ifdef VPIX
  196.     int (*kg_sound)();    /* VP/ix sound generator    S004    */
  197.     uchar_t kg_num;        /* keyboard group number        */
  198.     uchar_t kg_vtlock;    /* VT interlock token            */
  199.     uchar_t kg_vtsw_id;    /* serialized VT screen switch number    */
  200.     struct mscrn *kg_vtswtchto;    /* next screen in a VT switch    */
  201. #endif
  202. };
  203.  
  204. /*
  205.  * All activity center around a multi-screen.
  206.  */
  207. struct mscrn {
  208.     struct kbgrp    *m_grp;        /* multiscreen group header    */
  209.     int        m_num;        /* screen number        */
  210.     struct tty    *m_tty;        /* tty structure        */
  211.     /*
  212.      * video part
  213.      */
  214.     struct adapter *mv_adapter;    /* ptr to the screen's adapter    */
  215.     vseg_t mv_savscrn;        /* save screen RAM        */
  216.     unsigned mv_savsz;        /* size of save screen used    */
  217.     faddr_t mv_smap;        /* font value translation table    */
  218.     uchar_t mv_font;        /* ANSI font, one of 0, 1, or 2    */
  219.     ushort mv_tmpcol;        /* used by ANSI            */
  220.     ushort mv_row, mv_col;        /* cursor position        */
  221.     ushort mv_rsz, mv_csz;        /* text screen size        */
  222.     ushort mv_csstate;        /* Ctl Sequ state        */
  223.     ushort mv_csparam[NCSPARAMS];    /* Ctl Sequ parameters        */
  224.     uchar_t mv_csindex;        /* Ctl Sequ parameter index    */
  225.     uchar_t mv_cstyp;        /* cursor type            */
  226.     struct colors    mv_norm,    /* normal attributes        */
  227.             mv_rev,        /* reverse video attributes    */
  228.             mv_grfc;    /* graphic character attributes    */
  229.     uchar_t mv_ovscan;        /* border color            */
  230. #ifdef VPIX
  231. /*
  232.  * VP/ix virtual terminals.
  233.  */
  234.     struct proc *vt_procp;
  235.     struct v86dat *vt_v86p;
  236.     ushort vt_pid;
  237.     uchar_t vt_relsig;
  238.     uchar_t vt_acqsig;
  239.     uchar_t vt_frsig;
  240.     uchar_t vt_kbmode;
  241.     uchar_t vt_scrnmode;
  242. #endif
  243. /*
  244.  * Keyboard part
  245.  */
  246.     char mk_qstr[MAXFK];    /* work space for func. key conf    */
  247.     strixp_t mk_strix;    /* function key string table pointer    */
  248.     strtabp_t mk_strtab;    /* function key string text table    */
  249.     uchar_t mk_keylock;    /* caps/num/scroll lock            */
  250. /*
  251.  * flag definitions for mk_keylock
  252.  */
  253. #define    CLKED    0x01        /* caps   locked */
  254. #define    NLKED    0x02        /* num    locked */
  255. #define    SLKED    0x04        /* scroll locked */
  256. /*
  257.  * Bell part
  258.  */
  259.     ushort mb_time;        /* bell duration 1/10 secs */
  260.     ushort mb_freq;        /* bell frequency (pitch) */
  261. /*
  262.  * Misc. Features
  263.  */
  264.     ushort mf_savrow;    /* ^[[7 save current row & col    */
  265.     ushort mf_savcol;    /* ^[[8 restore row & col    */
  266.     ushort mf_snd_row;    /* row and col for sendscreen    */
  267.     ushort mf_snd_col;
  268.     ushort mf_status;    /* terminal status bit field    */
  269.     ushort mf_xtraopenf;    /* flags for systty support    */
  270. /*
  271.  * Defines for mf_status.
  272.  */
  273. #define MFS_SND_SCRN    0x0001        /* currently send screening    */
  274. #define MFS_KBD_LOCK    0x0002        /* keyboard is locked        */
  275. #define MFS_TEXTMODE    0x0004        /* textmode (not graphics mode)    */
  276. #define MFS_LOSTPUTC    0x0008        /* kernl putc's lost in grafixs    */
  277. #define MFS_NOMARGIN    0x0010        /* no automargin mode        */
  278. #ifdef VPIX
  279. #define MFS_PROCMODE    0x0020        /* screen has VPix handler proc    */
  280. #define MFS_VTWAIT    0x0040        /* writes to noncur scrs, block */
  281. #define MFS_VTMAPPED    0x0080        /* display is mapped VPix style    */
  282. #endif
  283. /*
  284.  * Defines for mf_xtraopenf.
  285.  */
  286. #define MFXOF_CONS    0x0001
  287. #define MFXOF_CDEV    0x0002
  288. /*
  289.  * Per Screen hardware fields for use by the adapter drivers.
  290.  * Each adapter driver uses this area in any manner it choses.
  291.  * If the adapter driver wished to make use of m6845.c then
  292.  * the first 8 bytes of the adapter area must match m6845_a.
  293.  */
  294.     uchar_t adp_area[32];
  295. };
  296.  
  297. /*
  298.  * All adapter multiscreen field definitions must have
  299.  * these fields at the top if the adapter driver is
  300.  * intended to work with m6845.c
  301.  */
  302. struct m6845_a {
  303.     uchar_t    a_battr;    /* Bold & Blink attributes    */
  304.     uchar_t    a_cattr;    /* Color/Reverse attributes    */
  305.     uchar_t    a_attrs;    /* OR battr with cattr        */
  306.     uchar_t    a_modereg;    /* contents of 6845 mode reg    */
  307.     ushort    a_csr;        /* cursor shape            */
  308.     ushort    a_scroff;    /* offset of screen in video    */
  309. };
  310.  
  311. /*
  312.  *  Data for accessing an adapter driver.
  313.  */
  314. struct adapter {
  315.     char    *v_name;        /* name of the adapter ie "CGA"    */
  316.  
  317.     ushort    v_type;            /* basic type eg. MONO, CGA,... */
  318.     ushort    v_oem;            /* nonstandard vendor name     */
  319.     struct mscrn *v_curscrn;    /* pointer to the current screen*/
  320.  
  321.     ushort    v_initrc;        /* saved return value of v_init */
  322.     /*
  323.      * Adapter routines
  324.      * These routines manipulate the
  325.      * on video and save image screens.
  326.      */
  327.     int (*v_init)();    /* init the adapter driver        */
  328.     int (*v_cmos)();    /* Extra cmos type checking        */
  329.     int (*v_initscreen)();    /* init a multiscreen on the adapter    */
  330.     void (*v_scroll)();
  331.     void (*v_copy)();
  332.     void (*v_clear)();
  333.     void (*v_pchar)();    /* put a string of characters        */
  334.     void (*v_scurs)();    /* set the active and cursor position    */
  335.     void (*v_sgr)();    /* set graphic rendition; see Ansi X.64    */
  336.     int (*v_ioctl)();    /* Adapter specific ioctl handler    */
  337.     int (*v_adapctl)();    /* Adapter specific misc other stuff    */
  338.  
  339.     vseg_t    v_videoram;    /* Kernel pointer to video ram        */
  340.     paddr_t    v_paddr;    /* Physical address of video ram    */
  341.     ulong_t    v_size;        /* Size of of video ram in bytes    */
  342. #ifdef VPIX
  343.     ulong_t    v_v86addr;    /* Where VP/ix needs this card        */
  344. #endif
  345. };
  346.  
  347. /* bits fields of v_initrc (Adapter Init return values */
  348. #define AI_PRESENT    0x0001
  349. #define AI_COLOR    0x0002
  350. #define ADAP_NP        0
  351.  
  352. /* misc. macros */
  353. #define DISPLAYED(msp)    ((msp)->mv_adapter->v_curscrn == (msp))
  354. #define TEXTMODE(msp)    (MFS_TEXTMODE & (msp)->mf_status)
  355. #define SCREENSZ(msp)    ((msp)->mv_rsz * (msp)->mv_csz)
  356. #define CURSOR(msp)    ((msp)->mv_row * (msp)->mv_csz + (msp)->mv_col)
  357.  
  358. #ifdef M_I386
  359. #define    VIDMEMGET(pages)    ( (pfn_t) memget(pages) )
  360. #else    /* M_I286 */
  361. #define    VIDMEMGET(pages)    ( (mloc_t) mmuget(pages) )
  362. #endif
  363.  
  364. faddr_t vidmap();
  365. faddr_t vidumapinit();
  366.  
  367. #ifdef VPIX
  368. struct kbgrp *vidgetgrpp();    /* get a kb grp ptr from a kb grp num    */
  369. int vidgetgrpnum();        /* get a kb grp num from a kb grp ptr    */
  370. #endif
  371.