hysdn_defs.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:11k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* $Id: hysdn_defs.h,v 1.1.4.1 2001/11/20 14:19:37 kai Exp $
  2.  *
  3.  * Linux driver for HYSDN cards
  4.  * global definitions and exported vars and functions.
  5.  *
  6.  * Author    Werner Cornelius (werner@titro.de) for Hypercope GmbH
  7.  * Copyright 1999 by Werner Cornelius (werner@titro.de)
  8.  *
  9.  * This software may be used and distributed according to the terms
  10.  * of the GNU General Public License, incorporated herein by reference.
  11.  *
  12.  */
  13. #ifndef HYSDN_DEFS_H
  14. #define HYSDN_DEFS_H
  15. #include <linux/config.h>
  16. #include <linux/hysdn_if.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/tqueue.h>
  19. #include <linux/skbuff.h>
  20. /****************************/
  21. /* storage type definitions */
  22. /****************************/
  23. #define uchar unsigned char
  24. #define uint unsigned int
  25. #define ulong unsigned long
  26. #define word unsigned short
  27. #include "ince1pc.h"
  28. #ifdef CONFIG_HYSDN_CAPI
  29. #include <linux/capi.h>
  30. #include "../avmb1/capicmd.h"
  31. #include "../avmb1/capiutil.h"
  32. #include "../avmb1/capilli.h"
  33. /***************************/
  34. /*   CAPI-Profile values.  */
  35. /***************************/
  36. #define GLOBAL_OPTION_INTERNAL_CONTROLLER 0x0001
  37. #define GLOBAL_OPTION_EXTERNAL_CONTROLLER 0x0002
  38. #define GLOBAL_OPTION_HANDSET             0x0004
  39. #define GLOBAL_OPTION_DTMF                0x0008
  40. #define GLOBAL_OPTION_SUPPL_SERVICES      0x0010
  41. #define GLOBAL_OPTION_CHANNEL_ALLOCATION  0x0020
  42. #define GLOBAL_OPTION_B_CHANNEL_OPERATION 0x0040
  43. #define B1_PROT_64KBIT_HDLC        0x0001
  44. #define B1_PROT_64KBIT_TRANSPARENT 0x0002
  45. #define B1_PROT_V110_ASYNCH        0x0004 
  46. #define B1_PROT_V110_SYNCH         0x0008
  47. #define B1_PROT_T30                0x0010
  48. #define B1_PROT_64KBIT_INV_HDLC    0x0020
  49. #define B1_PROT_56KBIT_TRANSPARENT 0x0040
  50. #define B2_PROT_ISO7776            0x0001
  51. #define B2_PROT_TRANSPARENT        0x0002
  52. #define B2_PROT_SDLC               0x0004
  53. #define B2_PROT_LAPD               0x0008
  54. #define B2_PROT_T30                0x0010
  55. #define B2_PROT_PPP                0x0020
  56. #define B2_PROT_TRANSPARENT_IGNORE_B1_FRAMING_ERRORS 0x0040
  57. #define B3_PROT_TRANSPARENT        0x0001
  58. #define B3_PROT_T90NL              0x0002
  59. #define B3_PROT_ISO8208            0x0004
  60. #define B3_PROT_X25_DCE            0x0008
  61. #define B3_PROT_T30                0x0010
  62. #define B3_PROT_T30EXT             0x0020
  63. #define HYSDN_MAXVERSION 8
  64. /* Number of sendbuffers in CAPI-queue */
  65. #define HYSDN_MAX_CAPI_SKB             20
  66. #endif /* CONFIG_HYSDN_CAPI*/
  67. /************************************************/
  68. /* constants and bits for debugging/log outputs */
  69. /************************************************/
  70. #define LOG_MAX_LINELEN 120
  71. #define DEB_OUT_SYSLOG  0x80000000 /* output to syslog instead of proc fs */
  72. #define LOG_MEM_ERR     0x00000001 /* log memory errors like kmalloc failure */
  73. #define LOG_POF_OPEN    0x00000010 /* log pof open and close activities */
  74. #define LOG_POF_RECORD  0x00000020 /* log pof record parser */
  75. #define LOG_POF_WRITE   0x00000040 /* log detailed pof write operation */
  76. #define LOG_POF_CARD    0x00000080 /* log pof related card functions */
  77. #define LOG_CNF_LINE    0x00000100 /* all conf lines are put to procfs */
  78. #define LOG_CNF_DATA    0x00000200 /* non comment conf lines are shown with channel */
  79. #define LOG_CNF_MISC    0x00000400 /* additional conf line debug outputs */
  80. #define LOG_SCHED_ASYN  0x00001000 /* debug schedulers async tx routines */
  81. #define LOG_PROC_OPEN   0x00100000 /* open and close from procfs are logged */
  82. #define LOG_PROC_ALL    0x00200000 /* all actions from procfs are logged */
  83. #define LOG_NET_INIT    0x00010000 /* network init and deinit logging */
  84. #define DEF_DEB_FLAGS   0x7fff000f /* everything is logged to procfs */
  85. /**********************************/
  86. /* proc filesystem name constants */
  87. /**********************************/
  88. #define PROC_SUBDIR_NAME "hysdn"
  89. #define PROC_CONF_BASENAME "cardconf"
  90. #define PROC_LOG_BASENAME "cardlog"
  91. /***********************************/
  92. /* PCI 32 bit parms for IO and MEM */
  93. /***********************************/
  94. #define PCI_REG_PLX_MEM_BASE    0
  95. #define PCI_REG_PLX_IO_BASE     1
  96. #define PCI_REG_MEMORY_BASE     3
  97. /**************/
  98. /* card types */
  99. /**************/
  100. #define BD_NONE         0U
  101. #define BD_PERFORMANCE  1U
  102. #define BD_VALUE        2U
  103. #define BD_PCCARD       3U
  104. #define BD_ERGO         4U
  105. #define BD_METRO        5U
  106. #define BD_CHAMP2       6U
  107. #define BD_PLEXUS       7U
  108. /******************************************************/
  109. /* defined states for cards shown by reading cardconf */
  110. /******************************************************/
  111. #define CARD_STATE_UNUSED   0 /* never been used or booted */
  112. #define CARD_STATE_BOOTING  1 /* booting is in progress */
  113. #define CARD_STATE_BOOTERR  2 /* a previous boot was aborted */
  114. #define CARD_STATE_RUN      3 /* card is active */
  115. /*******************************/
  116. /* defines for error_log_state */
  117. /*******************************/
  118. #define ERRLOG_STATE_OFF   0 /* error log is switched off, nothing to do */
  119. #define ERRLOG_STATE_ON    1 /* error log is switched on, wait for data */
  120. #define ERRLOG_STATE_START 2 /* start error logging */
  121. #define ERRLOG_STATE_STOP  3 /* stop error logging */
  122. /*******************************/
  123. /* data structure for one card */
  124. /*******************************/
  125. typedef struct HYSDN_CARD {
  126. /* general variables for the cards */
  127. int myid; /* own driver card id */
  128. uchar bus; /* pci bus the card is connected to */
  129. uchar devfn; /* slot+function bit encoded */
  130. word subsysid; /* PCI subsystem id */
  131. uchar brdtype; /* type of card */
  132. uint bchans; /* number of available B-channels */
  133. uint faxchans; /* number of available fax-channels */
  134. uchar mac_addr[6]; /* MAC Address read from card */
  135. uint irq; /* interrupt number */
  136. uint iobase; /* IO-port base address */
  137. ulong plxbase; /* PLX memory base */
  138. ulong membase; /* DPRAM memory base */
  139. ulong memend; /* DPRAM memory end */
  140. void *dpram; /* mapped dpram */
  141. int state; /* actual state of card -> CARD_STATE_** */
  142. struct HYSDN_CARD *next; /* pointer to next card */
  143. /* data areas for the /proc file system */
  144. void *proclog; /* pointer to proclog filesystem specific data */
  145. void *procconf; /* pointer to procconf filesystem specific data */
  146. /* debugging and logging */
  147. uchar err_log_state; /* actual error log state of the card */
  148. ulong debug_flags; /* tells what should be debugged and where */
  149. void (*set_errlog_state) (struct HYSDN_CARD *, int);
  150. /* interrupt handler + interrupt synchronisation */
  151. struct tq_struct irq_queue; /* interrupt task queue */
  152. uchar volatile irq_enabled; /* interrupt enabled if != 0 */
  153. uchar volatile hw_lock; /* hardware is currently locked -> no access */
  154. /* boot process */
  155. void *boot; /* pointer to boot private data */
  156. int (*writebootimg) (struct HYSDN_CARD *, uchar *, ulong);
  157. int (*writebootseq) (struct HYSDN_CARD *, uchar *, int);
  158. int (*waitpofready) (struct HYSDN_CARD *);
  159. int (*testram) (struct HYSDN_CARD *);
  160. /* scheduler for data transfer (only async parts) */
  161. uchar async_data[256]; /* async data to be sent (normally for config) */
  162. word volatile async_len; /* length of data to sent */
  163. word volatile async_channel; /* channel number for async transfer */
  164. int volatile async_busy; /* flag != 0 sending in progress */
  165. int volatile net_tx_busy; /* a network packet tx is in progress */
  166. /* network interface */
  167. void *netif; /* pointer to network structure */
  168. /* init and deinit stopcard for booting, too */
  169. void (*stopcard) (struct HYSDN_CARD *);
  170. void (*releasehardware) (struct HYSDN_CARD *);
  171. #ifdef CONFIG_HYSDN_CAPI
  172. struct hycapictrl_info {
  173. char cardname[32];
  174. spinlock_t lock;
  175. int versionlen;
  176. char versionbuf[1024];
  177. char *version[HYSDN_MAXVERSION];
  178. char infobuf[128]; /* for function procinfo */
  179. struct HYSDN_CARD  *card;
  180. struct capi_ctr *capi_ctrl;
  181. struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB];
  182. int in_idx, out_idx; /* indexes to buffer ring */
  183. int sk_count; /* number of buffers currently in ring */
  184. struct sk_buff *tx_skb; /* buffer for tx operation */
  185. } *hyctrlinfo;
  186. #endif /* CONFIG_HYSDN_CAPI */
  187. } hysdn_card;
  188. #ifdef CONFIG_HYSDN_CAPI
  189. typedef struct hycapictrl_info hycapictrl_info;
  190. #endif /* CONFIG_HYSDN_CAPI */
  191. /*****************/
  192. /* exported vars */
  193. /*****************/
  194. extern int cardmax; /* number of found cards */
  195. extern hysdn_card *card_root; /* pointer to first card */
  196. /*************************/
  197. /* im/exported functions */
  198. /*************************/
  199. extern int printk(const char *fmt,...);
  200. extern char *hysdn_getrev(const char *);
  201. /* hysdn_procconf.c */
  202. extern int hysdn_procconf_init(void); /* init proc config filesys */
  203. extern void hysdn_procconf_release(void); /* deinit proc config filesys */
  204. /* hysdn_proclog.c */
  205. extern int hysdn_proclog_init(hysdn_card *); /* init proc log entry */
  206. extern void hysdn_proclog_release(hysdn_card *); /* deinit proc log entry */
  207. extern void put_log_buffer(hysdn_card *, char *); /* output log data */
  208. extern void hysdn_addlog(hysdn_card *, char *,...); /* output data to log */
  209. extern void hysdn_card_errlog(hysdn_card *, tErrLogEntry *, int); /* output card log */
  210. /* boardergo.c */
  211. extern int ergo_inithardware(hysdn_card * card); /* get hardware -> module init */
  212. /* hysdn_boot.c */
  213. extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */
  214. extern int pof_write_open(hysdn_card *, uchar **); /* open proc file for writing pof */
  215. extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */
  216. extern int EvalSysrTokData(hysdn_card *, uchar *, int); /* Check Sysready Token Data */
  217. /* hysdn_sched.c */
  218. extern int hysdn_sched_tx(hysdn_card *, uchar *, word volatile *, word volatile *,
  219.   word);
  220. extern int hysdn_sched_rx(hysdn_card *, uchar *, word, word);
  221. extern int hysdn_tx_cfgline(hysdn_card *, uchar *, word); /* send one cfg line */
  222. /* hysdn_net.c */
  223. extern unsigned int hynet_enable; 
  224. extern char *hysdn_net_revision;
  225. extern int hysdn_net_create(hysdn_card *); /* create a new net device */
  226. extern int hysdn_net_release(hysdn_card *); /* delete the device */
  227. extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */
  228. extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */
  229. extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */
  230. extern void hysdn_rx_netpkt(hysdn_card *, uchar *, word); /* rxed packet from network */
  231. #ifdef CONFIG_HYSDN_CAPI
  232. extern unsigned int hycapi_enable; 
  233. extern struct capi_driver_interface *hy_di;
  234. extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */
  235. extern int hycapi_capi_release(hysdn_card *); /* delete the device */
  236. extern int hycapi_capi_stop(hysdn_card *card);   /* suspend */
  237. extern int hycapi_load_firmware(struct capi_ctr *, capiloaddata *);
  238. extern void hycapi_reset_ctr(struct capi_ctr *);
  239. extern void hycapi_remove_ctr(struct capi_ctr *);
  240. extern void hycapi_register_appl(struct capi_ctr *, __u16 appl,
  241.  capi_register_params *);
  242. extern void hycapi_release_appl(struct capi_ctr *, __u16 appl);
  243. extern void hycapi_send_message(struct capi_ctr *, struct sk_buff *skb);
  244. extern char *hycapi_procinfo(struct capi_ctr *);
  245. extern int hycapi_read_proc(char *page, char **start, off_t off,
  246.     int count, int *eof, struct capi_ctr *card);
  247. extern void hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len);
  248. extern void hycapi_tx_capiack(hysdn_card * card);
  249. extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card);
  250. extern int hycapi_init(void);
  251. extern void hycapi_cleanup(void);
  252. #endif /* CONFIG_HYSDN_CAPI */
  253. #endif /* HYSDN_DEFS_H */