File: /usr/src/linux/drivers/isdn/sc/message.h

1     /*
2      *  $Id: message.h,v 1.1 1996/11/07 13:07:47 fritz Exp $
3      *  Copyright (C) 1996  SpellCaster Telecommunications Inc.
4      *
5      *  message.h - structures, macros and defines useful for sending
6      *              messages to the adapter
7      *
8      *  This program is free software; you can redistribute it and/or modify
9      *  it under the terms of the GNU General Public License as published by
10      *  the Free Software Foundation; either version 2 of the License, or
11      *  (at your option) any later version.
12      *
13      *  This program is distributed in the hope that it will be useful,
14      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16      *  GNU General Public License for more details.
17      *
18      *  You should have received a copy of the GNU General Public License
19      *  along with this program; if not, write to the Free Software
20      *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21      *
22      *  For more information, please contact gpl-info@spellcast.com or write:
23      *
24      *     SpellCaster Telecommunications Inc.
25      *     5621 Finch Avenue East, Unit #3
26      *     Scarborough, Ontario  Canada
27      *     M1B 2T9
28      *     +1 (416) 297-8565
29      *     +1 (416) 297-6433 Facsimile
30      */
31     
32     /*
33      * Board message macros, defines and structures
34      */
35      
36     #ifndef MESSAGE_H
37     #define MESSAGE_H
38     
39     #define MAX_MESSAGES		32	/* Maximum messages that can be
40     					   queued */
41     #define MSG_DATA_LEN		48	/* Maximum size of message payload */
42     #define MSG_LEN			64	/* Size of a message */
43     #define CMPID			0	/* Loader message process ID */
44     #define CEPID			64	/* Firmware message process ID */
45     
46     /*
47      * Macro to determine if a message is a loader message
48      */
49     #define IS_CM_MESSAGE(mesg, tx, cx, dx)		\
50     		((mesg.type == cmRspType##tx)		\
51     		&&(mesg.class == cmRspClass##cx)	\
52     		&&(mesg.code == cmRsp##dx))
53     
54     /*
55      * Macro to determine if a message is a firmware message
56      */
57     #define IS_CE_MESSAGE(mesg, tx, cx, dx)		\
58     		((mesg.type == ceRspType##tx)		\
59     		&&(mesg.class == ceRspClass##cx)	\
60     		&&(mesg.code == ceRsp##tx##dx))
61     
62     /* 
63      * Loader Request and Response Messages
64      */
65     
66     /* message types */
67     #define cmReqType1			1
68     #define cmReqType2			2
69     #define cmRspType0			0
70     #define cmRspType1			1
71     #define cmRspType2			2
72     #define cmRspType5			5
73     
74     /* message classes */
75     #define cmReqClass0			0
76     #define cmRspClass0			0
77     
78     /* message codes */
79     #define cmReqHWConfig		1			/* 1,0,1 */
80     #define cmReqMsgLpbk		2			/* 1,0,2 */
81     #define cmReqVersion		3			/* 1,0,3 */
82     #define cmReqLoadProc		1			/* 2,0,1 */
83     #define cmReqStartProc		2			/* 2,0,2 */
84     #define cmReqReadMem		6			/* 2,0,6 */
85     #define cmRspHWConfig		cmReqHWConfig
86     #define	cmRspMsgLpbk		cmReqMsgLpbk
87     #define cmRspVersion		cmReqVersion
88     #define cmRspLoadProc		cmReqLoadProc
89     #define cmRspStartProc		cmReqStartProc
90     #define	cmRspReadMem		cmReqReadMem
91     #define cmRspMiscEngineUp	1			/* 5,0,1 */
92     #define cmRspInvalid		0			/* 0,0,0 */
93     
94     
95     /*
96      * Firmware Request and Response Messages
97      */
98     
99     /* message types */
100     #define ceReqTypePhy		1
101     #define ceReqTypeLnk		2
102     #define ceReqTypeCall		3
103     #define ceReqTypeStat		1
104     #define ceRspTypeErr		0
105     #define	ceRspTypePhy		ceReqTypePhy
106     #define ceRspTypeLnk		ceReqTypeLnk
107     #define ceRspTypeCall		ceReqTypeCall
108     #define ceRspTypeStat		ceReqTypeStat
109     
110     /* message classes */
111     #define ceReqClass0		0
112     #define ceReqClass1		1
113     #define ceReqClass2		2
114     #define ceReqClass3		3
115     #define ceRspClass0		ceReqClass0
116     #define ceRspClass1		ceReqClass1
117     #define ceRspClass2		ceReqClass2
118     #define ceRspClass3		ceReqClass3
119     
120     /* message codes  (B) = BRI only, (P) = PRI only, (V) = POTS only */
121     #define ceReqPhyProcInfo	1			/* 1,0,1 */
122     #define ceReqPhyConnect		1			/* 1,1,1 */
123     #define ceReqPhyDisconnect	2			/* 1,1,2 */
124     #define ceReqPhySetParams	3			/* 1,1,3 (P) */
125     #define ceReqPhyGetParams	4			/* 1,1,4 (P) */
126     #define ceReqPhyStatus		1			/* 1,2,1 */
127     #define ceReqPhyAcfaStatus	2			/* 1,2,2 (P) */
128     #define ceReqPhyChCallState	3			/* 1,2,3 (P) */
129     #define ceReqPhyChServState	4			/* 1,2,4 (P) */
130     #define ceReqPhyRLoopBack	1			/* 1,3,1 */
131     #define ceRspPhyProcInfo	ceReqPhyProcInfo
132     #define	ceRspPhyConnect		ceReqPhyConnect
133     #define ceRspPhyDisconnect	ceReqPhyDisconnect
134     #define ceRspPhySetParams	ceReqPhySetParams
135     #define ceRspPhyGetParams	ceReqPhyGetParams
136     #define ceRspPhyStatus		ceReqPhyStatus
137     #define ceRspPhyAcfaStatus	ceReqPhyAcfaStatus
138     #define ceRspPhyChCallState	ceReqPhyChCallState
139     #define ceRspPhyChServState	ceReqPhyChServState
140     #define ceRspPhyRLoopBack	ceReqphyRLoopBack
141     #define ceReqLnkSetParam	1			/* 2,0,1 */
142     #define ceReqLnkGetParam	2			/* 2,0,2 */
143     #define ceReqLnkGetStats	3			/* 2,0,3 */
144     #define ceReqLnkWrite		1			/* 2,1,1 */
145     #define ceReqLnkRead		2			/* 2,1,2 */
146     #define ceReqLnkFlush		3			/* 2,1,3 */
147     #define ceReqLnkWrBufTrc	4			/* 2,1,4 */
148     #define ceReqLnkRdBufTrc	5			/* 2,1,5 */
149     #define ceRspLnkSetParam	ceReqLnkSetParam
150     #define ceRspLnkGetParam	ceReqLnkGetParam
151     #define ceRspLnkGetStats	ceReqLnkGetStats
152     #define ceRspLnkWrite		ceReqLnkWrite
153     #define ceRspLnkRead		ceReqLnkRead
154     #define ceRspLnkFlush		ceReqLnkFlush
155     #define ceRspLnkWrBufTrc	ceReqLnkWrBufTrc
156     #define ceRspLnkRdBufTrc	ceReqLnkRdBufTrc
157     #define ceReqCallSetSwitchType	1			/* 3,0,1 */
158     #define ceReqCallGetSwitchType	2			/* 3,0,2 */
159     #define ceReqCallSetFrameFormat	3			/* 3,0,3 */
160     #define ceReqCallGetFrameFormat	4			/* 3,0,4 */
161     #define ceReqCallSetCallType	5			/* 3,0,5 */
162     #define ceReqCallGetCallType	6			/* 3,0,6 */
163     #define ceReqCallSetSPID	7			/* 3,0,7 (!P) */
164     #define ceReqCallGetSPID	8			/* 3,0,8 (!P) */
165     #define ceReqCallSetMyNumber	9			/* 3,0,9 (!P) */
166     #define ceReqCallGetMyNumber	10			/* 3,0,10 (!P) */
167     #define	ceRspCallSetSwitchType	ceReqCallSetSwitchType
168     #define ceRspCallGetSwitchType	ceReqCallSetSwitchType
169     #define ceRspCallSetFrameFormat	ceReqCallSetFrameFormat
170     #define ceRspCallGetFrameFormat	ceReqCallGetFrameFormat
171     #define ceRspCallSetCallType	ceReqCallSetCallType
172     #define ceRspCallGetCallType	ceReqCallGetCallType
173     #define ceRspCallSetSPID	ceReqCallSetSPID
174     #define ceRspCallGetSPID	ceReqCallGetSPID
175     #define ceRspCallSetMyNumber	ceReqCallSetMyNumber
176     #define ceRspCallGetMyNumber	ceReqCallGetMyNumber
177     #define ceRspStatAcfaStatus	2
178     #define ceRspStat
179     #define ceRspErrError		0			/* 0,0,0 */
180     
181     /*
182      * Call Types
183      */
184     #define CALLTYPE_64K		0
185     #define CALLTYPE_56K		1
186     #define CALLTYPE_SPEECH		2
187     #define CALLTYPE_31KHZ		3
188     
189     /*
190      * Link Level data contains a pointer to and the length of
191      * a buffer in shared RAM. Used by LnkRead and LnkWrite message
192      * types. Part of RspMsgStruct and ReqMsgStruct.
193      */
194     typedef struct {
195     	unsigned long buff_offset;
196     	unsigned short msg_len;
197     } LLData;
198     
199     
200     /* 
201      * Message payload template for an HWConfig message
202      */
203     typedef struct {
204     	char st_u_sense;
205     	char powr_sense;
206     	char sply_sense;
207     	unsigned char asic_id;
208     	long ram_size;
209     	char serial_no[13];
210     	char part_no[13];
211     	char rev_no[2];
212     } HWConfig_pl;
213     
214     /*
215      * A Message
216      */
217     struct message {
218     	unsigned char sequence_no;
219     	unsigned char process_id;
220     	unsigned char time_stamp;
221     	unsigned char cmd_sequence_no;	/* Rsp messages only */
222     	unsigned char reserved1[3];
223     	unsigned char msg_byte_cnt;
224     	unsigned char type;
225     	unsigned char class;
226     	unsigned char code;
227     	unsigned char phy_link_no;
228     	unsigned char rsp_status;	/* Rsp messages only */
229     	unsigned char reseved2[3];
230     	union {
231     		unsigned char byte_array[MSG_DATA_LEN];
232     		LLData response;
233     		HWConfig_pl HWCresponse;
234     	} msg_data;
235     };
236     
237     typedef struct message ReqMessage;	/* Request message */
238     typedef struct message RspMessage;	/* Response message */
239     
240     /*
241      * The first 5010 bytes of shared memory contain the message queues,
242      * indexes and other data. This structure is its template
243      */
244     typedef struct {
245     	volatile ReqMessage req_queue[MAX_MESSAGES];
246     	volatile RspMessage rsp_queue[MAX_MESSAGES];
247     	volatile unsigned char req_head;
248     	volatile unsigned char req_tail;
249     	volatile unsigned char rsp_head;
250     	volatile unsigned char rsp_tail;
251     	volatile unsigned long signature;
252     	volatile unsigned long trace_enable;
253     	volatile unsigned char reserved[4];
254     } DualPortMemory;
255     
256     #endif
257