1
2/*
3 *
4 Copyright (c) Eicon Networks, 2002.
5 *
6 This source file is supplied for the use with
7 Eicon Networks range of DIVA Server Adapters.
8 *
9 Eicon File Revision :    2.1
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, or (at your option)
14 any later version.
15 *
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
18 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the 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 *
25 */
26#ifndef __DIVA_SYNC__H
27#define __DIVA_SYNC__H
28#define IDI_SYNC_REQ_REMOVE             0x00
29#define IDI_SYNC_REQ_GET_NAME           0x01
30#define IDI_SYNC_REQ_GET_SERIAL         0x02
31#define IDI_SYNC_REQ_SET_POSTCALL       0x03
32#define IDI_SYNC_REQ_GET_XLOG           0x04
33#define IDI_SYNC_REQ_GET_FEATURES       0x05
34#define IDI_SYNC_REQ_USB_REGISTER       0x06
35#define IDI_SYNC_REQ_USB_RELEASE        0x07
36#define IDI_SYNC_REQ_USB_ADD_DEVICE     0x08
37#define IDI_SYNC_REQ_USB_START_DEVICE   0x09
38#define IDI_SYNC_REQ_USB_STOP_DEVICE    0x0A
39#define IDI_SYNC_REQ_USB_REMOVE_DEVICE  0x0B
40#define IDI_SYNC_REQ_GET_CARDTYPE       0x0C
41#define IDI_SYNC_REQ_GET_DBG_XLOG       0x0D
42#define DIVA_USB
43#define DIVA_USB_REQ                    0xAC
44#define DIVA_USB_TEST                   0xAB
45#define DIVA_USB_ADD_ADAPTER            0xAC
46#define DIVA_USB_REMOVE_ADAPTER         0xAD
47#define IDI_SYNC_REQ_SERIAL_HOOK        0x80
48#define IDI_SYNC_REQ_XCHANGE_STATUS     0x81
49#define IDI_SYNC_REQ_USB_HOOK           0x82
50#define IDI_SYNC_REQ_PORTDRV_HOOK       0x83
51#define IDI_SYNC_REQ_SLI                0x84   /*  SLI request from 3signal modem drivers */
52#define IDI_SYNC_REQ_RECONFIGURE        0x85
53#define IDI_SYNC_REQ_RESET              0x86
54#define IDI_SYNC_REQ_GET_85X_DEVICE_DATA     0x87
55#define IDI_SYNC_REQ_LOCK_85X                   0x88
56#define IDI_SYNC_REQ_DIVA_85X_USB_DATA_EXCHANGE 0x99
57#define IDI_SYNC_REQ_DIPORT_EXCHANGE_REQ   0x98
58#define IDI_SYNC_REQ_GET_85X_EXT_PORT_TYPE      0xA0
59/******************************************************************************/
60#define IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES  0x92
61/*
62  To receive XDI features:
63  1. set 'buffer_length_in_bytes' to length of you buffer
64  2. set 'features' to pointer to your buffer
65  3. issue synchronous request to XDI
66  4. Check that feature 'DIVA_XDI_EXTENDED_FEATURES_VALID' is present
67  after call. This feature does indicate that your request
68  was processed and XDI does support this synchronous request
69  5. if on return bit 31 (0x80000000) in 'buffer_length_in_bytes' is
70  set then provided buffer was too small, and bits 30-0 does
71  contain necessary length of buffer.
72  in this case only features that do find place in the buffer
73  are indicated to caller
74*/
75typedef struct _diva_xdi_get_extended_xdi_features {
76	dword buffer_length_in_bytes;
77	byte  *features;
78} diva_xdi_get_extended_xdi_features_t;
79/*
80  features[0]
81*/
82#define DIVA_XDI_EXTENDED_FEATURES_VALID          0x01
83#define DIVA_XDI_EXTENDED_FEATURE_CMA             0x02
84#define DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR       0x04
85#define DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS       0x08
86#define DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC    0x10
87#define DIVA_XDI_EXTENDED_FEATURE_RX_DMA          0x20
88#define DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA  0x40
89#define DIVA_XDI_EXTENDED_FEATURE_WIDE_ID         0x80
90#define DIVA_XDI_EXTENDED_FEATURES_MAX_SZ    1
91/******************************************************************************/
92#define IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR   0x93
93typedef struct _diva_xdi_get_adapter_sdram_bar {
94	dword bar;
95} diva_xdi_get_adapter_sdram_bar_t;
96/******************************************************************************/
97#define IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS   0x94
98/*
99  CAPI Parameters will be written in the caller's buffer
100*/
101typedef struct _diva_xdi_get_capi_parameters {
102	dword structure_length;
103	byte flag_dynamic_l1_down;
104	byte group_optimization_enabled;
105} diva_xdi_get_capi_parameters_t;
106/******************************************************************************/
107#define IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER   0x95
108/*
109  Get logical adapter number, as assigned by XDI
110  'controller' is starting with zero 'sub' controller number
111  in case of one adapter that supports multiple interfaces
112  'controller' is zero for Master adapter (and adapter that supports
113  only one interface)
114*/
115typedef struct _diva_xdi_get_logical_adapter_number {
116	dword logical_adapter_number;
117	dword controller;
118	dword total_controllers;
119} diva_xdi_get_logical_adapter_number_s_t;
120/******************************************************************************/
121#define IDI_SYNC_REQ_UP1DM_OPERATION   0x96
122/******************************************************************************/
123#define IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION 0x97
124#define IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC     0x01
125#define IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE      0x02
126typedef struct _diva_xdi_dma_descriptor_operation {
127	int operation;
128	int descriptor_number;
129	void *descriptor_address;
130	dword descriptor_magic;
131} diva_xdi_dma_descriptor_operation_t;
132/******************************************************************************/
133#define IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY   0x01
134#define IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY     0x02
135#define IDI_SYNC_REQ_DIDD_ADD_ADAPTER               0x03
136#define IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER            0x04
137#define IDI_SYNC_REQ_DIDD_READ_ADAPTER_ARRAY        0x05
138#define IDI_SYNC_REQ_DIDD_GET_CFG_LIB_IFC           0x10
139typedef struct _diva_didd_adapter_notify {
140	dword handle; /* Notification handle */
141	void *callback;
142	void *context;
143} diva_didd_adapter_notify_t;
144typedef struct _diva_didd_add_adapter {
145	void *descriptor;
146} diva_didd_add_adapter_t;
147typedef struct _diva_didd_remove_adapter {
148	IDI_CALL p_request;
149} diva_didd_remove_adapter_t;
150typedef struct _diva_didd_read_adapter_array {
151	void *buffer;
152	dword length;
153} diva_didd_read_adapter_array_t;
154typedef struct _diva_didd_get_cfg_lib_ifc {
155	void *ifc;
156} diva_didd_get_cfg_lib_ifc_t;
157/******************************************************************************/
158#define IDI_SYNC_REQ_XDI_GET_STREAM    0x91
159#define DIVA_XDI_SYNCHRONOUS_SERVICE   0x01
160#define DIVA_XDI_DMA_SERVICE           0x02
161#define DIVA_XDI_AUTO_SERVICE          0x03
162#define DIVA_ISTREAM_COMPLETE_NOTIFY   0
163#define DIVA_ISTREAM_COMPLETE_READ     1
164#define DIVA_ISTREAM_COMPLETE_WRITE    2
165typedef struct _diva_xdi_stream_interface {
166	unsigned char  Id;                 /* filled by XDI client */
167	unsigned char provided_service;    /* filled by XDI        */
168	unsigned char requested_service;   /* filled by XDI Client */
169	void *xdi_context;    /* filled by XDI */
170	void *client_context;   /* filled by XDI client */
171	int (*write)(void *context,
172		     int Id,
173		     void *data,
174		     int length,
175		     int final,
176		     byte usr1,
177		     byte usr2);
178	int (*read)(void *context,
179		    int Id,
180		    void *data,
181		    int max_length,
182		    int *final,
183		    byte *usr1,
184		    byte *usr2);
185	int (*complete)(void *client_context,
186			int Id,
187			int what,
188			void *data,
189			int length,
190			int *final);
191} diva_xdi_stream_interface_t;
192/******************************************************************************/
193/*
194 * IDI_SYNC_REQ_SERIAL_HOOK - special interface for the DIVA Mobile card
195 */
196typedef struct
197{ unsigned char LineState;         /* Modem line state (STATUS_R) */
198#define SERIAL_GSM_CELL 0x01   /* GSM or CELL cable attached  */
199	unsigned char CardState;          /* PCMCIA card state (0 = down) */
200	unsigned char IsdnState;          /* ISDN layer 1 state (0 = down)*/
201	unsigned char HookState;          /* current logical hook state */
202#define SERIAL_ON_HOOK 0x02   /* set in DIVA CTRL_R register */
203} SERIAL_STATE;
204typedef int (*SERIAL_INT_CB)(void *Context);
205typedef int (*SERIAL_DPC_CB)(void *Context);
206typedef unsigned char (*SERIAL_I_SYNC)(void *Context);
207typedef struct
208{ /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */
209	unsigned char Req;             /* request (must be always 0) */
210	unsigned char Rc;              /* return code (is the request) */
211	unsigned char Function;           /* private function code  */
212#define SERIAL_HOOK_ATTACH 0x81
213#define SERIAL_HOOK_STATUS 0x82
214#define SERIAL_HOOK_I_SYNC 0x83
215#define SERIAL_HOOK_NOECHO 0x84
216#define SERIAL_HOOK_RING 0x85
217#define SERIAL_HOOK_DETACH 0x8f
218	unsigned char Flags;           /* function refinements   */
219	/* parameters passed by the ATTACH request      */
220	SERIAL_INT_CB InterruptHandler; /* called on each interrupt  */
221	SERIAL_DPC_CB DeferredHandler; /* called on hook state changes */
222	void   *HandlerContext; /* context for both handlers */
223	/* return values for both the ATTACH and the STATUS request   */
224	unsigned long IoBase;    /* IO port assigned to UART  */
225	SERIAL_STATE State;
226	/* parameters and return values for the I_SYNC function    */
227	SERIAL_I_SYNC SyncFunction;  /* to be called synchronized */
228	void   *SyncContext;  /* context for this function */
229	unsigned char SyncResult;   /* return value of function  */
230} SERIAL_HOOK;
231/*
232 * IDI_SYNC_REQ_XCHANGE_STATUS - exchange the status between IDI and WMP
233 * IDI_SYNC_REQ_RECONFIGURE - reconfiguration of IDI from WMP
234 */
235typedef struct
236{ /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */
237	unsigned char Req;             /* request (must be always 0) */
238	unsigned char Rc;              /* return code (is the request) */
239#define DRIVER_STATUS_BOOT  0xA1
240#define DRIVER_STATUS_INIT_DEV 0xA2
241#define DRIVER_STATUS_RUNNING 0xA3
242#define DRIVER_STATUS_SHUTDOWN 0xAF
243#define DRIVER_STATUS_TRAPPED 0xAE
244	unsigned char wmpStatus;          /* exported by WMP              */
245	unsigned char idiStatus;   /* exported by IDI              */
246	unsigned long wizProto;   /* from WMP registry to IDI     */
247	/* the cardtype value is defined by cardtype.h */
248	unsigned long cardType;   /* from IDI registry to WMP     */
249	unsigned long nt2;    /* from IDI registry to WMP     */
250	unsigned long permanent;   /* from IDI registry to WMP     */
251	unsigned long stableL2;   /* from IDI registry to WMP     */
252	unsigned long tei;    /* from IDI registry to WMP     */
253#define CRC4_MASK   0x00000003
254#define L1_TRISTATE_MASK 0x00000004
255#define WATCHDOG_MASK  0x00000008
256#define NO_ORDER_CHECK_MASK 0x00000010
257#define LOW_CHANNEL_MASK 0x00000020
258#define NO_HSCX30_MASK  0x00000040
259#define SET_BOARD   0x00001000
260#define SET_CRC4   0x00030000
261#define SET_L1_TRISTATE  0x00040000
262#define SET_WATCHDOG  0x00080000
263#define SET_NO_ORDER_CHECK 0x00100000
264#define SET_LOW_CHANNEL  0x00200000
265#define SET_NO_HSCX30  0x00400000
266#define SET_MODE   0x00800000
267#define SET_PROTO   0x02000000
268#define SET_CARDTYPE  0x04000000
269#define SET_NT2    0x08000000
270#define SET_PERMANENT  0x10000000
271#define SET_STABLEL2  0x20000000
272#define SET_TEI    0x40000000
273#define SET_NUMBERLEN  0x80000000
274	unsigned long Flag;  /* |31-Type-16|15-Mask-0| */
275	unsigned long NumberLen; /* reconfiguration: union is empty */
276	union {
277		struct {    /* possible reconfiguration, but ... ; SET_BOARD */
278			unsigned long SerialNumber;
279			char     *pCardname; /* di_defs.h: BOARD_NAME_LENGTH */
280		} board;
281		struct {      /* reset: need resources */
282			void *pRawResources;
283			void *pXlatResources;
284		} res;
285		struct { /* reconfiguration: wizProto == PROTTYPE_RBSCAS */
286#define GLARE_RESOLVE_MASK 0x00000001
287#define DID_MASK   0x00000002
288#define BEARER_CAP_MASK  0x0000000c
289#define SET_GLARE_RESOLVE 0x00010000
290#define SET_DID    0x00020000
291#define SET_BEARER_CAP  0x000c0000
292			unsigned long Flag;  /* |31-Type-16|15-VALUE-0| */
293			unsigned short DigitTimeout;
294			unsigned short AnswerDelay;
295		} rbs;
296		struct { /* reconfiguration: wizProto == PROTTYPE_QSIG */
297#define CALL_REF_LENGTH1_MASK 0x00000001
298#define BRI_CHANNEL_ID_MASK  0x00000002
299#define SET_CALL_REF_LENGTH  0x00010000
300#define SET_BRI_CHANNEL_ID  0x00020000
301			unsigned long Flag;  /* |31-Type-16|15-VALUE-0| */
302		} qsig;
303		struct { /* reconfiguration: NumberLen != 0 */
304#define SET_SPID1   0x00010000
305#define SET_NUMBER1   0x00020000
306#define SET_SUBADDRESS1  0x00040000
307#define SET_SPID2   0x00100000
308#define SET_NUMBER2   0x00200000
309#define SET_SUBADDRESS2  0x00400000
310#define MASK_SET   0xffff0000
311			unsigned long Flag;   /* |31-Type-16|15-Channel-0| */
312			unsigned char *pBuffer; /* number value */
313		} isdnNo;
314	}
315		parms
316		;
317} isdnProps;
318/*
319 * IDI_SYNC_REQ_PORTDRV_HOOK - signal plug/unplug (Award Cardware only)
320 */
321typedef void (*PORTDRV_HOOK_CB)(void *Context, int Plug);
322typedef struct
323{ /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */
324	unsigned char Req;             /* request (must be always 0) */
325	unsigned char Rc;              /* return code (is the request) */
326	unsigned char Function;           /* private function code  */
327	unsigned char Flags;           /* function refinements   */
328	PORTDRV_HOOK_CB Callback;   /* to be called on plug/unplug */
329	void   *Context;   /* context for callback   */
330	unsigned long Info;    /* more info if needed   */
331} PORTDRV_HOOK;
332/*  Codes for the 'Rc' element in structure below. */
333#define SLI_INSTALL     (0xA1)
334#define SLI_UNINSTALL   (0xA2)
335typedef int (*SLIENTRYPOINT)(void *p3SignalAPI, void *pContext);
336typedef struct
337{   /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */
338	unsigned char   Req;                /* request (must be always 0)   */
339	unsigned char   Rc;                 /* return code (is the request) */
340	unsigned char   Function;           /* private function code        */
341	unsigned char   Flags;              /* function refinements         */
342	SLIENTRYPOINT   Callback;           /* to be called on plug/unplug  */
343	void            *Context;           /* context for callback         */
344	unsigned long   Info;               /* more info if needed          */
345} SLIENTRYPOINT_REQ;
346/******************************************************************************/
347/*
348 *  Definitions for DIVA USB
349 */
350typedef int (*USB_SEND_REQ)(unsigned char PipeIndex, unsigned char Type, void *Data, int sizeData);
351typedef int (*USB_START_DEV)(void *Adapter, void *Ipac);
352/* called from WDM */
353typedef void (*USB_RECV_NOTIFY)(void *Ipac, void *msg);
354typedef void (*USB_XMIT_NOTIFY)(void *Ipac, unsigned char PipeIndex);
355/******************************************************************************/
356/*
357 * Parameter description for synchronous requests.
358 *
359 * Sorry, must repeat some parts of di_defs.h here because
360 * they are not defined for all operating environments
361 */
362typedef union
363{ ENTITY Entity;
364	struct
365	{ /* 'Req' and 'Rc' are at the same place as in the ENTITY struct */
366		unsigned char   Req; /* request (must be always 0) */
367		unsigned char   Rc;  /* return code (is the request) */
368	}   Request;
369	struct
370	{ unsigned char   Req; /* request (must be always 0) */
371		unsigned char   Rc;  /* return code (0x01)   */
372		unsigned char   name[BOARD_NAME_LENGTH];
373	}   GetName;
374	struct
375	{ unsigned char   Req; /* request (must be always 0) */
376		unsigned char   Rc;  /* return code (0x02)   */
377		unsigned long   serial; /* serial number    */
378	}   GetSerial;
379	struct
380	{ unsigned char   Req; /* request (must be always 0) */
381		unsigned char   Rc;  /* return code (0x02)   */
382		unsigned long   lineIdx;/* line, 0 if card has only one */
383	}   GetLineIdx;
384	struct
385	{ unsigned char  Req;     /* request (must be always 0) */
386		unsigned char  Rc;      /* return code (0x02)   */
387		unsigned long  cardtype;/* card type        */
388	}   GetCardType;
389	struct
390	{ unsigned short command;/* command = 0x0300 */
391		unsigned short dummy; /* not used */
392		IDI_CALL       callback;/* routine to call back */
393		ENTITY      *contxt; /* ptr to entity to use */
394	}   PostCall;
395	struct
396	{ unsigned char  Req;  /* request (must be always 0) */
397		unsigned char  Rc;   /* return code (0x04)   */
398		unsigned char  pcm[1]; /* buffer (a pc_maint struct) */
399	}   GetXlog;
400	struct
401	{ unsigned char  Req;  /* request (must be always 0) */
402		unsigned char  Rc;   /* return code (0x05)   */
403		unsigned short features;/* feature defines see below */
404	}   GetFeatures;
405	SERIAL_HOOK  SerialHook;
406/* Added for DIVA USB */
407	struct
408	{ unsigned char   Req;
409		unsigned char   Rc;
410		USB_SEND_REQ    UsbSendRequest; /* function in Diva Usb WDM driver in usb_os.c, */
411		/* called from usb_drv.c to send a message to our device */
412		/* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0); */
413		USB_RECV_NOTIFY usb_recv;       /* called from usb_os.c to pass a received message and ptr to IPAC */
414		/* on to usb_drv.c by a call to usb_recv(). */
415		USB_XMIT_NOTIFY usb_xmit;       /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */
416		/* to usb_drv.c by a call to usb_xmit(). */
417		USB_START_DEV   UsbStartDevice; /* Start the USB Device, in usb_os.c */
418		IDI_CALL        callback;       /* routine to call back */
419		ENTITY          *contxt;     /* ptr to entity to use */
420		void **ipac_ptr;    /* pointer to struct IPAC in VxD */
421	} Usb_Msg_old;
422/* message used by WDM and VXD to pass pointers of function and IPAC* */
423	struct
424	{ unsigned char Req;
425		unsigned char Rc;
426		USB_SEND_REQ    pUsbSendRequest;/* function in Diva Usb WDM driver in usb_os.c, */
427		/* called from usb_drv.c to send a message to our device */
428		/* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0); */
429		USB_RECV_NOTIFY p_usb_recv;     /* called from usb_os.c to pass a received message and ptr to IPAC */
430		/* on to usb_drv.c by a call to usb_recv(). */
431		USB_XMIT_NOTIFY p_usb_xmit;     /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */
432		/* to usb_drv.c by a call to usb_xmit().*/
433		void            *ipac_ptr;      /* &Diva.ipac pointer to struct IPAC in VxD */
434	} Usb_Msg;
435	PORTDRV_HOOK PortdrvHook;
436	SLIENTRYPOINT_REQ   sliEntryPointReq;
437	struct {
438		unsigned char Req;
439		unsigned char Rc;
440		diva_xdi_stream_interface_t info;
441	} xdi_stream_info;
442	struct {
443		unsigned char Req;
444		unsigned char Rc;
445		diva_xdi_get_extended_xdi_features_t info;
446	} xdi_extended_features;
447	struct {
448		unsigned char Req;
449		unsigned char Rc;
450		diva_xdi_get_adapter_sdram_bar_t info;
451	} xdi_sdram_bar;
452	struct {
453		unsigned char Req;
454		unsigned char Rc;
455		diva_xdi_get_capi_parameters_t info;
456	} xdi_capi_prms;
457	struct {
458		ENTITY           e;
459		diva_didd_adapter_notify_t info;
460	} didd_notify;
461	struct {
462		ENTITY           e;
463		diva_didd_add_adapter_t   info;
464	} didd_add_adapter;
465	struct {
466		ENTITY           e;
467		diva_didd_remove_adapter_t info;
468	} didd_remove_adapter;
469	struct {
470		ENTITY             e;
471		diva_didd_read_adapter_array_t info;
472	} didd_read_adapter_array;
473	struct {
474		ENTITY             e;
475		diva_didd_get_cfg_lib_ifc_t     info;
476	} didd_get_cfg_lib_ifc;
477	struct {
478		unsigned char Req;
479		unsigned char Rc;
480		diva_xdi_get_logical_adapter_number_s_t info;
481	} xdi_logical_adapter_number;
482	struct {
483		unsigned char Req;
484		unsigned char Rc;
485		diva_xdi_dma_descriptor_operation_t info;
486	} xdi_dma_descriptor_operation;
487} IDI_SYNC_REQ;
488/******************************************************************************/
489#endif /* __DIVA_SYNC__H */
490