import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / drivers / isdn / eicon / adapter.h
1 /*
2  * Main internal include file for Diva Server driver
3  *
4  * Copyright (C) Eicon Technology Corporation, 2000.
5  *
6  * Eicon File Revision :    1.7  
7  *
8  * This software may be used and distributed according to the terms
9  * of the GNU General Public License, incorporated herein by reference.
10  *
11  */
12
13 #if !defined(ADAPTER_H)
14 #define ADAPTER_H
15
16 #include "sys.h"
17 #include "idi.h"
18 #include "divas.h"
19 #undef ID_MASK
20 #include "pc.h"
21
22 #define XMOREC 0x1f
23 #define XMOREF 0x20
24 #define XBUSY  0x40
25 #define RMORE  0x80
26
27         /* structure for all information we have to keep on a per   */
28         /* adapater basis                                           */
29
30 typedef struct adapter_s ADAPTER;
31
32 struct adapter_s {
33   void * io;
34
35   byte IdTable[256];
36   byte ReadyInt;
37
38   byte (* ram_in)(ADAPTER * a, void * adr);
39   word (* ram_inw)(ADAPTER * a, void * adr);
40   void (* ram_in_buffer)(ADAPTER * a, void * adr, void * P, word length);
41   void (* ram_look_ahead)(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e);
42
43   void (* ram_out)(ADAPTER * a, void * adr, byte data);
44   void (* ram_outw)(ADAPTER * a, void * adr, word data);
45   void (* ram_out_buffer)(ADAPTER * a, void * adr, void * P, word length);
46
47   void (* ram_inc)(ADAPTER * a, void * adr);
48 };
49
50 typedef struct card card_t;
51
52 typedef int     card_load_fn_t(card_t *card, dia_load_t *load);
53 typedef int     card_config_fn_t(card_t *card, dia_config_t *config);
54 typedef int     card_start_fn_t(card_t *card, byte *channels);
55 typedef int     card_reset_fn_t(card_t *card);
56 typedef int card_mem_get_fn_t(card_t *card, mem_block_t *mem_block);
57
58 #define MAX_PENTITIES   256             /* Number of entities primary adapter */
59 #define MAX_ENTITIES    16              /* Number of entities standard adapter */
60
61 typedef struct e_info_s E_INFO;
62
63 struct e_info_s
64 {
65         ENTITY          *e;                             /* entity pointer */
66         byte            next;                   /* chaining index */
67         word            assign_ref;             /* assign reference */
68 };
69
70 /* DIVA card info (details hidden from user) */
71
72 typedef struct  ux_diva_card_s ux_diva_card_t;
73
74 /* card info */
75
76 struct card
77 {
78         ADAPTER                         a;                              /* per-adapter information */
79         dia_card_t                      cfg;                    /* card configuration */
80         int                             state;                  /* State of the adapter */
81         dword                           serial_no;              /* serial number */
82         int                             test_int_pend;  /* set for interrupt testing */
83         ux_diva_card_t          *hw;                    /* O/S-specific handle */
84         card_reset_fn_t         *card_reset;    /* call this to reset card */
85         card_load_fn_t          *card_load;             /* call this to load card */
86         card_config_fn_t        *card_config;   /* call this to config card */
87         card_start_fn_t         *card_start;    /* call this to start card */
88         card_mem_get_fn_t       *card_mem_get;  /* call this to get card memory */
89         E_INFO                          *e_tbl;                 /* table of ENTITY pointers */
90         byte                            e_head;                 /* list of active ENTITIES */
91         byte                            e_tail;                 /* list of active ENTITIES */
92         int                                     e_count;                /* # of active ENTITIES */
93         int                                     e_max;                  /* total # of ENTITIES */
94         byte                            assign;                 /* assign queue entry */
95         PBUFFER                         RBuffer;                /* Copy of receive lookahead buffer */
96         int                                     log_types;              /* bit-mask of active logs */
97         word                            xlog_offset;    /* offset to XLOG buffer on card */
98         void            (*out)(ADAPTER *a);
99         byte            (*dpc)(ADAPTER * a);
100         byte            (*test_int)(ADAPTER * a);
101         void            (*clear_int)(ADAPTER * a);
102         void            (*reset_int)(card_t *c);
103         int             is_live;
104
105         int             (*card_isr)(card_t *card);
106
107         int             int_pend;               /* interrupt pending */
108         long            interrupt_reentered;
109         long            dpc_reentered;
110         int             set_xlog_request;
111
112 } ;
113
114 /* card information */
115
116 #define MAX_CARDS       20              /* max number of cards on a system */
117
118 extern
119 card_t                  DivasCards[];
120
121 extern
122 int                             DivasCardNext;
123
124 extern
125 dia_config_t    DivasCardConfigs[];
126
127 extern
128 byte                    DivasFlavourConfig[];
129
130 /*------------------------------------------------------------------*/
131 /* public functions of IDI common code                              */
132 /*------------------------------------------------------------------*/
133
134 void DivasOut(ADAPTER * a);
135 byte DivasDpc(ADAPTER * a);
136 byte DivasTestInt(ADAPTER * a);
137 void DivasClearInt(ADAPTER * a);
138
139 /*------------------------------------------------------------------*/
140 /* public functions of configuration platform-specific code         */
141 /*------------------------------------------------------------------*/
142
143 int DivasConfigGet(dia_card_t *card);
144
145 /*------------------------------------------------------------------*/
146 /* public functions of LOG related code                             */
147 /*------------------------------------------------------------------*/
148
149 void    DivasXlogReq(int card_num);
150 int             DivasXlogRetrieve(card_t *card);
151 void    DivasLog(dia_log_t *log);
152 void    DivasLogIdi(card_t *card, ENTITY *e, int request);
153
154 /*------------------------------------------------------------------*/
155 /* public functions to initialise cards for each type supported     */
156 /*------------------------------------------------------------------*/
157
158 int             DivasPriInit(card_t *card, dia_card_t *cfg);
159
160 int             DivasBriInit(card_t *card, dia_card_t *cfg);
161 int             Divas4BriInit(card_t *card, dia_card_t *cfg);
162 void    DivasBriPatch(card_t *card);
163
164 /*------------------------------------------------------------------*/
165 /* public functions of log common code                              */
166 /*------------------------------------------------------------------*/
167
168 extern  char    *DivasLogFifoRead(void);
169 extern  void    DivasLogFifoWrite(char *entry, int length);
170 extern  int             DivasLogFifoEmpty(void);
171 extern  int             DivasLogFifoFull(void);
172 extern  void    DivasLogAdd(void *buffer, int length);
173
174 /*------------------------------------------------------------------*/
175 /* public functions of misc. platform-specific code                     */
176 /*------------------------------------------------------------------*/
177
178 int             DivasDpcSchedule(void);
179 void            DivasDoDpc(void *);
180 void            DivasDoRequestDpc(void *pData);
181 int             DivasScheduleRequestDpc(void);
182
183 /* table of IDI request functions */
184
185 extern
186 IDI_CALL        DivasIdiRequest[];
187
188 /*
189  * intialisation entry point
190  */
191
192 int             DivasInit(void);
193
194 /*
195  * Get information on the number and type of cards present
196  */
197
198 extern
199 int     DivasCardsDiscover(void);
200
201 /*
202  * initialise a new card
203  */
204
205 int             DivasCardNew(dia_card_t *card);
206
207 /*
208  * configure specified card
209  */
210
211 int             DivasCardConfig(dia_config_t *config);
212
213 /*
214  * load specified binary code onto card
215  */
216
217 int             DivasCardLoad(dia_load_t *load);
218
219 /*
220  * start specified card running
221  */
222
223 int             DivasCardStart(int card_id);
224
225 /*
226  * ISR for card
227  * Returns 0 if specified card was interrupting
228  */
229
230 int             DivasIsr(void *arg);
231
232 /*
233  * Get number of active cards
234  */
235
236 int             DivasGetNum(void);
237
238 /*
239  * Get list of active cards
240  */
241
242 int             DivasGetList(dia_card_list_t *card_list);
243
244 /* definitions common to several card types */
245
246 #define DIVAS_SHARED_OFFSET     (0x1000)
247
248 #endif /* ADAPTER_H */