port.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. ** -----------------------------------------------------------------------------
  3. **
  4. ** Perle Specialix driver for Linux
  5. ** Ported from existing RIO Driver for SCO sources.
  6. *
  7. * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. **
  23. ** Module : port.h
  24. ** SID : 1.3
  25. ** Last Modified : 11/6/98 11:34:12
  26. ** Retrieved : 11/6/98 11:34:21
  27. **
  28. ** ident @(#)port.h 1.3
  29. **
  30. ** -----------------------------------------------------------------------------
  31. */
  32. #ifndef __rio_port_h__
  33. #define __rio_port_h__
  34. #ifdef SCCS_LABELS
  35. static char *_port_h_sccs_ = "@(#)port.h 1.3";
  36. #endif
  37. #undef VPIX
  38. /*
  39. ** the port data structure - one per port in the system
  40. */
  41. #ifdef STATS
  42. struct RIOStats {
  43. /*
  44. ** interrupt statistics
  45. */
  46. uint BreakIntCnt;
  47. uint ModemOffCnt;
  48. uint ModemOnCnt;
  49. uint RxIntCnt;
  50. uint TxIntCnt;
  51. /*
  52. ** throughput statistics
  53. */
  54. uint RxCharCnt;
  55. uint RxPktCnt;
  56. uint RxSaveCnt;
  57. uint TxCharCnt;
  58. uint TxPktCnt;
  59. /*
  60. ** driver entry statistics
  61. */
  62. uint CloseCnt;
  63. uint IoctlCnt;
  64. uint OpenCnt;
  65. uint ReadCnt;
  66. uint WriteCnt;
  67. /*
  68. ** proc statistics
  69. */
  70. uint BlockCnt;
  71. uint OutputCnt;
  72. uint ResumeCnt;
  73. uint RflushCnt;
  74. uint SuspendCnt;
  75. uint TbreakCnt;
  76. uint TimeoutCnt;
  77. uint UnblockCnt;
  78. uint WflushCnt;
  79. uint WFBodgeCnt;
  80. };
  81. #endif
  82. /*
  83. ** Port data structure
  84. */
  85. struct Port {
  86. struct gs_port gs;
  87. int PortNum; /* RIO port no., 0-511 */
  88. struct Host *HostP;
  89. volatile caddr_t Caddr;
  90. ushort HostPort; /* Port number on host card */
  91. uchar RupNum; /* Number of RUP for port */
  92. uchar ID2; /* Second ID of RTA for port */
  93. ulong State; /* FLAGS for open & xopen */
  94. #define RIO_LOPEN 0x00001 /* Local open */
  95. #define RIO_MOPEN 0x00002 /* Modem open */
  96. #define RIO_WOPEN 0x00004 /* Waiting for open */
  97. #define RIO_CLOSING 0x00008 /* The port is being close */
  98. #define RIO_XPBUSY 0x00010 /* Transparent printer busy */
  99. #define RIO_BREAKING 0x00020 /* Break in progress */
  100. #define RIO_DIRECT 0x00040 /* Doing Direct output */
  101. #define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
  102. #define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
  103. #define RIO_CARR_ON 0x00200 /* Stream has carrier present */
  104. #define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
  105. #define RIO_RBLK 0x00800 /* Stream is read-blocked */
  106. #define RIO_BUSY 0x01000 /* Stream is BUSY for write */
  107. #define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
  108. #define RIO_TXSTOP 0x04000 /* Stream output is stopped */
  109. #define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
  110. #define RIO_DYNOROD 0x10000 /* Drain failed */
  111. #define RIO_DELETED 0x20000 /* RTA has been deleted */
  112. #define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
  113. #define RIO_USING_EUC 0x100000 /* Using extended Unix chars */
  114. #define RIO_CAN_COOK 0x200000 /* This line can do cooking */
  115. #define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */
  116. #define RIO_TRIAD_BLOCK 0x800000 /* Next read will block */
  117. #define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */
  118. #define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */
  119. ulong Config; /* FLAGS for NOREAD.... */
  120. #define RIO_NOREAD 0x0001 /* Are not allowed to read port */
  121. #define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
  122. #define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
  123. #define RIO_NOMASK 0x0007 /* All not allowed things */
  124. #define RIO_IXANY 0x0008 /* Port is allowed ixany */
  125. #define RIO_MODEM 0x0010 /* Stream is a modem device */
  126. #define RIO_IXON 0x0020 /* Port is allowed ixon */
  127. #define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
  128. #define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */
  129. #define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */
  130. /*
  131. ** 15.10.1998 ARG - ESIL 0761 prt fix
  132. ** As LynxOS does not appear to support Hardware Flow Control .....
  133. ** Define our own flow control flags in 'Config'.
  134. */
  135. #define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
  136. #define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
  137. struct PHB *PhbP; /* pointer to PHB for port */
  138. WORD *TxAdd; /* Add packets here */
  139. WORD *TxStart; /* Start of add array */
  140. WORD *TxEnd; /* End of add array */
  141. WORD *RxRemove; /* Remove packets here */
  142. WORD *RxStart; /* Start of remove array */
  143. WORD *RxEnd; /* End of remove array */
  144. uint RtaUniqueNum; /* Unique number of RTA */
  145. ushort PortState; /* status of port */
  146. ushort ModemState; /* status of modem lines */
  147. ulong ModemLines; /* Modem bits sent to RTA */
  148. uchar CookMode; /* who expands CR/LF? */
  149. uchar ParamSem; /* Prevent write during param */
  150. uchar Mapped; /* if port mapped onto host */
  151. uchar SecondBlock; /* if port belongs to 2nd block
  152. of 16 port RTA */
  153. uchar InUse; /* how many pre-emptive cmds */
  154. uchar Lock; /* if params locked */
  155. uchar Store; /* if params stored across closes */
  156. uchar FirstOpen; /* TRUE if first time port opened */
  157. uchar FlushCmdBodge; /* if doing a (non)flush */
  158. uchar MagicFlags; /* require intr processing */
  159. #define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
  160. #define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
  161. #define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
  162. uchar WflushFlag; /* 1 How many WFLUSHs active */
  163. /*
  164. ** Transparent print stuff
  165. */
  166. struct Xprint {
  167. #ifndef MAX_XP_CTRL_LEN
  168. #define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */
  169. #endif
  170. uint XpCps;
  171. char XpOn[MAX_XP_CTRL_LEN];
  172. char XpOff[MAX_XP_CTRL_LEN];
  173. ushort XpLen; /* strlen(XpOn)+strlen(XpOff) */
  174. uchar XpActive;
  175. uchar XpLastTickOk; /* TRUE if we can process */
  176. #define XP_OPEN 00001
  177. #define XP_RUNABLE 00002
  178. struct ttystatics *XttyP;
  179. } Xprint;
  180. #ifdef VPIX
  181. v86_t *StashP;
  182. uint IntMask;
  183. struct termss VpixSs;
  184. uchar ModemStatusReg; /* Modem status register */
  185. #endif
  186. uchar RxDataStart;
  187. uchar Cor2Copy; /* copy of COR2 */
  188. char *Name; /* points to the Rta's name */
  189. #ifdef STATS
  190. struct RIOStats Stat; /* ports statistics */
  191. #endif
  192. char *TxRingBuffer;
  193. ushort TxBufferIn; /* New data arrives here */
  194. ushort TxBufferOut; /* Intr removes data here */
  195. ushort OldTxBufferOut; /* Indicates if draining */
  196. int TimeoutId; /* Timeout ID */
  197. uint Debug;
  198. uchar WaitUntilBooted; /* True if open should block */
  199. uint statsGather; /* True if gathering stats */
  200. ulong txchars; /* Chars transmitted */
  201. ulong rxchars; /* Chars received */
  202. ulong opens; /* port open count */
  203. ulong closes; /* port close count */
  204. ulong ioctls; /* ioctl count */
  205. uchar LastRxTgl; /* Last state of rx toggle bit */
  206. spinlock_t portSem; /* Lock using this sem */
  207. int MonitorTstate; /* Monitoring ? */
  208. int timeout_id; /* For calling 100 ms delays */
  209. int timeout_sem; /* For calling 100 ms delays */
  210. int firstOpen; /* First time open ? */
  211. char *p; /* save the global struc here .. */
  212. };
  213. struct ModuleInfo {
  214. char *Name;
  215. uint Flags[4]; /* one per port on a module */
  216. };
  217. #endif
  218. /*
  219. ** This struct is required because trying to grab an entire Port structure
  220. ** runs into problems with differing struct sizes between driver and config.
  221. */
  222. struct PortParams {
  223. uint Port;
  224. ulong Config;
  225. ulong State;
  226. struct ttystatics *TtyP;
  227. };