aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/sc/message.h
blob: 8eb15e7306b251a5095fe030b164f7e550511056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* $Id: message.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $
 *
 * Copyright (C) 1996  SpellCaster Telecommunications Inc.
 *
 * structures, macros and defines useful for sending
 * messages to the adapter
 *
 * This software may be used and distributed according to the terms
 * of the GNU General Public License, incorporated herein by reference.
 *
 * For more information, please contact gpl-info@spellcast.com or write:
 *
 *     SpellCaster Telecommunications Inc.
 *     5621 Finch Avenue East, Unit #3
 *     Scarborough, Ontario  Canada
 *     M1B 2T9
 *     +1 (416) 297-8565
 *     +1 (416) 297-6433 Facsimile
 */

/*
 * Board message macros, defines and structures
 */
 
#ifndef MESSAGE_H
#define MESSAGE_H

#define MAX_MESSAGES		32	/* Maximum messages that can be
					   queued */
#define MSG_DATA_LEN		48	/* Maximum size of message payload */
#define MSG_LEN			64	/* Size of a message */
#define CMPID			0	/* Loader message process ID */
#define CEPID			64	/* Firmware message process ID */

/*
 * Macro to determine if a message is a loader message
 */
#define IS_CM_MESSAGE(mesg, tx, cx, dx)		\
		((mesg.type == cmRspType##tx)		\
		&&(mesg.class == cmRspClass##cx)	\
		&&(mesg.code == cmRsp##dx))

/*
 * Macro to determine if a message is a firmware message
 */
#define IS_CE_MESSAGE(mesg, tx, cx, dx)		\
		((mesg.type == ceRspType##tx)		\
		&&(mesg.class == ceRspClass##cx)	\
		&&(mesg.code == ceRsp##tx##dx))

/* 
 * Loader Request and Response Messages
 */

/* message types */
#define cmReqType1			1
#define cmReqType2			2
#define cmRspType0			0
#define cmRspType1			1
#define cmRspType2			2
#define cmRspType5			5

/* message classes */
#define cmReqClass0			0
#define cmRspClass0			0

/* message codes */
#define cmReqHWConfig		1			/* 1,0,1 */
#define cmReqMsgLpbk		2			/* 1,0,2 */
#define cmReqVersion		3			/* 1,0,3 */
#define cmReqLoadProc		1			/* 2,0,1 */
#define cmReqStartProc		2			/* 2,0,2 */
#define cmReqReadMem		6			/* 2,0,6 */
#define cmRspHWConfig		cmReqHWConfig
#define	cmRspMsgLpbk		cmReqMsgLpbk
#define cmRspVersion		cmReqVersion
#define cmRspLoadProc		cmReqLoadProc
#define cmRspStartProc		cmReqStartProc
#define	cmRspReadMem		cmReqReadMem
#define cmRspMiscEngineUp	1			/* 5,0,1 */
#define cmRspInvalid		0			/* 0,0,0 */


/*
 * Firmware Request and Response Messages
 */

/* message types */
#define ceReqTypePhy		1
#define ceReqTypeLnk		2
#define ceReqTypeCall		3
#define ceReqTypeStat		1
#define ceRspTypeErr		0
#define	ceRspTypePhy		ceReqTypePhy
#define ceRspTypeLnk		ceReqTypeLnk
#define ceRspTypeCall		ceReqTypeCall
#define ceRspTypeStat		ceReqTypeStat

/* message classes */
#define ceReqClass0		0
#define ceReqClass1		1
#define ceReqClass2		2
#define ceReqClass3		3
#define ceRspClass0		ceReqClass0
#define ceRspClass1		ceReqClass1
#define ceRspClass2		ceReqClass2
#define ceRspClass3		ceReqClass3

/* message codes  (B) = BRI only, (P) = PRI only, (V) = POTS only */
#define ceReqPhyProcInfo	1			/* 1,0,1 */
#define ceReqPhyConnect		1			/* 1,1,1 */
#define ceReqPhyDisconnect	2			/* 1,1,2 */
#define ceReqPhySetParams	3			/* 1,1,3 (P) */
#define ceReqPhyGetParams	4			/* 1,1,4 (P) */
#define ceReqPhyStatus		1			/* 1,2,1 */
#define ceReqPhyAcfaStatus	2			/* 1,2,2 (P) */
#define ceReqPhyChCallState	3			/* 1,2,3 (P) */
#define ceReqPhyChServState	4			/* 1,2,4 (P) */
#define ceReqPhyRLoopBack	1			/* 1,3,1 */
#define ceRspPhyProcInfo	ceReqPhyProcInfo
#define	ceRspPhyConnect		ceReqPhyConnect
#define ceRspPhyDisconnect	ceReqPhyDisconnect
#define ceRspPhySetParams	ceReqPhySetParams
#define ceRspPhyGetParams	ceReqPhyGetParams
#define ceRspPhyStatus		ceReqPhyStatus
#define ceRspPhyAcfaStatus	ceReqPhyAcfaStatus
#define ceRspPhyChCallState	ceReqPhyChCallState
#define ceRspPhyChServState	ceReqPhyChServState
#define ceRspPhyRLoopBack	ceReqphyRLoopBack
#define ceReqLnkSetParam	1			/* 2,0,1 */
#define ceReqLnkGetParam	2			/* 2,0,2 */
#define ceReqLnkGetStats	3			/* 2,0,3 */
#define ceReqLnkWrite		1			/* 2,1,1 */
#define ceReqLnkRead		2			/* 2,1,2 */
#define ceReqLnkFlush		3			/* 2,1,3 */
#define ceReqLnkWrBufTrc	4			/* 2,1,4 */
#define ceReqLnkRdBufTrc	5			/* 2,1,5 */
#define ceRspLnkSetParam	ceReqLnkSetParam
#define ceRspLnkGetParam	ceReqLnkGetParam
#define ceRspLnkGetStats	ceReqLnkGetStats
#define ceRspLnkWrite		ceReqLnkWrite
#define ceRspLnkRead		ceReqLnkRead
#define ceRspLnkFlush		ceReqLnkFlush
#define ceRspLnkWrBufTrc	ceReqLnkWrBufTrc
#define ceRspLnkRdBufTrc	ceReqLnkRdBufTrc
#define ceReqCallSetSwitchType	1			/* 3,0,1 */
#define ceReqCallGetSwitchType	2			/* 3,0,2 */
#define ceReqCallSetFrameFormat	3			/* 3,0,3 */
#define ceReqCallGetFrameFormat	4			/* 3,0,4 */
#define ceReqCallSetCallType	5			/* 3,0,5 */
#define ceReqCallGetCallType	6			/* 3,0,6 */
#define ceReqCallSetSPID	7			/* 3,0,7 (!P) */
#define ceReqCallGetSPID	8			/* 3,0,8 (!P) */
#define ceReqCallSetMyNumber	9			/* 3,0,9 (!P) */
#define ceReqCallGetMyNumber	10			/* 3,0,10 (!P) */
#define	ceRspCallSetSwitchType	ceReqCallSetSwitchType
#define ceRspCallGetSwitchType	ceReqCallSetSwitchType
#define ceRspCallSetFrameFormat	ceReqCallSetFrameFormat
#define ceRspCallGetFrameFormat	ceReqCallGetFrameFormat
#define ceRspCallSetCallType	ceReqCallSetCallType
#define ceRspCallGetCallType	ceReqCallGetCallType
#define ceRspCallSetSPID	ceReqCallSetSPID
#define ceRspCallGetSPID	ceReqCallGetSPID
#define ceRspCallSetMyNumber	ceReqCallSetMyNumber
#define ceRspCallGetMyNumber	ceReqCallGetMyNumber
#define ceRspStatAcfaStatus	2
#define ceRspStat
#define ceRspErrError		0			/* 0,0,0 */

/*
 * Call Types
 */
#define CALLTYPE_64K		0
#define CALLTYPE_56K		1
#define CALLTYPE_SPEECH		2
#define CALLTYPE_31KHZ		3

/*
 * Link Level data contains a pointer to and the length of
 * a buffer in shared RAM. Used by LnkRead and LnkWrite message
 * types. Part of RspMsgStruct and ReqMsgStruct.
 */
typedef struct {
	unsigned long buff_offset;
	unsigned short msg_len;
} LLData;


/* 
 * Message payload template for an HWConfig message
 */
typedef struct {
	char st_u_sense;
	char powr_sense;
	char sply_sense;
	unsigned char asic_id;
	long ram_size;
	char serial_no[13];
	char part_no[13];
	char rev_no[2];
} HWConfig_pl;

/*
 * A Message
 */
struct message {
	unsigned char sequence_no;
	unsigned char process_id;
	unsigned char time_stamp;
	unsigned char cmd_sequence_no;	/* Rsp messages only */
	unsigned char reserved1[3];
	unsigned char msg_byte_cnt;
	unsigned char type;
	unsigned char class;
	unsigned char code;
	unsigned char phy_link_no;
	unsigned char rsp_status;	/* Rsp messages only */
	unsigned char reseved2[3];
	union {
		unsigned char byte_array[MSG_DATA_LEN];
		LLData response;
		HWConfig_pl HWCresponse;
	} msg_data;
};

typedef struct message ReqMessage;	/* Request message */
typedef struct message RspMessage;	/* Response message */

/*
 * The first 5010 bytes of shared memory contain the message queues,
 * indexes and other data. This structure is its template
 */
typedef struct {
	volatile ReqMessage req_queue[MAX_MESSAGES];
	volatile RspMessage rsp_queue[MAX_MESSAGES];
	volatile unsigned char req_head;
	volatile unsigned char req_tail;
	volatile unsigned char rsp_head;
	volatile unsigned char rsp_tail;
	volatile unsigned long signature;
	volatile unsigned long trace_enable;
	volatile unsigned char reserved[4];
} DualPortMemory;

#endif