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