cirrus.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /****************************************************************************
  2. ******* *******
  3. ******* CIRRUS.H *******
  4. ******* *******
  5. ****************************************************************************
  6. Author : Jeremy Rolls
  7. Date : 3 Aug 1990
  8. *
  9. * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. Version : 0.01
  25. Mods
  26. ----------------------------------------------------------------------------
  27. Date By Description
  28. ----------------------------------------------------------------------------
  29. ***************************************************************************/
  30. #ifndef _cirrus_h
  31. #ifndef lint
  32. /* static char* _cirrus_h_sccs = "@(#)cirrus.h 1.16"; */
  33. #endif
  34. #define _cirrus_h 1
  35. #ifdef RTA
  36. #define TO_UART RX
  37. #define TO_DRIVER TX
  38. #endif
  39. #ifdef HOST
  40. #define TO_UART TX
  41. #define TO_DRIVER RX
  42. #endif
  43. #ifdef RTA
  44. /* Miscellaneous defines for CIRRUS addresses and related logic for
  45. interrupts etc.
  46. */
  47. #define MAP(a) ((short *)(cirrus_base + (a)))
  48. #define outp(a,b) (*MAP (a) =(b))
  49. #define inp(a) ((*MAP (a)) & 0xff)
  50. #define CIRRUS_FIRST (short*)0x7300
  51. #define CIRRUS_SECOND (short*)0x7200
  52. #define CIRRUS_THIRD (short*)0x7100
  53. #define CIRRUS_FOURTH (short*)0x7000
  54. #define PORTS_ON_CIRRUS 4
  55. #define CIRRUS_FIFO_SIZE 12
  56. #define SPACE 0x20
  57. #define TAB 0x09
  58. #define LINE_FEED 0x0a
  59. #define CARRIAGE_RETURN 0x0d
  60. #define BACKSPACE 0x08
  61. #define SPACES_IN_TABS 8
  62. #define SEND_ESCAPE 0x00
  63. #define START_BREAK 0x81
  64. #define TIMER_TICK 0x82
  65. #define STOP_BREAK 0x83
  66. #define BASE(a) ((a) < 4 ? (short*)CIRRUS_FIRST : ((a) < 8 ? (short *)CIRRUS_SECOND : ((a) < 12 ? (short*)CIRRUS_THIRD : (short *)CIRRUS_FOURTH)))
  67. #define txack1 ((short *)0x7104)
  68. #define rxack1 ((short *)0x7102)
  69. #define mdack1 ((short *)0x7106)
  70. #define txack2 ((short *)0x7006)
  71. #define rxack2 ((short *)0x7004)
  72. #define mdack2 ((short *)0x7100)
  73. #define int_latch ((short *) 0x7800)
  74. #define int_status ((short *) 0x7c00)
  75. #define tx1_pending 0x20
  76. #define rx1_pending 0x10
  77. #define md1_pending 0x40
  78. #define tx2_pending 0x02
  79. #define rx2_pending 0x01
  80. #define md2_pending 0x40
  81. #define module1_bits 0x07
  82. #define module1_modern 0x08
  83. #define module2_bits 0x70
  84. #define module2_modern 0x80
  85. #define module_blank 0xf
  86. #define rs232_d25 0x0
  87. #define rs232_rj45 0x1
  88. #define rs422_d25 0x3
  89. #define parallel 0x5
  90. #define CLK0 0x00
  91. #define CLK1 0x01
  92. #define CLK2 0x02
  93. #define CLK3 0x03
  94. #define CLK4 0x04
  95. #define CIRRUS_REVC 0x42
  96. #define CIRRUS_REVE 0x44
  97. #define TURNON 1
  98. #define TURNOFF 0
  99. /* The list of CIRRUS registers.
  100. NB. These registers are relative values on 8 bit boundaries whereas
  101. on the RTA's the CIRRUS registers are on word boundaries. Use pointer
  102. arithmetic (short *) to obtain the real addresses required */
  103. #define ccr 0x05 /* Channel Command Register */
  104. #define ier 0x06 /* Interrupt Enable Register */
  105. #define cor1 0x08 /* Channel Option Register 1 */
  106. #define cor2 0x09 /* Channel Option Register 2 */
  107. #define cor3 0x0a /* Channel Option Register 3 */
  108. #define cor4 0x1e /* Channel Option Register 4 */
  109. #define cor5 0x1f /* Channel Option Register 5 */
  110. #define ccsr 0x0b /* Channel Control Status Register */
  111. #define rdcr 0x0e /* Receive Data Count Register */
  112. #define tdcr 0x12 /* Transmit Data Count Register */
  113. #define mcor1 0x15 /* Modem Change Option Register 1 */
  114. #define mcor2 0x16 /* Modem Change Option Regsiter 2 */
  115. #define livr 0x18 /* Local Interrupt Vector Register */
  116. #define schr1 0x1a /* Special Character Register 1 */
  117. #define schr2 0x1b /* Special Character Register 2 */
  118. #define schr3 0x1c /* Special Character Register 3 */
  119. #define schr4 0x1d /* Special Character Register 4 */
  120. #define rtr 0x20 /* Receive Timer Register */
  121. #define rtpr 0x21 /* Receive Timeout Period Register */
  122. #define lnc 0x24 /* Lnext character */
  123. #define rivr 0x43 /* Receive Interrupt Vector Register */
  124. #define tivr 0x42 /* Transmit Interrupt Vector Register */
  125. #define mivr 0x41 /* Modem Interrupt Vector Register */
  126. #define gfrcr 0x40 /* Global Firmware Revision code Reg */
  127. #define ricr 0x44 /* Receive Interrupting Channel Reg */
  128. #define ticr 0x45 /* Transmit Interrupting Channel Reg */
  129. #define micr 0x46 /* Modem Interrupting Channel Register */
  130. #define gcr 0x4b /* Global configuration register*/
  131. #define misr 0x4c /* Modem interrupt status register */
  132. #define rbusr 0x59
  133. #define tbusr 0x5a
  134. #define mbusr 0x5b
  135. #define eoir 0x60 /* End Of Interrupt Register */
  136. #define rdsr 0x62 /* Receive Data / Status Register */
  137. #define tdr 0x63 /* Transmit Data Register */
  138. #define svrr 0x67 /* Service Request Register */
  139. #define car 0x68 /* Channel Access Register */
  140. #define mir 0x69 /* Modem Interrupt Register */
  141. #define tir 0x6a /* Transmit Interrupt Register */
  142. #define rir 0x6b /* Receive Interrupt Register */
  143. #define msvr1 0x6c /* Modem Signal Value Register 1 */
  144. #define msvr2 0x6d /* Modem Signal Value Register 2*/
  145. #define psvr 0x6f /* Printer Signal Value Register*/
  146. #define tbpr 0x72 /* Transmit Baud Rate Period Register */
  147. #define tcor 0x76 /* Transmit Clock Option Register */
  148. #define rbpr 0x78 /* Receive Baud Rate Period Register */
  149. #define rber 0x7a /* Receive Baud Rate Extension Register */
  150. #define rcor 0x7c /* Receive Clock Option Register*/
  151. #define ppr 0x7e /* Prescalar Period Register */
  152. /* Misc registers used for forcing the 1400 out of its reset woes */
  153. #define airl 0x6d
  154. #define airm 0x6e
  155. #define airh 0x6f
  156. #define btcr 0x66
  157. #define mtcr 0x6c
  158. #define tber 0x74
  159. #endif /* #ifdef RTA */
  160. /* Bit fields for particular registers */
  161. /* GCR */
  162. #define GCR_SERIAL 0x00 /* Configure as serial channel */
  163. #define GCR_PARALLEL 0x80 /* Configure as parallel channel */
  164. /* RDSR - when status read from FIFO */
  165. #define RDSR_BREAK 0x08 /* Break received */
  166. #define RDSR_TIMEOUT 0x80 /* No new data timeout */
  167. #define RDSR_SC1 0x10 /* Special char 1 (tx XON) matched */
  168. #define RDSR_SC2 0x20 /* Special char 2 (tx XOFF) matched */
  169. #define RDSR_SC12_MASK 0x30 /* Mask for special chars 1 and 2 */
  170. /* PPR */
  171. #define PPR_DEFAULT 0x31 /* Default value - for a 25Mhz clock gives
  172. a timeout period of 1ms */
  173. /* LIVR */
  174. #define LIVR_EXCEPTION 0x07 /* Receive exception interrupt */
  175. /* CCR */
  176. #define CCR_RESET 0x80 /* Reset channel */
  177. #define CCR_CHANGE 0x4e /* COR's have changed - NB always change all
  178. COR's */
  179. #define CCR_WFLUSH 0x82 /* Flush transmit FIFO and TSR / THR */
  180. #define CCR_SENDSC1 0x21 /* Send special character one */
  181. #define CCR_SENDSC2 0x22 /* Send special character two */
  182. #define CCR_SENDSC3 0x23 /* Send special character three */
  183. #define CCR_SENDSC4 0x24 /* Send special character four */
  184. #define CCR_TENABLE 0x18 /* Enable transmitter */
  185. #define CCR_TDISABLE 0x14 /* Disable transmitter */
  186. #define CCR_RENABLE 0x12 /* Enable receiver */
  187. #define CCR_RDISABLE 0x11 /* Disable receiver */
  188. #define CCR_READY 0x00 /* CCR is ready for another command */
  189. /* CCSR */
  190. #define CCSR_TXENABLE 0x08 /* Transmitter enable */
  191. #define CCSR_RXENABLE 0x80 /* Receiver enable */
  192. #define CCSR_TXFLOWOFF 0x04 /* Transmit flow off */
  193. #define CCSR_TXFLOWON 0x02 /* Transmit flow on */
  194. /* SVRR */
  195. #define SVRR_RECEIVE 0x01 /* Receive interrupt pending */
  196. #define SVRR_TRANSMIT 0x02 /* Transmit interrupt pending */
  197. #define SVRR_MODEM 0x04 /* Modem interrupt pending */
  198. /* CAR */
  199. #define CAR_PORTS 0x03 /* Bit fields for ports */
  200. /* IER */
  201. #define IER_MODEM 0x80 /* Change in modem status */
  202. #define IER_RECEIVE 0x10 /* Good data / data exception */
  203. #define IER_TRANSMITR 0x04 /* Transmit ready (FIFO empty) */
  204. #define IER_TRANSMITE 0x02 /* Transmit empty */
  205. #define IER_TIMEOUT 0x01 /* Timeout on no data */
  206. #define IER_DEFAULT 0x94 /* Default values */
  207. #define IER_PARALLEL 0x84 /* Default for Parallel */
  208. #define IER_EMPTY 0x92 /* Transmitter empty rather than ready */
  209. /* COR1 - Driver only */
  210. #define COR1_INPCK 0x10 /* Check parity of received characters */
  211. /* COR1 - driver and RTA */
  212. #define COR1_ODD 0x80 /* Odd parity */
  213. #define COR1_EVEN 0x00 /* Even parity */
  214. #define COR1_NOP 0x00 /* No parity */
  215. #define COR1_FORCE 0x20 /* Force parity */
  216. #define COR1_NORMAL 0x40 /* With parity */
  217. #define COR1_1STOP 0x00 /* 1 stop bit */
  218. #define COR1_15STOP 0x04 /* 1.5 stop bits */
  219. #define COR1_2STOP 0x08 /* 2 stop bits */
  220. #define COR1_5BITS 0x00 /* 5 data bits */
  221. #define COR1_6BITS 0x01 /* 6 data bits */
  222. #define COR1_7BITS 0x02 /* 7 data bits */
  223. #define COR1_8BITS 0x03 /* 8 data bits */
  224. #define COR1_HOST 0xef /* Safe host bits */
  225. /* RTA only */
  226. #define COR1_CINPCK 0x00 /* Check parity of received characters */
  227. #define COR1_CNINPCK 0x10 /* Don't check parity */
  228. /* COR2 bits for both RTA and driver use */
  229. #define COR2_IXANY 0x80 /* IXANY - any character is XON */
  230. #define COR2_IXON 0x40 /* IXON - enable tx soft flowcontrol */
  231. #define COR2_RTSFLOW 0x02 /* Enable tx hardware flow control */
  232. /* Additional driver bits */
  233. #define COR2_HUPCL 0x20 /* Hang up on close */
  234. #define COR2_CTSFLOW 0x04 /* Enable rx hardware flow control */
  235. #define COR2_IXOFF 0x01 /* Enable rx software flow control */
  236. #define COR2_DTRFLOW 0x08 /* Enable tx hardware flow control */
  237. /* RTA use only */
  238. #define COR2_ETC 0x20 /* Embedded transmit options */
  239. #define COR2_LOCAL 0x10 /* Local loopback mode */
  240. #define COR2_REMOTE 0x08 /* Remote loopback mode */
  241. #define COR2_HOST 0xc2 /* Safe host bits */
  242. /* COR3 - RTA use only */
  243. #define COR3_SCDRNG 0x80 /* Enable special char detect for range */
  244. #define COR3_SCD34 0x40 /* Special character detect for SCHR's 3 + 4 */
  245. #define COR3_FCT 0x20 /* Flow control transparency */
  246. #define COR3_SCD12 0x10 /* Special character detect for SCHR's 1 + 2 */
  247. #define COR3_FIFO12 0x0c /* 12 chars for receive FIFO threshold */
  248. #define COR3_FIFO10 0x0a /* 10 chars for receive FIFO threshold */
  249. #define COR3_FIFO8 0x08 /* 8 chars for receive FIFO threshold */
  250. #define COR3_FIFO6 0x06 /* 6 chars for receive FIFO threshold */
  251. #define COR3_THRESHOLD COR3_FIFO8 /* MUST BE LESS THAN MCOR_THRESHOLD */
  252. #define COR3_DEFAULT (COR3_FCT | COR3_THRESHOLD)
  253. /* Default bits for COR3 */
  254. /* COR4 driver and RTA use */
  255. #define COR4_IGNCR 0x80 /* Throw away CR's on input */
  256. #define COR4_ICRNL 0x40 /* Map CR -> NL on input */
  257. #define COR4_INLCR 0x20 /* Map NL -> CR on input */
  258. #define COR4_IGNBRK 0x10 /* Ignore Break */
  259. #define COR4_NBRKINT 0x08 /* No interrupt on break (-BRKINT) */
  260. #define COR4_RAISEMOD 0x01 /* Raise modem output lines on non-zero baud */
  261. /* COR4 driver only */
  262. #define COR4_IGNPAR 0x04 /* IGNPAR (ignore characters with errors) */
  263. #define COR4_PARMRK 0x02 /* PARMRK */
  264. #define COR4_HOST 0xf8 /* Safe host bits */
  265. /* COR4 RTA only */
  266. #define COR4_CIGNPAR 0x02 /* Thrown away bad characters */
  267. #define COR4_CPARMRK 0x04 /* PARMRK characters */
  268. #define COR4_CNPARMRK 0x03 /* Don't PARMRK */
  269. /* COR5 driver and RTA use */
  270. #define COR5_ISTRIP 0x80 /* Strip input chars to 7 bits */
  271. #define COR5_LNE 0x40 /* Enable LNEXT processing */
  272. #define COR5_CMOE 0x20 /* Match good and errored characters */
  273. #define COR5_ONLCR 0x02 /* NL -> CR NL on output */
  274. #define COR5_OCRNL 0x01 /* CR -> NL on output */
  275. /*
  276. ** Spare bits - these are not used in the CIRRUS registers, so we use
  277. ** them to set various other features.
  278. */
  279. /*
  280. ** tstop and tbusy indication
  281. */
  282. #define COR5_TSTATE_ON 0x08 /* Turn on monitoring of tbusy and tstop */
  283. #define COR5_TSTATE_OFF 0x04 /* Turn off monitoring of tbusy and tstop */
  284. /*
  285. ** TAB3
  286. */
  287. #define COR5_TAB3 0x10 /* TAB3 mode */
  288. #define COR5_HOST 0xc3 /* Safe host bits */
  289. /* CCSR */
  290. #define CCSR_TXFLOFF 0x04 /* Tx is xoffed */
  291. /* MSVR1 */
  292. /* NB. DTR / CD swapped from Cirrus spec as the pins are also reversed on the
  293. RTA. This is because otherwise DCD would get lost on the 1 parallel / 3
  294. serial option.
  295. */
  296. #define MSVR1_CD 0x80 /* CD (DSR on Cirrus) */
  297. #define MSVR1_RTS 0x40 /* RTS (CTS on Cirrus) */
  298. #define MSVR1_RI 0x20 /* RI */
  299. #define MSVR1_DTR 0x10 /* DTR (CD on Cirrus) */
  300. #define MSVR1_CTS 0x01 /* CTS output pin (RTS on Cirrus) */
  301. /* Next two used to indicate state of tbusy and tstop to driver */
  302. #define MSVR1_TSTOP 0x08 /* Set if port flow controlled */
  303. #define MSVR1_TEMPTY 0x04 /* Set if port tx buffer empty */
  304. #define MSVR1_HOST 0xf3 /* The bits the host wants */
  305. /* MSVR2 */
  306. #define MSVR2_DSR 0x02 /* DSR output pin (DTR on Cirrus) */
  307. /* MCOR */
  308. #define MCOR_CD 0x80 /* CD (DSR on Cirrus) */
  309. #define MCOR_RTS 0x40 /* RTS (CTS on Cirrus) */
  310. #define MCOR_RI 0x20 /* RI */
  311. #define MCOR_DTR 0x10 /* DTR (CD on Cirrus) */
  312. #define MCOR_DEFAULT (MCOR_CD | MCOR_RTS | MCOR_RI | MCOR_DTR)
  313. #define MCOR_FULLMODEM MCOR_DEFAULT
  314. #define MCOR_RJ45 (MCOR_CD | MCOR_RTS | MCOR_DTR)
  315. #define MCOR_RESTRICTED (MCOR_CD | MCOR_RTS)
  316. /* More MCOR - H/W Handshake (flowcontrol) stuff */
  317. #define MCOR_THRESH8 0x08 /* eight characters then we stop */
  318. #define MCOR_THRESH9 0x09 /* nine characters then we stop */
  319. #define MCOR_THRESH10 0x0A /* ten characters then we stop */
  320. #define MCOR_THRESH11 0x0B /* eleven characters then we stop */
  321. #define MCOR_THRESHBITS 0x0F /* mask for ANDing out the above */
  322. #define MCOR_THRESHOLD MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
  323. /* RTPR */
  324. #define RTPR_DEFAULT 0x02 /* Default */
  325. /* Defines for the subscripts of a CONFIG packet */
  326. #define CONFIG_COR1 1 /* Option register 1 */
  327. #define CONFIG_COR2 2 /* Option register 2 */
  328. #define CONFIG_COR4 3 /* Option register 4 */
  329. #define CONFIG_COR5 4 /* Option register 5 */
  330. #define CONFIG_TXXON 5 /* Tx XON character */
  331. #define CONFIG_TXXOFF 6 /* Tx XOFF character */
  332. #define CONFIG_RXXON 7 /* Rx XON character */
  333. #define CONFIG_RXXOFF 8 /* Rx XOFF character */
  334. #define CONFIG_LNEXT 9 /* LNEXT character */
  335. #define CONFIG_TXBAUD 10 /* Tx baud rate */
  336. #define CONFIG_RXBAUD 11 /* Rx baud rate */
  337. /* Port status stuff */
  338. #define IDLE_CLOSED 0 /* Closed */
  339. #define IDLE_OPEN 1 /* Idle open */
  340. #define IDLE_BREAK 2 /* Idle on break */
  341. /* Subscript of MODEM STATUS packet */
  342. #define MODEM_VALUE 3 /* Current values of handshake pins */
  343. /* Subscript of SBREAK packet */
  344. #define BREAK_LENGTH 1 /* Length of a break in slices of 0.01 seconds
  345. 0 = stay on break until an EBREAK command
  346. is sent */
  347. #define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
  348. /* Packet types going from Host to remote - with the exception of OPEN, MOPEN,
  349. CONFIG, SBREAK and MEMDUMP the remaining bytes of the data array will not
  350. be used
  351. */
  352. #define OPEN 0x00 /* Open a port */
  353. #define CONFIG 0x01 /* Configure a port */
  354. #define MOPEN 0x02 /* Modem open (block for DCD) */
  355. #define CLOSE 0x03 /* Close a port */
  356. #define WFLUSH (0x04 | PRE_EMPTIVE) /* Write flush */
  357. #define RFLUSH (0x05 | PRE_EMPTIVE) /* Read flush */
  358. #define RESUME (0x06 | PRE_EMPTIVE) /* Resume if xoffed */
  359. #define SBREAK 0x07 /* Start break */
  360. #define EBREAK 0x08 /* End break */
  361. #define SUSPEND (0x09 | PRE_EMPTIVE) /* Susp op (behave as tho xoffed) */
  362. #define FCLOSE (0x0a | PRE_EMPTIVE) /* Force close */
  363. #define XPRINT 0x0b /* Xprint packet */
  364. #define MBIS (0x0c | PRE_EMPTIVE) /* Set modem lines */
  365. #define MBIC (0x0d | PRE_EMPTIVE) /* Clear modem lines */
  366. #define MSET (0x0e | PRE_EMPTIVE) /* Set modem lines */
  367. #define PCLOSE 0x0f /* Pseudo close - Leaves rx/tx enabled */
  368. #define MGET (0x10 | PRE_EMPTIVE) /* Force update of modem status */
  369. #define MEMDUMP (0x11 | PRE_EMPTIVE) /* Send back mem from addr supplied */
  370. #define READ_REGISTER (0x12 | PRE_EMPTIVE) /* Read CD1400 register (debug) */
  371. /* "Command" packets going from remote to host COMPLETE and MODEM_STATUS
  372. use data[4] / data[3] to indicate current state and modem status respectively
  373. */
  374. #define COMPLETE (0x20 | PRE_EMPTIVE)
  375. /* Command complete */
  376. #define BREAK_RECEIVED (0x21 | PRE_EMPTIVE)
  377. /* Break received */
  378. #define MODEM_STATUS (0x22 | PRE_EMPTIVE)
  379. /* Change in modem status */
  380. /* "Command" packet that could go either way - handshake wake-up */
  381. #define HANDSHAKE (0x23 | PRE_EMPTIVE)
  382. /* Wake-up to HOST / RTA */
  383. #endif