Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
8.8 KiB

  1. /*
  2. ************************************************************************
  3. *
  4. * SETTINGS.h
  5. *
  6. *
  7. * Portions Copyright (C) 1996-1998 National Semiconductor Corp.
  8. * All rights reserved.
  9. * Copyright (C) 1996-1998 Microsoft Corporation. All Rights Reserved.
  10. *
  11. *
  12. *
  13. *************************************************************************
  14. */
  15. #ifndef SETTINGS_H
  16. #define SETTINGS_H
  17. #include "dongle.h"
  18. #if DBG /* { */
  19. /*
  20. * The DBG_ADD_PKT_ID flag causes the miniport to add/delete a packet
  21. * id to each packet. This is only for debugging purposes; it makes
  22. * the miniport INCOMPATIBLE with all others.
  23. */
  24. //#define DBG_ADD_PKT_ID
  25. #ifdef DBG_ADD_PKT_ID
  26. extern BOOLEAN addPktIdOn;
  27. #endif
  28. typedef enum {
  29. DBG_ERR = (1 << 0),
  30. DBG_STAT = (1 << 1),
  31. DBG_MSG = (1 << 2),
  32. DBG_OUT = (1 << 2),
  33. DBG_BUF = (1 << 3),
  34. DBG_PACKET = (1 << 4),
  35. DBG_PKT = (1 << 4),
  36. // Added so we can look at an ndis buffer.
  37. DBG_NDIS_PACKET = (1 << 5),
  38. DBG_DUMPLOG = (1 << 6),
  39. DBG_LOG = (1 << 7),
  40. DBG_ALL = (DBG_ERR|DBG_STAT|DBG_MSG|DBG_BUF|DBG_PACKET),
  41. DBG_SIR_MODE = (1 << 8),
  42. DBG_FIR_MODE = (1 << 9),
  43. DBG_TX = (1 << 10),
  44. DBG_RX = (1 << 11),
  45. DBG_DMA = (1 << 12),
  46. DBG_ISR = (1 << 13),
  47. DBG_TRACE_TX = (1 << 14)
  48. };
  49. // extern ULONG _cdecl DbgPrint(PCHAR Format, ...);
  50. extern UINT dbgOpt;
  51. #define DBG_NDIS_RESULT_STR(_ndisResult) \
  52. ((PUCHAR) ((_ndisResult == NDIS_STATUS_SUCCESS) ? \
  53. "NDIS_STATUS_SUCCESS" : (_ndisResult == NDIS_STATUS_FAILURE) ? \
  54. "NDIS_STATUS_FAILURE" : (_ndisResult == NDIS_STATUS_PENDING) ? \
  55. "NDIS_STATUS_PENDING" : "NDIS_STATUS_???"))
  56. #define DBGPRINT(dbgprint_params_in_parens) \
  57. { \
  58. DbgPrint("NSC: "); \
  59. DbgPrint dbgprint_params_in_parens; \
  60. DbgPrint("\r\n"); \
  61. }
  62. #define DEBUGMSG(flags, dbgprint_params_in_parens) \
  63. if (dbgOpt & (flags)) \
  64. { \
  65. DbgPrint dbgprint_params_in_parens; \
  66. }
  67. #define DEBUGFIR(flags, dbgprint_params_in_parens) \
  68. if (dbgOpt & DBG_FIR_MODE && dbgOpt & (flags)) \
  69. { \
  70. DbgPrint dbgprint_params_in_parens; \
  71. }
  72. #define DBGOUT(dbgprint_params_in_parens) \
  73. if (dbgOpt & DBG_MSG) { \
  74. if ((DebugSpeed > MAX_SIR_SPEED) && \
  75. (dbgOpt & DBG_FIR_MODE)) { \
  76. DBGPRINT(dbgprint_params_in_parens); \
  77. } \
  78. else if (dbgOpt & DBG_SIR_MODE) { \
  79. DBGPRINT(dbgprint_params_in_parens); \
  80. } \
  81. }
  82. #define DBGERR(dbgprint_params_in_parens) \
  83. if (dbgOpt & DBG_ERR) { \
  84. if ((DebugSpeed > MAX_SIR_SPEED) && \
  85. (dbgOpt & DBG_FIR_MODE)) { \
  86. DBGPRINT(dbgprint_params_in_parens); \
  87. } \
  88. else if (dbgOpt & DBG_SIR_MODE) { \
  89. DBGPRINT(dbgprint_params_in_parens); \
  90. } \
  91. }
  92. #define DBGSTAT(dbgprint_params_in_parens) \
  93. if (dbgOpt & DBG_STAT) { \
  94. if ((DebugSpeed > MAX_SIR_SPEED) && \
  95. (dbgOpt & DBG_FIR_MODE)) { \
  96. DBGPRINT(dbgprint_params_in_parens); \
  97. } \
  98. else if (dbgOpt & DBG_SIR_MODE) { \
  99. DBGPRINT(dbgprint_params_in_parens); \
  100. } \
  101. }
  102. #define DBGPKT(dbgprint_params_in_parens) \
  103. if (dbgOpt & DBG_PACKET) { \
  104. if ((DebugSpeed > MAX_SIR_SPEED) && \
  105. (dbgOpt & DBG_FIR_MODE)) { \
  106. DBGPRINT(dbgprint_params_in_parens); \
  107. } \
  108. else if (dbgOpt & DBG_SIR_MODE) { \
  109. DBGPRINT(dbgprint_params_in_parens); \
  110. } \
  111. }
  112. #define DBG_D(i) DbgPrint("IRSIR:"#i"==%d\n", (i))
  113. #define DBG_X(x) DbgPrint("IRSIR:"#x"==0x%0*X\n", sizeof(x)*2, ((ULONG_PTR)(x))&((1<<(sizeof(x)*8))-1) )
  114. #define DBG_UNISTR(s) DbgPrint("IRSIR:"#s"==%wZ\n", (s))
  115. extern VOID DBG_NDIS_Buffer(PNDIS_BUFFER ndisBuf);
  116. #define DBG_NDIS_BUFFER(Ndis_buffer) \
  117. if (dbgOpt & DBG_NDIS_PACKET) { \
  118. if ((DebugSpeed > MAX_SIR_SPEED) && \
  119. (dbgOpt & DBG_FIR_MODE)) { \
  120. DBG_NDIS_Buffer(Ndis_buffer); \
  121. } \
  122. else if (dbgOpt & DBG_SIR_MODE) { \
  123. DBG_NDIS_Buffer(Ndis_buffer); \
  124. } \
  125. }
  126. extern VOID DBG_PrintBuf(PUCHAR bufptr, UINT buflen);
  127. #define DBGPRINTBUF(bufptr, buflen) \
  128. if (dbgOpt & DBG_BUF) { \
  129. if ((DebugSpeed > MAX_SIR_SPEED) && \
  130. (dbgOpt & DBG_FIR_MODE)) { \
  131. DBG_PrintBuf((PUCHAR)(bufptr), (UINT)(buflen)); \
  132. } \
  133. else if (dbgOpt & DBG_SIR_MODE) { \
  134. DBG_PrintBuf((PUCHAR)(bufptr), (UINT)(buflen)); \
  135. } \
  136. }
  137. #else /* } { */
  138. #define DbgBreakPoint()
  139. #define DBGOUT(dbgprint_params_in_parens)
  140. #define DBGERR(dbgprint_params_in_parens)
  141. #define DBGPRINTBUF(bufptr, buflen)
  142. #define DBGSTAT(dbgprint_params_in_parens)
  143. #define DBGPKT(dbgprint_params_in_parens)
  144. #define DBG_NDIS_RESULT_STR(_ndisResult)
  145. #define DEBUGFIR(flags, dbgprint_params_in_parens)
  146. #define DEBUGMSG(flags, dbgprint_params_in_parens)
  147. #define DBG_D(i)
  148. #define DBG_X(x)
  149. #define DBG_UNISTR(s)
  150. #endif /* } #if DBG */
  151. enum baudRates {
  152. /* Slow IR */
  153. BAUDRATE_2400 = 0,
  154. BAUDRATE_9600,
  155. BAUDRATE_19200,
  156. BAUDRATE_38400,
  157. BAUDRATE_57600,
  158. BAUDRATE_115200,
  159. /* Medium IR */
  160. BAUDRATE_576000,
  161. BAUDRATE_1152000,
  162. /* Fast IR */
  163. BAUDRATE_4000000,
  164. NUM_BAUDRATES /* must be last */
  165. };
  166. #define DEFAULT_BAUDRATE BAUDRATE_115200
  167. #define ALL_SLOW_IRDA_SPEEDS ( \
  168. NDIS_IRDA_SPEED_2400 | NDIS_IRDA_SPEED_9600 | \
  169. NDIS_IRDA_SPEED_19200 | NDIS_IRDA_SPEED_38400 | \
  170. NDIS_IRDA_SPEED_57600 | NDIS_IRDA_SPEED_115200)
  171. #define ALL_IRDA_SPEEDS ( \
  172. ALL_SLOW_IRDA_SPEEDS | NDIS_IRDA_SPEED_1152K | NDIS_IRDA_SPEED_4M)
  173. #define MAX_SIR_SPEED 115200
  174. #define MIN_FIR_SPEED 4000000
  175. #define DEFAULT_BOFS_CODE BOFS_48
  176. #define MAX_NUM_EXTRA_BOFS 48
  177. #define DEFAULT_NUM_EXTRA_BOFS MAX_NUM_EXTRA_BOFS
  178. #define DEFAULT_TURNAROUND_usec 1000
  179. typedef struct {
  180. enum baudRates tableIndex;
  181. UINT bitsPerSec;
  182. UINT ndisCode; // bitmask element
  183. } baudRateInfo;
  184. #define DEFAULT_BAUD_RATE 9600
  185. /*
  186. * This is the largest IR packet size (counting _I_ field only,
  187. * and not counting ESC characters) that we handle.
  188. *
  189. */
  190. #define MAX_I_DATA_SIZE 2048
  191. #define MAX_NDIS_DATA_SIZE (IR_ADDR_SIZE+IR_CONTROL_SIZE+MAX_I_DATA_SIZE)
  192. #ifdef DBG_ADD_PKT_ID
  193. #pragma message("WARNING: INCOMPATIBLE DEBUG VERSION")
  194. #define MAX_RCV_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE+2)
  195. #define MAX_DMA_XMIT_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE+2)
  196. #else
  197. #define MAX_RCV_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE)
  198. #define MAX_DMA_XMIT_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE)
  199. #endif
  200. #define MAX_TX_PACKETS 7
  201. #define MAX_RX_PACKETS 7
  202. /*
  203. * We loop an extra time in the receive FSM in order to see EOF after the
  204. * last data byte; so we need some extra space in readBuf in case we then
  205. * get garbage instead.
  206. */
  207. #define RCV_BUFFER_SIZE (MAX_RCV_DATA_SIZE +4+sizeof(LIST_ENTRY))
  208. #define RCV_DMA_SIZE ((MAX_RX_PACKETS+5) * (MAX_RCV_DATA_SIZE + FAST_IR_FCS_SIZE+ 16))
  209. #define RCV_BUF_TO_LIST_ENTRY(b) ((PLIST_ENTRY)((PUCHAR)(b)-sizeof(LIST_ENTRY)))
  210. #define LIST_ENTRY_TO_RCV_BUF(e) ((PVOID)((PUCHAR)(e)+sizeof(LIST_ENTRY)))
  211. #if (RCV_DMA_SIZE > 0x10000)
  212. #error "RCV_DMA_SIZE can't span physical segments"
  213. #endif
  214. /*
  215. * We allocate buffers twice as large as the max rcv size to accomodate ESC
  216. * characters and BOFs, etc. Recall that in the worst possible case, the
  217. * data contains all BOF/EOF/ESC characters, in which case we must expand
  218. * it to twice its original size.
  219. */
  220. #define MAX_POSSIBLE_IR_PACKET_SIZE_FOR_DATA(dataLen) ( \
  221. (dataLen) * 2 + (MAX_NUM_EXTRA_BOFS + 1) * \
  222. SLOW_IR_BOF_SIZE + IR_ADDR_SIZE + IR_CONTROL_SIZE + \
  223. SLOW_IR_FCS_SIZE + SLOW_IR_EOF_SIZE)
  224. #define MAX_IRDA_DATA_SIZE \
  225. MAX_POSSIBLE_IR_PACKET_SIZE_FOR_DATA(MAX_I_DATA_SIZE)
  226. /*
  227. * When FCS is computed on an IR packet with FCS appended, the result
  228. * should be this constant.
  229. */
  230. #define GOOD_FCS ((USHORT) ~0xf0b8)
  231. /*
  232. * Sizes of IrLAP frame fields:
  233. * Beginning Of Frame (BOF)
  234. * End Of Frame (EOF)
  235. * Address
  236. * Control
  237. */
  238. #define IR_ADDR_SIZE 1
  239. #define IR_CONTROL_SIZE 1
  240. #define SLOW_IR_BOF_TYPE UCHAR
  241. #define SLOW_IR_BOF_SIZE sizeof(SLOW_IR_BOF_TYPE)
  242. #define SLOW_IR_EXTRA_BOF_TYPE UCHAR
  243. #define SLOW_IR_EXTRA_BOF_SIZE sizeof(SLOW_IR_EXTRA_BOF_TYPE)
  244. #define SLOW_IR_EOF_TYPE UCHAR
  245. #define SLOW_IR_EOF_SIZE sizeof(SLOW_IR_EOF_TYPE)
  246. #define SLOW_IR_FCS_TYPE USHORT
  247. #define SLOW_IR_FCS_SIZE sizeof(SLOW_IR_FCS_TYPE)
  248. #define SLOW_IR_BOF 0xC0
  249. /* don't use 0xFF, it breaks some HP printers! */
  250. #define SLOW_IR_EXTRA_BOF 0xC0
  251. #define SLOW_IR_EOF 0xC1
  252. #define SLOW_IR_ESC 0x7D
  253. #define SLOW_IR_ESC_COMP 0x20
  254. #define MEDIUM_IR_BOF 0x7E
  255. #define MEDIUM_IR_EOF 0x7E
  256. #define MEDIUM_IR_FCS_SIZE 2
  257. #define FAST_IR_FCS_SIZE 4
  258. #define FAST_IR_EOF_SIZE 1
  259. #define MIN(a,b) (((a) <= (b)) ? (a) : (b))
  260. #define MAX(a,b) (((a) >= (b)) ? (a) : (b))
  261. #endif SETTINGS_H