dsp_defs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. *
  3. Copyright (c) Eicon Networks, 2002.
  4. *
  5. This source file is supplied for the use with
  6. Eicon Networks range of DIVA Server Adapters.
  7. *
  8. Eicon File Revision : 2.1
  9. *
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2, or (at your option)
  13. any later version.
  14. *
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
  17. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. See the GNU General Public License for more details.
  19. *
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. *
  24. */
  25. #ifndef DSP_DEFS_H_
  26. #define DSP_DEFS_H_
  27. #include "dspdids.h"
  28. /*---------------------------------------------------------------------------*/
  29. #define dsp_download_reserve_space(fp, length)
  30. /*****************************************************************************/
  31. /*
  32. * OS file access abstraction layer
  33. *
  34. * I/O functions returns -1 on error, 0 on EOF
  35. */
  36. struct _OsFileHandle_;
  37. typedef long (*OsFileIo)(struct _OsFileHandle_ *handle,
  38. void *buffer,
  39. long size);
  40. typedef long (*OsFileSeek)(struct _OsFileHandle_ *handle,
  41. long position,
  42. int mode);
  43. typedef long (*OsCardLoad)(struct _OsFileHandle_ *handle,
  44. long length,
  45. void **addr);
  46. typedef struct _OsFileHandle_
  47. { void *sysFileDesc;
  48. unsigned long sysFileSize;
  49. OsFileIo sysFileRead;
  50. OsFileSeek sysFileSeek;
  51. void *sysLoadDesc;
  52. OsCardLoad sysCardLoad;
  53. } OsFileHandle;
  54. extern OsFileHandle *OsOpenFile(char *path_name);
  55. extern void OsCloseFile(OsFileHandle *fp);
  56. /*****************************************************************************/
  57. #define DSP_TELINDUS_FILE "dspdload.bin"
  58. /* special DSP file for BRI cards for Qsig and CornetN because of missing memory */
  59. #define DSP_QSIG_TELINDUS_FILE "dspdqsig.bin"
  60. #define DSP_MDM_TELINDUS_FILE "dspdvmdm.bin"
  61. #define DSP_FAX_TELINDUS_FILE "dspdvfax.bin"
  62. #define DSP_DIRECTORY_ENTRIES 64
  63. #define DSP_MEMORY_TYPE_EXTERNAL_DM 0
  64. #define DSP_MEMORY_TYPE_EXTERNAL_PM 1
  65. #define DSP_MEMORY_TYPE_INTERNAL_DM 2
  66. #define DSP_MEMORY_TYPE_INTERNAL_PM 3
  67. #define DSP_DOWNLOAD_FLAG_BOOTABLE 0x0001
  68. #define DSP_DOWNLOAD_FLAG_2181 0x0002
  69. #define DSP_DOWNLOAD_FLAG_TIMECRITICAL 0x0004
  70. #define DSP_DOWNLOAD_FLAG_COMPAND 0x0008
  71. #define DSP_MEMORY_BLOCK_COUNT 16
  72. #define DSP_SEGMENT_PM_FLAG 0x0001
  73. #define DSP_SEGMENT_SHARED_FLAG 0x0002
  74. #define DSP_SEGMENT_EXTERNAL_DM DSP_MEMORY_TYPE_EXTERNAL_DM
  75. #define DSP_SEGMENT_EXTERNAL_PM DSP_MEMORY_TYPE_EXTERNAL_PM
  76. #define DSP_SEGMENT_INTERNAL_DM DSP_MEMORY_TYPE_INTERNAL_DM
  77. #define DSP_SEGMENT_INTERNAL_PM DSP_MEMORY_TYPE_INTERNAL_PM
  78. #define DSP_SEGMENT_FIRST_RELOCATABLE 4
  79. #define DSP_DATA_BLOCK_PM_FLAG 0x0001
  80. #define DSP_DATA_BLOCK_DWORD_FLAG 0x0002
  81. #define DSP_DATA_BLOCK_RESOLVE_FLAG 0x0004
  82. #define DSP_RELOC_NONE 0x00
  83. #define DSP_RELOC_SEGMENT_MASK 0x3f
  84. #define DSP_RELOC_TYPE_MASK 0xc0
  85. #define DSP_RELOC_TYPE_0 0x00 /* relocation of address in DM word / high part of PM word */
  86. #define DSP_RELOC_TYPE_1 0x40 /* relocation of address in low part of PM data word */
  87. #define DSP_RELOC_TYPE_2 0x80 /* relocation of address in standard command */
  88. #define DSP_RELOC_TYPE_3 0xc0 /* relocation of address in call/jump on flag in */
  89. #define DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE 48
  90. #define DSP_COMBIFILE_FORMAT_VERSION_BCD 0x0100
  91. #define DSP_FILE_FORMAT_IDENTIFICATION_SIZE 48
  92. #define DSP_FILE_FORMAT_VERSION_BCD 0x0100
  93. typedef struct tag_dsp_combifile_header
  94. {
  95. char format_identification[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE];
  96. word format_version_bcd;
  97. word header_size;
  98. word combifile_description_size;
  99. word directory_entries;
  100. word directory_size;
  101. word download_count;
  102. word usage_mask_size;
  103. } t_dsp_combifile_header;
  104. typedef struct tag_dsp_combifile_directory_entry
  105. {
  106. word card_type_number;
  107. word file_set_number;
  108. } t_dsp_combifile_directory_entry;
  109. typedef struct tag_dsp_file_header
  110. {
  111. char format_identification[DSP_FILE_FORMAT_IDENTIFICATION_SIZE];
  112. word format_version_bcd;
  113. word download_id;
  114. word download_flags;
  115. word required_processing_power;
  116. word interface_channel_count;
  117. word header_size;
  118. word download_description_size;
  119. word memory_block_table_size;
  120. word memory_block_count;
  121. word segment_table_size;
  122. word segment_count;
  123. word symbol_table_size;
  124. word symbol_count;
  125. word total_data_size_dm;
  126. word data_block_count_dm;
  127. word total_data_size_pm;
  128. word data_block_count_pm;
  129. } t_dsp_file_header;
  130. typedef struct tag_dsp_memory_block_desc
  131. {
  132. word alias_memory_block;
  133. word memory_type;
  134. word address;
  135. word size; /* DSP words */
  136. } t_dsp_memory_block_desc;
  137. typedef struct tag_dsp_segment_desc
  138. {
  139. word memory_block;
  140. word attributes;
  141. word base;
  142. word size;
  143. word alignment; /* ==0 -> no other legal start address than base */
  144. } t_dsp_segment_desc;
  145. typedef struct tag_dsp_symbol_desc
  146. {
  147. word symbol_id;
  148. word segment;
  149. word offset;
  150. word size; /* DSP words */
  151. } t_dsp_symbol_desc;
  152. typedef struct tag_dsp_data_block_header
  153. {
  154. word attributes;
  155. word segment;
  156. word offset;
  157. word size; /* DSP words */
  158. } t_dsp_data_block_header;
  159. typedef struct tag_dsp_download_desc
  160. {
  161. word download_id;
  162. word download_flags;
  163. word required_processing_power;
  164. word interface_channel_count;
  165. word excess_header_size;
  166. word memory_block_count;
  167. word segment_count;
  168. word symbol_count;
  169. word data_block_count_dm;
  170. word data_block_count_pm;
  171. byte *p_excess_header_data;
  172. char *p_download_description;
  173. t_dsp_memory_block_desc *p_memory_block_table;
  174. t_dsp_segment_desc *p_segment_table;
  175. t_dsp_symbol_desc *p_symbol_table;
  176. word *p_data_blocks_dm;
  177. word *p_data_blocks_pm;
  178. } t_dsp_desc;
  179. typedef struct tag_dsp_portable_download_desc /* be sure to keep native alignment for MAESTRA's */
  180. {
  181. word download_id;
  182. word download_flags;
  183. word required_processing_power;
  184. word interface_channel_count;
  185. word excess_header_size;
  186. word memory_block_count;
  187. word segment_count;
  188. word symbol_count;
  189. word data_block_count_dm;
  190. word data_block_count_pm;
  191. dword p_excess_header_data;
  192. dword p_download_description;
  193. dword p_memory_block_table;
  194. dword p_segment_table;
  195. dword p_symbol_table;
  196. dword p_data_blocks_dm;
  197. dword p_data_blocks_pm;
  198. } t_dsp_portable_desc;
  199. #define DSP_DOWNLOAD_INDEX_KERNEL 0
  200. #define DSP30TX_DOWNLOAD_INDEX_KERNEL 1
  201. #define DSP30RX_DOWNLOAD_INDEX_KERNEL 2
  202. #define DSP_MAX_DOWNLOAD_COUNT 64
  203. #define DSP_DOWNLOAD_MAX_SEGMENTS 16
  204. #define DSP_UDATA_REQUEST_RECONFIGURE 0
  205. /*
  206. parameters:
  207. <word> reconfigure delay (in 8kHz samples)
  208. <word> reconfigure code
  209. <byte> reconfigure hdlc preamble flags
  210. */
  211. #define DSP_RECONFIGURE_TX_FLAG 0x8000
  212. #define DSP_RECONFIGURE_SHORT_TRAIN_FLAG 0x4000
  213. #define DSP_RECONFIGURE_ECHO_PROTECT_FLAG 0x2000
  214. #define DSP_RECONFIGURE_HDLC_FLAG 0x1000
  215. #define DSP_RECONFIGURE_SYNC_FLAG 0x0800
  216. #define DSP_RECONFIGURE_PROTOCOL_MASK 0x00ff
  217. #define DSP_RECONFIGURE_IDLE 0
  218. #define DSP_RECONFIGURE_V25 1
  219. #define DSP_RECONFIGURE_V21_CH2 2
  220. #define DSP_RECONFIGURE_V27_2400 3
  221. #define DSP_RECONFIGURE_V27_4800 4
  222. #define DSP_RECONFIGURE_V29_7200 5
  223. #define DSP_RECONFIGURE_V29_9600 6
  224. #define DSP_RECONFIGURE_V33_12000 7
  225. #define DSP_RECONFIGURE_V33_14400 8
  226. #define DSP_RECONFIGURE_V17_7200 9
  227. #define DSP_RECONFIGURE_V17_9600 10
  228. #define DSP_RECONFIGURE_V17_12000 11
  229. #define DSP_RECONFIGURE_V17_14400 12
  230. /*
  231. data indications if transparent framer
  232. <byte> data 0
  233. <byte> data 1
  234. ...
  235. data indications if HDLC framer
  236. <byte> data 0
  237. <byte> data 1
  238. ...
  239. <byte> CRC 0
  240. <byte> CRC 1
  241. <byte> preamble flags
  242. */
  243. #define DSP_UDATA_INDICATION_SYNC 0
  244. /*
  245. returns:
  246. <word> time of sync (sampled from counter at 8kHz)
  247. */
  248. #define DSP_UDATA_INDICATION_DCD_OFF 1
  249. /*
  250. returns:
  251. <word> time of DCD off (sampled from counter at 8kHz)
  252. */
  253. #define DSP_UDATA_INDICATION_DCD_ON 2
  254. /*
  255. returns:
  256. <word> time of DCD on (sampled from counter at 8kHz)
  257. <byte> connected norm
  258. <word> connected options
  259. <dword> connected speed (bit/s)
  260. */
  261. #define DSP_UDATA_INDICATION_CTS_OFF 3
  262. /*
  263. returns:
  264. <word> time of CTS off (sampled from counter at 8kHz)
  265. */
  266. #define DSP_UDATA_INDICATION_CTS_ON 4
  267. /*
  268. returns:
  269. <word> time of CTS on (sampled from counter at 8kHz)
  270. <byte> connected norm
  271. <word> connected options
  272. <dword> connected speed (bit/s)
  273. */
  274. #define DSP_CONNECTED_NORM_UNSPECIFIED 0
  275. #define DSP_CONNECTED_NORM_V21 1
  276. #define DSP_CONNECTED_NORM_V23 2
  277. #define DSP_CONNECTED_NORM_V22 3
  278. #define DSP_CONNECTED_NORM_V22_BIS 4
  279. #define DSP_CONNECTED_NORM_V32_BIS 5
  280. #define DSP_CONNECTED_NORM_V34 6
  281. #define DSP_CONNECTED_NORM_V8 7
  282. #define DSP_CONNECTED_NORM_BELL_212A 8
  283. #define DSP_CONNECTED_NORM_BELL_103 9
  284. #define DSP_CONNECTED_NORM_V29_LEASED_LINE 10
  285. #define DSP_CONNECTED_NORM_V33_LEASED_LINE 11
  286. #define DSP_CONNECTED_NORM_TFAST 12
  287. #define DSP_CONNECTED_NORM_V21_CH2 13
  288. #define DSP_CONNECTED_NORM_V27_TER 14
  289. #define DSP_CONNECTED_NORM_V29 15
  290. #define DSP_CONNECTED_NORM_V33 16
  291. #define DSP_CONNECTED_NORM_V17 17
  292. #define DSP_CONNECTED_OPTION_TRELLIS 0x0001
  293. /*---------------------------------------------------------------------------*/
  294. extern char *dsp_read_file(OsFileHandle *fp,
  295. word card_type_number,
  296. word *p_dsp_download_count,
  297. t_dsp_desc *p_dsp_download_table,
  298. t_dsp_portable_desc *p_dsp_portable_download_table);
  299. /*---------------------------------------------------------------------------*/
  300. #endif /* DSP_DEFS_H_ */