Source code of Windows XP (NT5)
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.

219 lines
5.7 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1996-1999 Microsoft Corporation
  4. *
  5. * @doc
  6. * @module settings.h | IrSIR NDIS Miniport Driver
  7. * @comm
  8. *
  9. *-----------------------------------------------------------------------------
  10. *
  11. * Author: Scott Holden (sholden)
  12. *
  13. * Date: 10/4/1996 (created)
  14. *
  15. * Contents:
  16. *
  17. *****************************************************************************/
  18. #ifndef _SETTINGS_H
  19. #define _SETTINGS_H
  20. #include "dongle.h"
  21. #define IRSIR_MAJOR_VERSION 5
  22. #define IRSIR_MINOR_VERSION 0
  23. enum baudRates {
  24. //
  25. // Slow IR
  26. //
  27. BAUDRATE_2400 = 0,
  28. BAUDRATE_9600,
  29. BAUDRATE_19200,
  30. BAUDRATE_38400,
  31. BAUDRATE_57600,
  32. BAUDRATE_115200,
  33. //
  34. // Medium IR
  35. //
  36. BAUDRATE_576000,
  37. BAUDRATE_1152000,
  38. //
  39. // Fast IR
  40. //
  41. BAUDRATE_4000000,
  42. //
  43. // must be last
  44. //
  45. NUM_BAUDRATES
  46. };
  47. #define DEFAULT_BAUDRATE BAUDRATE_115200
  48. #define ALL_SLOW_IRDA_SPEEDS ( NDIS_IRDA_SPEED_2400 | \
  49. NDIS_IRDA_SPEED_9600 | \
  50. NDIS_IRDA_SPEED_19200 | \
  51. NDIS_IRDA_SPEED_38400 | \
  52. NDIS_IRDA_SPEED_57600 | \
  53. NDIS_IRDA_SPEED_115200 \
  54. )
  55. #define MAX_SPEED_SUPPORTED 115200
  56. #define MAX_TX_PACKETS 7
  57. #define MAX_RX_PACKETS 7
  58. #define DEFAULT_BOFS_CODE BOFS_48
  59. #define MAX_NUM_EXTRA_BOFS 48
  60. #define DEFAULT_NUM_EXTRA_BOFS MAX_NUM_EXTRA_BOFS
  61. #define BITS_PER_CHAR 10
  62. #define usec_PER_SEC 1000000
  63. #define MAX_TURNAROUND_usec 10000
  64. #define MAX_TURNAROUND_BOFS (MAX_SPEED_SUPPORTED/BITS_PER_CHAR*MAX_TURNAROUND_usec/usec_PER_SEC)
  65. #define DEFAULT_TURNAROUND_usec 5000
  66. typedef struct{
  67. enum baudRates tableIndex;
  68. UINT bitsPerSec;
  69. UINT ndisCode; // bitmask element
  70. } baudRateInfo;
  71. #define DEFAULT_BAUD_RATE 9600
  72. //
  73. // Need to make up some default dongle interface functions which
  74. // do nothing, since a dongle may not need any special things
  75. // to operate.
  76. //
  77. NDIS_STATUS __inline StdUart_QueryCaps(
  78. PDONGLE_CAPABILITIES pDongleCaps
  79. )
  80. {
  81. //
  82. // set the default caps
  83. //
  84. pDongleCaps->supportedSpeedsMask = ALL_SLOW_IRDA_SPEEDS;
  85. pDongleCaps->turnAroundTime_usec = 0;
  86. pDongleCaps->extraBOFsRequired = 0;
  87. return NDIS_STATUS_SUCCESS;
  88. }
  89. NDIS_STATUS __inline StdUart_Init(
  90. PDEVICE_OBJECT pSerialDevObj
  91. )
  92. {
  93. return NDIS_STATUS_SUCCESS;
  94. }
  95. void __inline StdUart_Deinit(
  96. PDEVICE_OBJECT pSerialDevObj
  97. )
  98. {
  99. return;
  100. }
  101. NDIS_STATUS __inline StdUart_SetSpeed(
  102. PDEVICE_OBJECT pSerialDevObj,
  103. UINT bitsPerSec,
  104. UINT currentSpeed
  105. )
  106. {
  107. return NDIS_STATUS_SUCCESS;
  108. }
  109. //
  110. // This is the largest IR packet size
  111. // (counting _I_ field only, and not counting ESC characters)
  112. // that we handle.
  113. //
  114. #define MAX_I_DATA_SIZE 2048
  115. #define MAX_NDIS_DATA_SIZE (SLOW_IR_ADDR_SIZE+SLOW_IR_CONTROL_SIZE+MAX_I_DATA_SIZE)
  116. #ifdef DBG_ADD_PKT_ID
  117. #pragma message("WARNING: INCOMPATIBLE DEBUG VERSION")
  118. #define MAX_RCV_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE+sizeof(USHORT))
  119. #else
  120. #define MAX_RCV_DATA_SIZE (MAX_NDIS_DATA_SIZE+SLOW_IR_FCS_SIZE)
  121. #endif
  122. //
  123. // We loop an extra time in the receive state machine in order to
  124. // see EOF after the last data byte; so we need some
  125. // extra space in readBuf in case we then get garbage instead.
  126. //
  127. #define RCV_BUFFER_SIZE (MAX_RCV_DATA_SIZE+4)
  128. //
  129. // We allocate buffers twice as large as the max rcv size to
  130. // accomodate ESC characters and BOFs, etc.
  131. // Recall that in the worst possible case, the data contains
  132. // all BOF/EOF/ESC characters, in which case we must expand it to
  133. // twice its original size.
  134. //
  135. #define MAX_POSSIBLE_IR_PACKET_SIZE_FOR_DATA(dataLen) \
  136. ((dataLen)*2 + \
  137. (MAX_NUM_EXTRA_BOFS+1)*SLOW_IR_BOF_SIZE + \
  138. MAX_TURNAROUND_BOFS + \
  139. SLOW_IR_ADDR_SIZE + \
  140. SLOW_IR_CONTROL_SIZE + \
  141. SLOW_IR_FCS_SIZE + \
  142. SLOW_IR_EOF_SIZE)
  143. #define MAX_IRDA_DATA_SIZE MAX_POSSIBLE_IR_PACKET_SIZE_FOR_DATA(MAX_I_DATA_SIZE)
  144. //
  145. // When FCS is computed on an IR packet with FCS appended,
  146. // the result should be this constant.
  147. //
  148. #define GOOD_FCS ((USHORT)~0xf0b8)
  149. //
  150. // Sizes of IrLAP frame fields:
  151. // Beginning Of Frame (BOF)
  152. // End Of Frame (EOF)
  153. // Address
  154. // Control
  155. //
  156. #define SLOW_IR_BOF_TYPE UCHAR
  157. #define SLOW_IR_BOF_SIZE sizeof(SLOW_IR_BOF_TYPE)
  158. #define SLOW_IR_EXTRA_BOF_TYPE UCHAR
  159. #define SLOW_IR_EXTRA_BOF_SIZE sizeof(SLOW_IR_EXTRA_BOF_TYPE)
  160. #define SLOW_IR_EOF_TYPE UCHAR
  161. #define SLOW_IR_EOF_SIZE sizeof(SLOW_IR_EOF_TYPE)
  162. #define SLOW_IR_FCS_TYPE USHORT
  163. #define SLOW_IR_FCS_SIZE sizeof(SLOW_IR_FCS_TYPE)
  164. #define SLOW_IR_ADDR_SIZE 1
  165. #define SLOW_IR_CONTROL_SIZE 1
  166. #define SLOW_IR_BOF 0xC0
  167. #define SLOW_IR_EXTRA_BOF 0xC0 /* don't use 0xFF, it breaks some HP printers! */
  168. #define SLOW_IR_EOF 0xC1
  169. #define SLOW_IR_ESC 0x7D
  170. #define SLOW_IR_ESC_COMP 0x20
  171. #define MEDIUM_IR_BOF 0x7E
  172. #define MEDIUM_IR_EOF 0x7E
  173. #define MIN(a,b) (((a) <= (b)) ? (a) : (b))
  174. #define MAX(a,b) (((a) >= (b)) ? (a) : (b))
  175. #endif // _SETTINGS_H