sdla.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * INET An implementation of the TCP/IP protocol suite for the LINUX
  3. * operating system. INET is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * Global definitions for the Frame relay interface.
  7. *
  8. * Version: @(#)if_ifrad.h 0.20 13 Apr 96
  9. *
  10. * Author: Mike McLagan <mike.mclagan@linux.org>
  11. *
  12. * Changes:
  13. * 0.15 Mike McLagan Structure packing
  14. *
  15. * 0.20 Mike McLagan New flags for S508 buffer handling
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License
  19. * as published by the Free Software Foundation; either version
  20. * 2 of the License, or (at your option) any later version.
  21. */
  22. #ifndef SDLA_H
  23. #define SDLA_H
  24. /* adapter type */
  25. #define SDLA_TYPES
  26. #define SDLA_S502A 5020
  27. #define SDLA_S502E 5021
  28. #define SDLA_S503 5030
  29. #define SDLA_S507 5070
  30. #define SDLA_S508 5080
  31. #define SDLA_S509 5090
  32. #define SDLA_UNKNOWN -1
  33. /* port selection flags for the S508 */
  34. #define SDLA_S508_PORT_V35 0x00
  35. #define SDLA_S508_PORT_RS232 0x02
  36. /* Z80 CPU speeds */
  37. #define SDLA_CPU_3M 0x00
  38. #define SDLA_CPU_5M 0x01
  39. #define SDLA_CPU_7M 0x02
  40. #define SDLA_CPU_8M 0x03
  41. #define SDLA_CPU_10M 0x04
  42. #define SDLA_CPU_16M 0x05
  43. #define SDLA_CPU_12M 0x06
  44. /* some private IOCTLs */
  45. #define SDLA_IDENTIFY (FRAD_LAST_IOCTL + 1)
  46. #define SDLA_CPUSPEED (FRAD_LAST_IOCTL + 2)
  47. #define SDLA_PROTOCOL (FRAD_LAST_IOCTL + 3)
  48. #define SDLA_CLEARMEM (FRAD_LAST_IOCTL + 4)
  49. #define SDLA_WRITEMEM (FRAD_LAST_IOCTL + 5)
  50. #define SDLA_READMEM (FRAD_LAST_IOCTL + 6)
  51. struct sdla_mem {
  52. int addr;
  53. int len;
  54. void __user *data;
  55. };
  56. #define SDLA_START (FRAD_LAST_IOCTL + 7)
  57. #define SDLA_STOP (FRAD_LAST_IOCTL + 8)
  58. /* some offsets in the Z80's memory space */
  59. #define SDLA_NMIADDR 0x0000
  60. #define SDLA_CONF_ADDR 0x0010
  61. #define SDLA_S502A_NMIADDR 0x0066
  62. #define SDLA_CODE_BASEADDR 0x0100
  63. #define SDLA_WINDOW_SIZE 0x2000
  64. #define SDLA_ADDR_MASK 0x1FFF
  65. /* largest handleable block of data */
  66. #define SDLA_MAX_DATA 4080
  67. #define SDLA_MAX_MTU 4072 /* MAX_DATA - sizeof(fradhdr) */
  68. #define SDLA_MAX_DLCI 24
  69. /* this should be the same as frad_conf */
  70. struct sdla_conf {
  71. short station;
  72. short config;
  73. short kbaud;
  74. short clocking;
  75. short max_frm;
  76. short T391;
  77. short T392;
  78. short N391;
  79. short N392;
  80. short N393;
  81. short CIR_fwd;
  82. short Bc_fwd;
  83. short Be_fwd;
  84. short CIR_bwd;
  85. short Bc_bwd;
  86. short Be_bwd;
  87. };
  88. /* this should be the same as dlci_conf */
  89. struct sdla_dlci_conf {
  90. short config;
  91. short CIR_fwd;
  92. short Bc_fwd;
  93. short Be_fwd;
  94. short CIR_bwd;
  95. short Bc_bwd;
  96. short Be_bwd;
  97. short Tc_fwd;
  98. short Tc_bwd;
  99. short Tf_max;
  100. short Tb_max;
  101. };
  102. #ifndef __KERNEL__
  103. void sdla(void *cfg_info, char *dev, struct frad_conf *conf, int quiet);
  104. #else
  105. /* important Z80 window addresses */
  106. #define SDLA_CONTROL_WND 0xE000
  107. #define SDLA_502_CMD_BUF 0xEF60
  108. #define SDLA_502_RCV_BUF 0xA900
  109. #define SDLA_502_TXN_AVAIL 0xFFF1
  110. #define SDLA_502_RCV_AVAIL 0xFFF2
  111. #define SDLA_502_EVENT_FLAGS 0xFFF3
  112. #define SDLA_502_MDM_STATUS 0xFFF4
  113. #define SDLA_502_IRQ_INTERFACE 0xFFFD
  114. #define SDLA_502_IRQ_PERMISSION 0xFFFE
  115. #define SDLA_502_DATA_OFS 0x0010
  116. #define SDLA_508_CMD_BUF 0xE000
  117. #define SDLA_508_TXBUF_INFO 0xF100
  118. #define SDLA_508_RXBUF_INFO 0xF120
  119. #define SDLA_508_EVENT_FLAGS 0xF003
  120. #define SDLA_508_MDM_STATUS 0xF004
  121. #define SDLA_508_IRQ_INTERFACE 0xF010
  122. #define SDLA_508_IRQ_PERMISSION 0xF011
  123. #define SDLA_508_TSE_OFFSET 0xF012
  124. /* Event flags */
  125. #define SDLA_EVENT_STATUS 0x01
  126. #define SDLA_EVENT_DLCI_STATUS 0x02
  127. #define SDLA_EVENT_BAD_DLCI 0x04
  128. #define SDLA_EVENT_LINK_DOWN 0x40
  129. /* IRQ Trigger flags */
  130. #define SDLA_INTR_RX 0x01
  131. #define SDLA_INTR_TX 0x02
  132. #define SDLA_INTR_MODEM 0x04
  133. #define SDLA_INTR_COMPLETE 0x08
  134. #define SDLA_INTR_STATUS 0x10
  135. #define SDLA_INTR_TIMER 0x20
  136. /* DLCI status bits */
  137. #define SDLA_DLCI_DELETED 0x01
  138. #define SDLA_DLCI_ACTIVE 0x02
  139. #define SDLA_DLCI_WAITING 0x04
  140. #define SDLA_DLCI_NEW 0x08
  141. #define SDLA_DLCI_INCLUDED 0x40
  142. /* valid command codes */
  143. #define SDLA_INFORMATION_WRITE 0x01
  144. #define SDLA_INFORMATION_READ 0x02
  145. #define SDLA_ISSUE_IN_CHANNEL_SIGNAL 0x03
  146. #define SDLA_SET_DLCI_CONFIGURATION 0x10
  147. #define SDLA_READ_DLCI_CONFIGURATION 0x11
  148. #define SDLA_DISABLE_COMMUNICATIONS 0x12
  149. #define SDLA_ENABLE_COMMUNICATIONS 0x13
  150. #define SDLA_READ_DLC_STATUS 0x14
  151. #define SDLA_READ_DLC_STATISTICS 0x15
  152. #define SDLA_FLUSH_DLC_STATISTICS 0x16
  153. #define SDLA_LIST_ACTIVE_DLCI 0x17
  154. #define SDLA_FLUSH_INFORMATION_BUFFERS 0x18
  155. #define SDLA_ADD_DLCI 0x20
  156. #define SDLA_DELETE_DLCI 0x21
  157. #define SDLA_ACTIVATE_DLCI 0x22
  158. #define SDLA_DEACTIVATE_DLCI 0x23
  159. #define SDLA_READ_MODEM_STATUS 0x30
  160. #define SDLA_SET_MODEM_STATUS 0x31
  161. #define SDLA_READ_COMMS_ERR_STATS 0x32
  162. #define SDLA_FLUSH_COMMS_ERR_STATS 0x33
  163. #define SDLA_READ_CODE_VERSION 0x40
  164. #define SDLA_SET_IRQ_TRIGGER 0x50
  165. #define SDLA_GET_IRQ_TRIGGER 0x51
  166. /* In channel signal types */
  167. #define SDLA_ICS_LINK_VERIFY 0x02
  168. #define SDLA_ICS_STATUS_ENQ 0x03
  169. /* modem status flags */
  170. #define SDLA_MODEM_DTR_HIGH 0x01
  171. #define SDLA_MODEM_RTS_HIGH 0x02
  172. #define SDLA_MODEM_DCD_HIGH 0x08
  173. #define SDLA_MODEM_CTS_HIGH 0x20
  174. /* used for RET_MODEM interpretation */
  175. #define SDLA_MODEM_DCD_LOW 0x01
  176. #define SDLA_MODEM_CTS_LOW 0x02
  177. /* return codes */
  178. #define SDLA_RET_OK 0x00
  179. #define SDLA_RET_COMMUNICATIONS 0x01
  180. #define SDLA_RET_CHANNEL_INACTIVE 0x02
  181. #define SDLA_RET_DLCI_INACTIVE 0x03
  182. #define SDLA_RET_DLCI_CONFIG 0x04
  183. #define SDLA_RET_BUF_TOO_BIG 0x05
  184. #define SDLA_RET_NO_DATA 0x05
  185. #define SDLA_RET_BUF_OVERSIZE 0x06
  186. #define SDLA_RET_CIR_OVERFLOW 0x07
  187. #define SDLA_RET_NO_BUFS 0x08
  188. #define SDLA_RET_TIMEOUT 0x0A
  189. #define SDLA_RET_MODEM 0x10
  190. #define SDLA_RET_CHANNEL_OFF 0x11
  191. #define SDLA_RET_CHANNEL_ON 0x12
  192. #define SDLA_RET_DLCI_STATUS 0x13
  193. #define SDLA_RET_DLCI_UNKNOWN 0x14
  194. #define SDLA_RET_COMMAND_INVALID 0x1F
  195. /* Configuration flags */
  196. #define SDLA_DIRECT_RECV 0x0080
  197. #define SDLA_TX_NO_EXCEPT 0x0020
  198. #define SDLA_NO_ICF_MSGS 0x1000
  199. #define SDLA_TX50_RX50 0x0000
  200. #define SDLA_TX70_RX30 0x2000
  201. #define SDLA_TX30_RX70 0x4000
  202. /* IRQ selection flags */
  203. #define SDLA_IRQ_RECEIVE 0x01
  204. #define SDLA_IRQ_TRANSMIT 0x02
  205. #define SDLA_IRQ_MODEM_STAT 0x04
  206. #define SDLA_IRQ_COMMAND 0x08
  207. #define SDLA_IRQ_CHANNEL 0x10
  208. #define SDLA_IRQ_TIMER 0x20
  209. /* definitions for PC memory mapping */
  210. #define SDLA_8K_WINDOW 0x01
  211. #define SDLA_S502_SEG_A 0x10
  212. #define SDLA_S502_SEG_C 0x20
  213. #define SDLA_S502_SEG_D 0x00
  214. #define SDLA_S502_SEG_E 0x30
  215. #define SDLA_S507_SEG_A 0x00
  216. #define SDLA_S507_SEG_B 0x40
  217. #define SDLA_S507_SEG_C 0x80
  218. #define SDLA_S507_SEG_E 0xC0
  219. #define SDLA_S508_SEG_A 0x00
  220. #define SDLA_S508_SEG_C 0x10
  221. #define SDLA_S508_SEG_D 0x08
  222. #define SDLA_S508_SEG_E 0x18
  223. /* SDLA adapter port constants */
  224. #define SDLA_IO_EXTENTS 0x04
  225. #define SDLA_REG_CONTROL 0x00
  226. #define SDLA_REG_PC_WINDOW 0x01 /* offset for PC window select latch */
  227. #define SDLA_REG_Z80_WINDOW 0x02 /* offset for Z80 window select latch */
  228. #define SDLA_REG_Z80_CONTROL 0x03 /* offset for Z80 control latch */
  229. #define SDLA_S502_STS 0x00 /* status reg for 502, 502E, 507 */
  230. #define SDLA_S508_GNRL 0x00 /* general purp. reg for 508 */
  231. #define SDLA_S508_STS 0x01 /* status reg for 508 */
  232. #define SDLA_S508_IDR 0x02 /* ID reg for 508 */
  233. /* control register flags */
  234. #define SDLA_S502A_START 0x00 /* start the CPU */
  235. #define SDLA_S502A_INTREQ 0x02
  236. #define SDLA_S502A_INTEN 0x04
  237. #define SDLA_S502A_HALT 0x08 /* halt the CPU */
  238. #define SDLA_S502A_NMI 0x10 /* issue an NMI to the CPU */
  239. #define SDLA_S502E_CPUEN 0x01
  240. #define SDLA_S502E_ENABLE 0x02
  241. #define SDLA_S502E_INTACK 0x04
  242. #define SDLA_S507_ENABLE 0x01
  243. #define SDLA_S507_IRQ3 0x00
  244. #define SDLA_S507_IRQ4 0x20
  245. #define SDLA_S507_IRQ5 0x40
  246. #define SDLA_S507_IRQ7 0x60
  247. #define SDLA_S507_IRQ10 0x80
  248. #define SDLA_S507_IRQ11 0xA0
  249. #define SDLA_S507_IRQ12 0xC0
  250. #define SDLA_S507_IRQ15 0xE0
  251. #define SDLA_HALT 0x00
  252. #define SDLA_CPUEN 0x02
  253. #define SDLA_MEMEN 0x04
  254. #define SDLA_S507_EPROMWR 0x08
  255. #define SDLA_S507_EPROMCLK 0x10
  256. #define SDLA_S508_INTRQ 0x08
  257. #define SDLA_S508_INTEN 0x10
  258. struct sdla_cmd {
  259. char opp_flag;
  260. char cmd;
  261. short length;
  262. char retval;
  263. short dlci;
  264. char flags;
  265. short rxlost_int;
  266. long rxlost_app;
  267. char reserve[2];
  268. char data[SDLA_MAX_DATA]; /* transfer data buffer */
  269. } __attribute__((packed));
  270. struct intr_info {
  271. char flags;
  272. short txlen;
  273. char irq;
  274. char flags2;
  275. short timeout;
  276. } __attribute__((packed));
  277. /* found in the 508's control window at RXBUF_INFO */
  278. struct buf_info {
  279. unsigned short rse_num;
  280. unsigned long rse_base;
  281. unsigned long rse_next;
  282. unsigned long buf_base;
  283. unsigned short reserved;
  284. unsigned long buf_top;
  285. } __attribute__((packed));
  286. /* structure pointed to by rse_base in RXBUF_INFO struct */
  287. struct buf_entry {
  288. char opp_flag;
  289. short length;
  290. short dlci;
  291. char flags;
  292. short timestamp;
  293. short reserved[2];
  294. long buf_addr;
  295. } __attribute__((packed));
  296. #endif
  297. #endif