message.h 7.1 KB

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