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.

1181 lines
42 KiB

  1. //--- init.h(common for vs and rk)
  2. // use 2.04.03 format 3 part optional for non-released versions)
  3. // use 2.05 format 2 part for released changes
  4. #ifdef S_RK
  5. #ifdef NT50
  6. #define VER_PRODUCTVERSION_STR "4.50"
  7. #define VER_PRODUCTVERSION 4,50
  8. #else
  9. #define VER_PRODUCTVERSION_STR "4.50"
  10. #define VER_PRODUCTVERSION 4,50
  11. #endif
  12. #else
  13. #ifdef NT50
  14. #define VER_PRODUCTVERSION_STR "2.50"
  15. #define VER_PRODUCTVERSION 2,50
  16. #else
  17. #define VER_PRODUCTVERSION_STR "2.50"
  18. #define VER_PRODUCTVERSION 2,50
  19. #endif
  20. #endif
  21. // these are now turned on or off in the sources file in rk or vs dir
  22. //#define ROCKET
  23. //#define VS1000
  24. //#define NT50
  25. // make the ExAllocatePool call "WDM-compatible" - use pool tags version
  26. // with our tag "Rckt" (little endian format)
  27. #ifdef NT50
  28. #ifdef POOL_TAGGING
  29. #ifdef ExAllocatePool
  30. #undef ExAllocatePool
  31. #endif
  32. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'tkcR')
  33. #endif
  34. #endif
  35. //
  36. // define paths to Rockwell modem firmware...
  37. //
  38. #define MODEM_CSREC_PATH "\\SystemRoot\\system32\\ROCKET\\ctmmdmfw.rm"
  39. #define MODEM_CSM_SREC_PATH "\\SystemRoot\\system32\\ROCKET\\ctmmdmld.rm"
  40. //#define TRY_DYNAMIC_BINDING
  41. // define to allow modem download for new pci rocketmodem 56k product(no flash)
  42. #define MDM_DOWNLOAD
  43. // these should be on, they are left in just in case(will strip out in future)
  44. #define RING_FAKE
  45. #define USE_SYNC_LOCKS
  46. #define NEW_WAIT
  47. #define NEW_WRITE_SYNC_LOCK
  48. #define NEW_WAIT_SYNC_LOCK
  49. #ifdef S_RK
  50. // we can only use this on rocketport
  51. #define NEW_FAST_TX
  52. #endif
  53. #define TRACE_PORT
  54. #define USE_HAL_ASSIGNSLOT
  55. // pnp bus-driver stuff
  56. #define DO_BUS_EXTENDER
  57. // attempted io-aliasing solution for nt5.0 to properly get resources
  58. // for isa-bus cards using alias io space
  59. #define DO_ISA_BUS_ALIAS_IO
  60. #define GLOBAL_ASSERT
  61. #define GLOBAL_TRACE
  62. #define TRACE_PORT
  63. #ifdef S_VS
  64. #define MAX_NUM_BOXES 64
  65. #else
  66. #define MAX_NUM_BOXES 8
  67. #endif
  68. #define MAX_PORTS_PER_DEVICE 64
  69. //---- following used to trace driver activity
  70. //#define D_L0 0x00001L
  71. //#define D_L2 0x00004L
  72. //#define D_L4 0x00010L
  73. //#define D_L6 0x00040L
  74. //#define D_L7 0x00080L
  75. //#define D_L8 0x00100L
  76. //#define D_L9 0x00200L
  77. //#define D_L10 0x00400L
  78. //#define D_L11 0x00800L
  79. #define D_Error 0x08000L
  80. #define D_All 0xffffffffL
  81. #define D_Nic 0x00002L
  82. #define D_Hdlc 0x00008L
  83. #define D_Port 0x00020L
  84. #define D_Options 0x01000L
  85. //---- following used to trace driver activity
  86. #define D_Init 0x00010000L
  87. #define D_Pnp 0x00020000L
  88. #define D_Ioctl 0x00040000L
  89. #define D_Write 0x00080000L
  90. #define D_Read 0x00100000L
  91. #define D_Ssci 0x00200000L
  92. #define D_Thread 0x00400000L
  93. #define D_Test 0x00800000L
  94. #define D_PnpAdd 0x01000000L
  95. #define D_PnpPower 0x02000000L
  96. //Constant definitions for the I/O error code log values.
  97. // Values are 32 bit values layed out as follows:
  98. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  99. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  100. // +---+-+-+-----------------------+-------------------------------+
  101. // |Sev|C|R| Facility | Code |
  102. // +---+-+-+-----------------------+-------------------------------+
  103. // where
  104. // Sev - is the severity code
  105. // 00 - Success
  106. // 01 - Informational
  107. // 10 - Warning
  108. // 11 - Error
  109. // C - is the Customer code flag
  110. // R - is a reserved bit
  111. // Facility - is the facility code
  112. // Code - is the facility's status code
  113. // Define the facility codes
  114. #define FACILITY_SERIAL_ERROR_CODE 0x6
  115. #define FACILITY_RPC_STUBS 0x3
  116. #define FACILITY_RPC_RUNTIME 0x2
  117. #define FACILITY_IO_ERROR_CODE 0x4
  118. // Define the severity codes
  119. #define STATUS_SEVERITY_WARNING 0x2
  120. #define STATUS_SEVERITY_SUCCESS 0x0
  121. #define STATUS_SEVERITY_INFORMATIONAL 0x1
  122. #define STATUS_SEVERITY_ERROR 0x3
  123. #ifdef S_RK
  124. #define SERIAL_RP_INIT_FAIL ((NTSTATUS)0x80060001L)
  125. #else
  126. #define SERIAL_RP_INIT_FAIL ((NTSTATUS)0xC0060001L)
  127. #endif
  128. #define SERIAL_RP_INIT_PASS ((NTSTATUS)0x40060002L)
  129. #define SERIAL_NO_SYMLINK_CREATED ((NTSTATUS)0x80060003L)
  130. #define SERIAL_NO_DEVICE_MAP_CREATED ((NTSTATUS)0x80060004L)
  131. #define SERIAL_NO_DEVICE_MAP_DELETED ((NTSTATUS)0x80060005L)
  132. #define SERIAL_UNREPORTED_IRQL_CONFLICT ((NTSTATUS)0xC0060006L)
  133. #define SERIAL_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC0060007L)
  134. #define SERIAL_NO_PARAMETERS_INFO ((NTSTATUS)0xC0060008L)
  135. #define SERIAL_UNABLE_TO_ACCESS_CONFIG ((NTSTATUS)0xC0060009L)
  136. #define SERIAL_UNKNOWN_BUS ((NTSTATUS)0xC006000AL)
  137. #define SERIAL_BUS_NOT_PRESENT ((NTSTATUS)0xC006000BL)
  138. #define SERIAL_INVALID_USER_CONFIG ((NTSTATUS)0xC006000CL)
  139. #define SERIAL_RP_RESOURCE_CONFLICT ((NTSTATUS)0xC006000DL)
  140. #define SERIAL_RP_HARDWARE_FAIL ((NTSTATUS)0xC006000EL)
  141. #define SERIAL_DEVICEOBJECT_FAILED ((NTSTATUS)0xC006000FL)
  142. #define SERIAL_CUSTOM_ERROR_MESSAGE ((NTSTATUS)0xC0060010L)
  143. #define SERIAL_CUSTOM_INFO_MESSAGE ((NTSTATUS)0x40060011L)
  144. #define SERIAL_NT50_INIT_PASS ((NTSTATUS)0x40060012L)
  145. // max number of nic cards we will allow
  146. #define VS1000_MAX_NICS 6
  147. #ifdef GLOBAL_ASSERT
  148. #define GAssert(id, exp ) { if (!(exp)) our_assert(id, __LINE__); }
  149. #else
  150. #define GAssert(id, exp )
  151. #endif
  152. #ifdef GLOBAL_TRACE
  153. #define GTrace3(_Mask,_LeadStr, _Msg,_P1,_P2, _P3) \
  154. { if (Driver.GTraceFlags & _Mask) TTprintf(_LeadStr, _Msg, _P1, _P2, _P3); }
  155. #define GTrace2(_Mask,_LeadStr, _Msg,_P1,_P2) \
  156. { if (Driver.GTraceFlags & _Mask) TTprintf(_LeadStr, _Msg, _P1, _P2); }
  157. #define GTrace1(_Mask,_LeadStr, _Msg,_P1) \
  158. { if (Driver.GTraceFlags & _Mask) TTprintf(_LeadStr, _Msg, _P1); }
  159. #define GTrace(_Mask_, _LeadStr, _Msg_) \
  160. { if (Driver.GTraceFlags & _Mask_) OurTrace(_LeadStr, _Msg_); }
  161. //#define GMark(c, x)
  162. #else
  163. #define GTrace2(_Mask,_LeadStr, _Msg,_P1, _P2) {}
  164. #define GTrace1(_Mask,_LeadStr, _Msg,_P1) {}
  165. #define GTrace(_Mask_, _LeadStr, _Msg_) {}
  166. //#define GMark(c, x) {}
  167. #endif
  168. // following are for debug, when checked build is made DBG is defined
  169. // and the messages go to our debug queue and the nt debug string output.
  170. #if DBG
  171. #define DTrace3(_Mask_,_LeadStr,_Msg_,_P1_,_P2_,_P3_) \
  172. { if (RocketDebugLevel & _Mask_) TTprintf(_LeadStr,_Msg_,_P1_,_P2_,_P3_); }
  173. #define DTrace2(_Mask_,_LeadStr,_Msg_,_P1_,_P2_) \
  174. { if (RocketDebugLevel & _Mask_) TTprintf(_LeadStr,_Msg_,_P1_,_P2_); }
  175. #define DTrace1(_Mask_,_LeadStr,_Msg_,_P1_) \
  176. { if (RocketDebugLevel & _Mask_) TTprintf(_LeadStr,_Msg_,_P1_); }
  177. #define DTrace(_Mask_,_LeadStr,_Msg_) \
  178. { if (RocketDebugLevel & _Mask_) OurTrace(_LeadStr, _Msg_); }
  179. #define DPrintf(_Mask_,_Msg_) \
  180. { if (RocketDebugLevel & _Mask_) Tprintf _Msg_; }
  181. #else
  182. #define DTrace3(_Mask,_LeadStr, _Msg,_P1, _P2, _P3) {}
  183. #define DTrace2(_Mask,_LeadStr, _Msg,_P1, _P2) {}
  184. #define DTrace1(_Mask,_LeadStr, _Msg,_P1) {}
  185. #define DTrace(_Mask_, _LeadStr, _Msg_) {}
  186. #define DPrintf(_Mask_,_Msg_) {}
  187. #endif
  188. #ifdef TRACE_PORT
  189. #define ExtTrace4(_Ext_,_Mask_,_Msg_,_P1_,_P2_,_P3_, _P4_) \
  190. { if (_Ext_->TraceOptions & 1) Tprintf(_Msg_,_P1_,_P2_,_P3_,_P4_); }
  191. #define ExtTrace3(_Ext_,_Mask_,_Msg_,_P1_,_P2_,_P3_) \
  192. { if (_Ext_->TraceOptions & 1) Tprintf(_Msg_,_P1_,_P2_,_P3_); }
  193. #define ExtTrace2(_Ext_,_Mask_,_Msg_,_P1_,_P2_) \
  194. { if (_Ext_->TraceOptions & 1) Tprintf(_Msg_,_P1_,_P2_); }
  195. #define ExtTrace1(_Ext_,_Mask_,_Msg_,_P1_) \
  196. { if (_Ext_->TraceOptions & 1) Tprintf(_Msg_,_P1_); }
  197. #define ExtTrace(_Ext_,_Mask_,_Msg_) \
  198. { if (_Ext_->TraceOptions & 1) Tprintf(_Msg_); }
  199. #else
  200. #define ExtTrace3(_Mask_,_Msg_,_P1_,_P2_,_P3_) {}
  201. #define ExtTrace2(_Mask_,_Msg_,_P1_,_P2_) {}
  202. #define ExtTrace1(_Mask_,_Msg_,_P1_) {}
  203. #define ExtTrace(_Mask_,_Msg_) {}
  204. #endif
  205. #if DBG
  206. #define MyAssert( exp ) { if (!(exp)) MyAssertMessage(__FILE__, __LINE__); }
  207. # ifdef S_VS
  208. #define MyKdPrint(_Mask_,_Msg_) \
  209. { \
  210. if (_Mask_ & RocketDebugLevel) { \
  211. DbgPrint ("VS:"); \
  212. DbgPrint _Msg_; \
  213. } \
  214. }
  215. # else
  216. #define MyKdPrint(_Mask_,_Msg_) \
  217. { \
  218. if (_Mask_ & RocketDebugLevel) { \
  219. DbgPrint ("RK:"); \
  220. DbgPrint _Msg_; \
  221. } \
  222. }
  223. # endif
  224. #define MyKdPrintUnicode(_Mask_,_PUnicode_)\
  225. if(_Mask_ & RocketDebugLevel) \
  226. { \
  227. ANSI_STRING tempstr; \
  228. RtlUnicodeStringToAnsiString(&tempstr,_PUnicode_,TRUE); \
  229. DbgPrint("%s",tempstr.Buffer);\
  230. RtlFreeAnsiString(&tempstr); \
  231. }
  232. #else
  233. #define MyAssert( exp ) {}
  234. #define MyKdPrint(_Mask_,_Msg_) {}
  235. #define MyKdPrintUnicode(_Mask_,_PUnicode_) {}
  236. #endif //DBG
  237. #define SERIAL_NONE_PARITY ((UCHAR)0x00)
  238. #define SERIAL_ODD_PARITY ((UCHAR)0x08)
  239. #define SERIAL_EVEN_PARITY ((UCHAR)0x18)
  240. #define SERIAL_MARK_PARITY ((UCHAR)0x28)
  241. #define SERIAL_SPACE_PARITY ((UCHAR)0x38)
  242. #define SERIAL_PARITY_MASK ((UCHAR)0x38)
  243. // This should be enough space to hold the numeric suffix of the device name.
  244. // #define DEVICE_NAME_DELTA 20
  245. // Default xon/xoff characters.
  246. #define SERIAL_DEF_XON 0x11
  247. #define SERIAL_DEF_XOFF 0x13
  248. // Reasons that reception may be held up.
  249. #define SERIAL_RX_DTR ((ULONG)0x01)
  250. #define SERIAL_RX_XOFF ((ULONG)0x02)
  251. #define SERIAL_RX_RTS ((ULONG)0x04)
  252. #define SERIAL_RX_DSR ((ULONG)0x08)
  253. // Reasons that transmission may be held up.
  254. #define SERIAL_TX_CTS ((ULONG)0x01)
  255. #define SERIAL_TX_DSR ((ULONG)0x02)
  256. #define SERIAL_TX_DCD ((ULONG)0x04)
  257. #define SERIAL_TX_XOFF ((ULONG)0x08)
  258. #define SERIAL_TX_BREAK ((ULONG)0x10)
  259. #define ST_XOFF_FAKE ((ULONG)0x20) // added for SETXOFF(kpb)
  260. // These values are used by the routines that can be used
  261. // to complete a read (other than interval timeout) to indicate
  262. // to the interval timeout that it should complete.
  263. #define SERIAL_COMPLETE_READ_CANCEL ((LONG)-1)
  264. #define SERIAL_COMPLETE_READ_TOTAL ((LONG)-2)
  265. #define SERIAL_COMPLETE_READ_COMPLETE ((LONG)-3)
  266. //--- flags for MdmCountry (ROW country code)
  267. #define ROW_NOT_USED 0
  268. #define ROW_AUSTRIA 1
  269. #define ROW_BELGIUM 2
  270. #define ROW_DENMARK 3
  271. #define ROW_FINLAND 4
  272. #define ROW_FRANCE 5
  273. #define ROW_GERMANY 6
  274. #define ROW_IRELAND 7
  275. #define ROW_ITALY 8
  276. #define ROW_LUXEMBOURG 9
  277. #define ROW_NETHERLANDS 10
  278. #define ROW_NORWAY 11
  279. #define ROW_PORTUGAL 12
  280. #define ROW_SPAIN 13
  281. #define ROW_SWEDEN 14
  282. #define ROW_SWITZERLAND 15
  283. #define ROW_UK 16
  284. #define ROW_GREECE 17
  285. #define ROW_ISRAEL 18
  286. #define ROW_CZECH_REP 19
  287. #define ROW_CANADA 20
  288. #define ROW_MEXICO 21
  289. #define ROW_USA 22
  290. #define ROW_NA ROW_USA
  291. #define ROW_HUNGARY 23
  292. #define ROW_POLAND 24
  293. #define ROW_RUSSIA 25
  294. #define ROW_SLOVAC_REP 26
  295. #define ROW_BULGARIA 27
  296. // 28
  297. // 29
  298. #define ROW_INDIA 30
  299. // 31
  300. // 32
  301. // 33
  302. // 34
  303. // 35
  304. // 36
  305. // 37
  306. // 38
  307. // 39
  308. #define ROW_AUSTRALIA 40
  309. #define ROW_CHINA 41
  310. #define ROW_HONG_KONG 42
  311. #define ROW_JAPAN 43
  312. #define ROW_PHILIPPINES ROW_JAPAN
  313. #define ROW_KOREA 44
  314. // 45
  315. #define ROW_TAIWAN 46
  316. #define ROW_SINGAPORE 47
  317. #define ROW_NEW_ZEALAND 48
  318. #define ROW_DEFAULT ROW_USA
  319. // Ext->DeviceType: // DEV_PORT, DEV_DRIVER, DEV_BOARD
  320. #define DEV_PORT 0
  321. #define DEV_BOARD 1
  322. /* Configuration information structure for one port */
  323. typedef struct {
  324. char Name[12];
  325. ULONG LockBaud;
  326. ULONG TxCloseTime;
  327. int WaitOnTx : 1;
  328. int RS485Override : 1;
  329. int RS485Low : 1;
  330. int Map2StopsTo1 : 1;
  331. int MapCdToDsr : 1;
  332. int RingEmulate : 1;
  333. } PORT_CONFIG;
  334. /* Configuration information structure for one board or vs1000("device") */
  335. typedef struct
  336. {
  337. #ifdef S_RK
  338. unsigned int MudbacIO; /* I/O address of MUDBAC */
  339. PUCHAR pMudbacIO; /* NT ptrs to I/O address of MUDBAC */
  340. unsigned int BaseIoAddr; // normal io-address
  341. unsigned int TrBaseIoAddr; // translated io-address
  342. PUCHAR pBaseIoAddr; // final indirect mapped handle for io-address
  343. unsigned int BaseIoSize; /* 44H for 1st isa, 40 for isa addition, etc */
  344. unsigned int ISABrdIndex; /* 0 for first, 1 for second, etc(isa only) */
  345. unsigned int AiopIO[AIOP_CTL_SIZE]; /* I/O addresses of AIOPs */
  346. PUCHAR pAiopIO[AIOP_CTL_SIZE]; /* NT ptrs to I/O address of AIOPs */
  347. //int NumChan; /* number of channels on this controller */
  348. // use NumPorts instead
  349. int NumAiop; /* number of Aiops on board */
  350. unsigned int RocketPortFound; /* indicates ctl was found and init'd */
  351. INTERFACE_TYPE BusType; /* PCIBus or Isa */
  352. int PCI_DevID;
  353. int PCI_RevID;
  354. int PCI_SVID;
  355. int PCI_SID;
  356. int Irq;
  357. int InterruptMode;
  358. int IrqLevel;
  359. int IrqVector;
  360. int Affinity;
  361. int TrInterruptMode;
  362. int TrIrqLevel;
  363. int TrIrqVector;
  364. int TrAffinity;
  365. int PCI_Slot;
  366. int BusNumber;
  367. int IsRocketPortPlus; // true if rocketport plus hardware
  368. #else
  369. int IsHubDevice; // true if device(RHub) uses slower baud clock
  370. #endif
  371. BOOLEAN HardwareStarted;
  372. BYTE MacAddr[6]; // vs1000
  373. int BackupServer; // vs1000
  374. int BackupTimer; // vs1000
  375. //int StartComIndex; // starting com-port index
  376. ULONG Hardware_ID; // software derived hardware id(used for nt50 now)
  377. ULONG IoAddress; // user interface io-address selection
  378. int ModemDevice; // true for RocketModems & Vs2000
  379. int NumPorts; // configured number of ports on this device
  380. ULONG ClkRate; // def:36864000=rcktport, 44236800=rplus, 18432000=rhub
  381. ULONG ClkPrescaler; // def:14H=rcktport, 12H=rplus, 14H=rhub
  382. #ifdef NT50
  383. // this holds the pnp-name we use as a registry key to hold
  384. // our device parameters in the registry for RocketPort & NT50
  385. char szNt50DevObjName[50]; // typical: "Device_002456
  386. #else
  387. int DevIndex; // nt40 keeps simple linear list of devices 0,1,2...
  388. #endif
  389. PORT_CONFIG port[MAX_PORTS_PER_DEVICE]; // our read in port configuration
  390. } DEVICE_CONFIG;
  391. #define TYPE_RM_VS2000 1
  392. #define TYPE_RMII 2
  393. #define TYPE_RM_i 3
  394. // forward declaration
  395. typedef struct _SERIAL_DEVICE_EXTENSION *PSERIAL_DEVICE_EXTENSION;
  396. typedef struct _SERIAL_DEVICE_EXTENSION {
  397. USHORT DeviceType; // DEV_PORT, DEV_BOARD
  398. USHORT BoardNum; // 0,1,2,3 for DEV_BOARD type
  399. BOOLEAN IsPDO; // a nt50 pnp thing, tells if we are a pdo or fdo
  400. char NtNameForPort[32]; // like "RocketPort0"
  401. char SymbolicLinkName[16]; // like "COM5"
  402. #ifdef S_VS
  403. //int box_num; // index into box & hdlc array
  404. SerPort *Port; // if a DEV_PORT type extension
  405. PortMan *pm; // if a DEV_BOARD type extension
  406. Hdlc *hd; // if a DEV_BOARD type extension
  407. //int DeviceNum; // index into total port array
  408. #else
  409. CHANPTR_T ChP; // ptr to channel structure
  410. CHANNEL_T ch; // our board channel structure
  411. #endif
  412. unsigned int UniqueId; // 0,1,2,3... CreateBoardDevice() bumps...
  413. // if we are DEV_BOARD, the this points to next board extension
  414. // if we are DEV_PORT, then it points to our parent board
  415. PSERIAL_DEVICE_EXTENSION board_ext;
  416. // if we are DEV_BOARD, the this points to start of port extensions
  417. // if we are DEV_PORT, then it points to next port extension
  418. PSERIAL_DEVICE_EXTENSION port_ext; // next port extension
  419. // if we are DEV_BOARD, the this points to start of pdo port extensions
  420. PSERIAL_DEVICE_EXTENSION port_pdo_ext; // next pdo port extension
  421. ULONG BaudRate; // NT defined baud rate
  422. SERIAL_LINE_CONTROL LineCtl; // NT defined line control
  423. ULONG ModemStatus; // NT defined modem status
  424. ULONG DTRRTSStatus; // NT defined modem status
  425. USHORT DevStatus; // device status
  426. //unsigned int FlowControl;
  427. //unsigned int DetectEn;
  428. #ifdef S_RK
  429. USHORT io_reported; // flag to tell if we have io,irq to unreport.
  430. ULONG EventModemStatus; // used to detect change for events
  431. unsigned int ModemCtl;
  432. unsigned int IntEnables; // RP specific ints to enable
  433. #endif
  434. int PortIndex; // if port: index into ports on board(0,1,2..)
  435. #ifdef TXBUFFER
  436. //PUCHAR TxBuf;
  437. //LONG TxIn;
  438. //LONG TxOut;
  439. //LONG TxBufSize;
  440. #endif
  441. Queue RxQ;
  442. // Used to keep ISR from completing a read while it is being started.
  443. BOOLEAN ReadPending;
  444. // This value is set by the read code to hold the time value
  445. // used for read interval timing. We keep it in the extension
  446. // so that the interval timer dpc routine determine if the
  447. // interval time has passed for the IO.
  448. LARGE_INTEGER IntervalTime;
  449. // These two values hold the "constant" time that we should use
  450. // to delay for the read interval time.
  451. LARGE_INTEGER ShortIntervalAmount;
  452. LARGE_INTEGER LongIntervalAmount;
  453. // This holds the value that we use to determine if we should use
  454. // the long interval delay or the short interval delay.
  455. LARGE_INTEGER CutOverAmount;
  456. // This holds the system time when we last time we had
  457. // checked that we had actually read characters. Used
  458. // for interval timing.
  459. LARGE_INTEGER LastReadTime;
  460. // This points the the delta time that we should use to
  461. // delay for interval timing.
  462. PLARGE_INTEGER IntervalTimeToUse;
  463. // Points to the device object that contains
  464. // this device extension.
  465. PDEVICE_OBJECT DeviceObject;
  466. // This list head is used to contain the time ordered list
  467. // of read requests. Access to this list is protected by
  468. // the global cancel spinlock.
  469. LIST_ENTRY ReadQueue;
  470. // This list head is used to contain the time ordered list
  471. // of write requests. Access to this list is protected by
  472. // the global cancel spinlock.
  473. LIST_ENTRY WriteQueue;
  474. // Holds the serialized list of purge requests.
  475. LIST_ENTRY PurgeQueue;
  476. // This points to the irp that is currently being processed
  477. // for the read queue. This field is initialized by the open to
  478. // NULL.
  479. // This value is only set at dispatch level. It may be
  480. // read at interrupt level.
  481. PIRP CurrentReadIrp;
  482. // This points to the irp that is currently being processed
  483. // for the write queue.
  484. // This value is only set at dispatch level. It may be
  485. // read at interrupt level.
  486. PIRP CurrentWriteIrp;
  487. // Points to the irp that is currently being processed to
  488. // purge the read/write queues and buffers.
  489. PIRP CurrentPurgeIrp;
  490. // Points to the current irp that is waiting on a comm event.
  491. PIRP CurrentWaitIrp;
  492. // Points to the irp that is being used to count the number
  493. // of characters received after an xoff (as currently defined
  494. // by the IOCTL_SERIAL_XOFF_COUNTER ioctl) is sent.
  495. PIRP CurrentXoffIrp;
  496. // Holds the number of bytes remaining in the current write irp.
  497. // This location is only accessed while at interrupt level.
  498. ULONG WriteLength;
  499. // The syncronization between the various threads in this
  500. // driver is hosed up in places, besides being really confusing.
  501. // This is an attempt to have a protected flag which is set
  502. // to 1 if the ISR owns the currentwriteirp, 2 if the ISR
  503. // is in the progress of ending the IRP(going to serialcompletewrite),
  504. // and 0 when it is complete. The starter routine sets it
  505. // from 0 to 1 to give a new irp to the isr/timer routine for
  506. // processing. The ISR sets it from 1 to 2 when it queues
  507. // the DPC to finalize the irp. The DPC sets it from 2 to
  508. // 0 when it completes the irp. The cancel or timer routines
  509. // must run a synchronized routine which guarentees sole access
  510. // to this flag. Looks if it is 1, if it is 1 then it takes
  511. // by setting it to zero, and returning a flag to indicate to
  512. // the caller to finalize the irp. If it is a 2, it assumes
  513. // the isr has arranged to finalize the irp. Geez-O-Pete
  514. // what a lot of silly gears!
  515. ULONG WriteBelongsToIsr;
  516. // Holds a pointer to the current character to be sent in
  517. // the current write.
  518. // This location is only accessed while at interrupt level.
  519. PUCHAR WriteCurrentChar;
  520. // This variable holds the size of whatever buffer we are currently
  521. // using.
  522. ULONG BufferSize;
  523. // This variable holds .8 of BufferSize. We don't want to recalculate
  524. // this real often - It's needed when so that an application can be
  525. // "notified" that the buffer is getting full.
  526. ULONG BufferSizePt8;
  527. // This value holds the number of characters desired for a
  528. // particular read. It is initially set by read length in the
  529. // IRP. It is decremented each time more characters are placed
  530. // into the "users" buffer buy the code that reads characters
  531. // out of the typeahead buffer into the users buffer. If the
  532. // typeahead buffer is exhausted by the read, and the reads buffer
  533. // is given to the isr to fill, this value is becomes meaningless.
  534. ULONG NumberNeededForRead;
  535. // This mask will hold the bitmask sent down via the set mask
  536. // ioctl. It is used by the interrupt service routine to determine
  537. // if the occurence of "events" (in the serial drivers understanding
  538. // of the concept of an event) should be noted.
  539. ULONG IsrWaitMask;
  540. // This mask will always be a subset of the IsrWaitMask. While
  541. // at device level, if an event occurs that is "marked" as interesting
  542. // in the IsrWaitMask, the driver will turn on that bit in this
  543. // history mask. The driver will then look to see if there is a
  544. // request waiting for an event to occur. If there is one, it
  545. // will copy the value of the history mask into the wait irp, zero
  546. // the history mask, and complete the wait irp. If there is no
  547. // waiting request, the driver will be satisfied with just recording
  548. // that the event occured. If a wait request should be queued,
  549. // the driver will look to see if the history mask is non-zero. If
  550. // it is non-zero, the driver will copy the history mask into the
  551. // irp, zero the history mask, and then complete the irp.
  552. ULONG HistoryMask;
  553. // This is a pointer to the where the history mask should be
  554. // placed when completing a wait. It is only accessed at
  555. // device level.
  556. // We have a pointer here to assist us to synchronize completing a wait.
  557. // If this is non-zero, then we have wait outstanding, and the isr still
  558. // knows about it. We make this pointer null so that the isr won't
  559. // attempt to complete the wait.
  560. // We still keep a pointer around to the wait irp, since the actual
  561. // pointer to the wait irp will be used for the "common" irp completion
  562. // path.
  563. ULONG *IrpMaskLocation;
  564. ULONG WaitIsISRs; // 1=owned by isr.c(expicit help)
  565. ULONG DummyIrpMaskLoc; // Point the IrpMaskLocation here when not in use
  566. // This mask holds all of the reason that transmission
  567. // is not proceeding. Normal transmission can not occur
  568. // if this is non-zero.
  569. // This is only written from interrupt level.
  570. // This could be (but is not) read at any level.
  571. ULONG TXHolding;
  572. // This mask holds all of the reason that reception
  573. // is not proceeding. Normal reception can not occur
  574. // if this is non-zero.
  575. // This is only written from interrupt level.
  576. // This could be (but is not) read at any level.
  577. ULONG RXHolding;
  578. // This holds the reasons that the driver thinks it is in
  579. // an error state.
  580. // This is only written from interrupt level.
  581. // This could be (but is not) read at any level.
  582. ULONG ErrorWord;
  583. // This keeps a total of the number of characters that
  584. // are in all of the "write" irps that the driver knows
  585. // about. It is only accessed with the cancel spinlock
  586. // held.
  587. ULONG TotalCharsQueued;
  588. // This holds a count of the number of characters read
  589. // the last time the interval timer dpc fired. It
  590. // is a long (rather than a ulong) since the other read
  591. // completion routines use negative values to indicate
  592. // to the interval timer that it should complete the read
  593. // if the interval timer DPC was lurking in some DPC queue when
  594. // some other way to complete occurs.
  595. LONG CountOnLastRead;
  596. // This is a count of the number of characters read by the
  597. // isr routine. It is *ONLY* written at isr level. We can
  598. // read it at dispatch level.
  599. ULONG ReadByIsr;
  600. // This is the number of characters read since the XoffCounter
  601. // was started. This variable is only accessed at device level.
  602. // If it is greater than zero, it implies that there is an
  603. // XoffCounter ioctl in the queue.
  604. LONG CountSinceXoff;
  605. // Holds the timeout controls for the device. This value
  606. // is set by the Ioctl processing.
  607. // It should only be accessed under protection of the control
  608. // lock since more than one request can be in the control dispatch
  609. // routine at one time.
  610. SERIAL_TIMEOUTS Timeouts;
  611. // This holds the various characters that are used
  612. // for replacement on errors and also for flow control.
  613. // They are only set at interrupt level.
  614. SERIAL_CHARS SpecialChars;
  615. // This structure holds the handshake and control flow
  616. // settings for the serial driver.
  617. // It is only set at interrupt level. It can be
  618. // be read at any level with the control lock held.
  619. SERIAL_HANDFLOW HandFlow;
  620. // We keep track of whether the somebody has the device currently
  621. // opened with a simple boolean. We need to know this so that
  622. // spurious interrupts from the device (especially during initialization)
  623. // will be ignored. This value is only accessed in the ISR and
  624. // is only set via synchronization routines. We may be able
  625. // to get rid of this boolean when the code is more fleshed out.
  626. BOOLEAN DeviceIsOpen;
  627. // Records whether we actually created the symbolic link name
  628. // at driver load time. If we didn't create it, we won't try
  629. // to distry it when we unload.
  630. BOOLEAN CreatedSymbolicLink;
  631. // We place all of the kernel and Io subsystem "opaque" structures
  632. // at the end of the extension. We don't care about their contents.
  633. // This lock will be used to protect various fields in
  634. // the extension that are set (& read) in the extension
  635. // by the io controls.
  636. KSPIN_LOCK ControlLock;
  637. // This points to a DPC used to complete read requests.
  638. KDPC CompleteWriteDpc;
  639. // This points to a DPC used to complete read requests.
  640. KDPC CompleteReadDpc;
  641. // This dpc is fired off if the timer for the total timeout
  642. // for the read expires. It will execute a dpc routine that
  643. // will cause the current read to complete.
  644. KDPC TotalReadTimeoutDpc;
  645. // This dpc is fired off if the timer for the interval timeout
  646. // expires. If no more characters have been read then the
  647. // dpc routine will cause the read to complete. However, if
  648. // more characters have been read then the dpc routine will
  649. // resubmit the timer.
  650. KDPC IntervalReadTimeoutDpc;
  651. // This dpc is fired off if the timer for the total timeout
  652. // for the write expires. It will execute a dpc routine that
  653. // will cause the current write to complete.
  654. KDPC TotalWriteTimeoutDpc;
  655. // This dpc is fired off if a comm error occurs. It will
  656. // execute a dpc routine that will cancel all pending reads
  657. // and writes.
  658. KDPC CommErrorDpc;
  659. // This dpc is fired off if an event occurs and there was
  660. // a irp waiting on that event. A dpc routine will execute
  661. // that completes the irp.
  662. KDPC CommWaitDpc;
  663. // This dpc is fired off if the timer used to "timeout" counting
  664. // the number of characters received after the Xoff ioctl is started
  665. // expired.
  666. KDPC XoffCountTimeoutDpc;
  667. // This dpc is fired off if the xoff counter actually runs down
  668. // to zero.
  669. KDPC XoffCountCompleteDpc;
  670. // This is the kernal timer structure used to handle
  671. // total read request timing.
  672. KTIMER ReadRequestTotalTimer;
  673. // This is the kernal timer structure used to handle
  674. // interval read request timing.
  675. KTIMER ReadRequestIntervalTimer;
  676. // This is the kernal timer structure used to handle
  677. // total time request timing.
  678. KTIMER WriteRequestTotalTimer;
  679. // This timer is used to timeout the xoff counter
  680. // io.
  681. KTIMER XoffCountTimer;
  682. USHORT sent_packets; // number of write() packets
  683. USHORT rec_packets; // number of read() packets
  684. SERIALPERF_STATS OurStats; // our non-resetable stats
  685. SERIALPERF_STATS OldStats; // performance monitor statistics(resetable)
  686. USHORT TraceOptions; // Debug Trace Options. 1=trace, 2=in data, 4=out dat
  687. // 8 = isr level events
  688. USHORT ISR_Flags; // bit flags used to control ISR, detects EV_TXEMPTY
  689. // used by NT virt-driver to embed modem status changes in input stream
  690. unsigned char escapechar;
  691. unsigned char Option; // used for per port options
  692. void *TraceExt; // Debug Trace Extension
  693. PORT_CONFIG *port_config; // if a port extension, points to port config data
  694. DEVICE_CONFIG *config; // if a board extension, points to config data
  695. //KEVENT SerialSyncEvent;
  696. #ifdef S_RK
  697. CONTROLLER_T *CtlP; // if a board extension, points to controller struct
  698. #endif
  699. // This is to tell the driver that we have received a QUERY_POWER asking
  700. // to power down. The driver will then queue any open requests until after
  701. // the power down.
  702. BOOLEAN ReceivedQueryD3;
  703. #ifdef NT50
  704. PDEVICE_OBJECT Pdo; // new PnP object used to open registry.
  705. PDEVICE_OBJECT LowerDeviceObject; // new PnP stack arrangement.
  706. // This is where keep track of the power state the device is in.
  707. DEVICE_POWER_STATE PowerState;
  708. // String where we keep the symbolic link that is returned to us when we
  709. // register our device under the COMM class with the Plug and Play manager.
  710. //
  711. UNICODE_STRING DeviceClassSymbolicName;
  712. #endif
  713. // Count of pending IRP's
  714. ULONG PendingIRPCnt;
  715. // Accepting requests?
  716. ULONG DevicePNPAccept;
  717. // No IRP's pending event
  718. KEVENT PendingIRPEvent;
  719. // PNP State
  720. ULONG PNPState;
  721. // Used by PnP.c module
  722. //BOOLEAN DeviceIsOpened;
  723. BOOLEAN FdoStarted;
  724. #ifdef RING_FAKE
  725. BYTE ring_char; // used to implement RING emulation via software
  726. BYTE ring_timer; // used to implement RING emulation via software
  727. #endif
  728. #ifdef NT50
  729. // WMI Information
  730. WMILIB_CONTEXT WmiLibInfo;
  731. // Name to use as WMI identifier
  732. UNICODE_STRING WmiIdentifier;
  733. // WMI Comm Data
  734. SERIAL_WMI_COMM_DATA WmiCommData;
  735. // WMI HW Data
  736. SERIAL_WMI_HW_DATA WmiHwData;
  737. // WMI Performance Data
  738. SERIAL_WMI_PERF_DATA WmiPerfData;
  739. #endif
  740. } SERIAL_DEVICE_EXTENSION,*PSERIAL_DEVICE_EXTENSION;
  741. //--- bits for Option field in extension
  742. #define OPTION_RS485_OVERRIDE 0x0001 // always use 485 mode
  743. #define OPTION_RS485_SOFTWARE_TOGGLE 0x0002 // port in toggle mode
  744. #define OPTION_RS485_HIGH_ACTIVE 0x0004 // use hardware to toggle rts low
  745. //--- bit flags for ISR_Flags
  746. #define TX_NOT_EMPTY 0x0001
  747. #define SERIAL_PNPACCEPT_OK 0x0L
  748. #define SERIAL_PNPACCEPT_REMOVING 0x1L
  749. #define SERIAL_PNPACCEPT_STOPPING 0x2L
  750. #define SERIAL_PNPACCEPT_STOPPED 0x4L
  751. #define SERIAL_PNP_ADDED 0x0L
  752. #define SERIAL_PNP_STARTED 0x1L
  753. #define SERIAL_PNP_QSTOP 0x2L
  754. #define SERIAL_PNP_STOPPING 0x3L
  755. #define SERIAL_PNP_QREMOVE 0x4L
  756. #define SERIAL_PNP_REMOVING 0x5L
  757. #define SERIAL_FLAGS_CLEAR 0x0L
  758. #define SERIAL_FLAGS_STARTED 0x1L
  759. typedef struct _DRIVER_CONTROL {
  760. PDRIVER_OBJECT GlobalDriverObject;
  761. // copy of RegistryPath into DriverEntry, with room for adding options
  762. UNICODE_STRING RegPath;
  763. // working global RegistryPath string, , with room for adding options
  764. UNICODE_STRING OptionRegPath;
  765. // head link of all board extensions
  766. PSERIAL_DEVICE_EXTENSION board_ext;
  767. USHORT VerboseLog; // boolean flag tells to log verbose to eventlog.
  768. USHORT ScanRate; // scan rate in milliseconds
  769. USHORT PreScaler; // optional prescaler value for rocketport boards
  770. USHORT MdmCountryCode; // country code for ROW RocketModems
  771. USHORT MdmSettleTime; // time to allow modems to settle (unit=0.10 sec)
  772. ULONG load_testing; // load testing(creates artificial load in isr.c)
  773. #ifdef S_VS
  774. // This is the names of the NIC cards which we get from the Registry.
  775. // Used to specify the nic card when we do an OpenAdapter call.
  776. char *BindNames; // list of strings, null, null terminated [VS1000_MAX_BINDINGS];
  777. #ifdef OLD_BINDING_GATHER
  778. PWCHAR BindString; // binding in registry, tells us what nic cards we have
  779. // This is the names of the NIC cards which we get from the Registry.
  780. // Used to specify the nic card when wee do an OpenAdapter call.
  781. UNICODE_STRING NicName[VS1000_MAX_BINDINGS];
  782. int num_nics; // number of nic cards in system which we use
  783. int num_bindings; // number of nic card bindings in our NicName list
  784. // there may be lots of old useless bindings with NT, PCI adapters
  785. // leave an old binding resident for each slot they are booted in
  786. // under nt50, pcmcia adapters also have inactive bindings.
  787. #endif
  788. #ifdef TRY_DYNAMIC_BINDING
  789. // bind passes in a handle as a reference, when we get an un-bind
  790. // we get passed in another handle. At unbind time, we look up in
  791. // this table to figure which nic card it references.
  792. NDIS_HANDLE BindContext[VS1000_MAX_NICS];
  793. #endif
  794. Nic *nics; // our open nic adapters, array of Nic structs.
  795. //Hdlc *hd; // array of Hdlc structs(NumBoxes # of elements)
  796. //PortMan *pm; // array of PortMan structs(NumBoxes # of elements)
  797. //SerPort *sp; // total array of serial-port structs(1 per port)
  798. // tells if thread needs to save off a detected mac-address back
  799. // to config reg area.
  800. PSERIAL_DEVICE_EXTENSION AutoMacDevExt;
  801. #endif
  802. #ifdef S_RK
  803. ULONG SetupIrq; // Irq used, 0 if none, 1 if PCI automatic
  804. #endif
  805. PKINTERRUPT InterruptObject;
  806. // Timer fields
  807. KTIMER PollTimer;
  808. LARGE_INTEGER PollIntervalTime;
  809. KDPC TimerDpc;
  810. //USHORT TotalNTPorts; // count of ports registered with NT
  811. ULONG PollCnt; // count of interrupts/timer ticks
  812. ULONG WriteDpcCnt;
  813. USHORT TimerCreated;
  814. USHORT InRocketWrite;
  815. ULONG TraceOptions; // bit flags, tells what driver parts to trace
  816. ULONG TraceFlags;
  817. Queue DebugQ; // data output buffer for driver debug log
  818. PSERIAL_DEVICE_EXTENSION DebugExt;
  819. KSPIN_LOCK DebugLock;
  820. ULONG DebugTimeOut; // used to timeout inactive debug sessions.
  821. #ifdef S_RK
  822. USHORT RS485_Flags; // 1H bit set if Reverse hardware type
  823. // clear if driver toggles RTS high
  824. #endif
  825. ULONG GTraceFlags; // trace flags, global.
  826. ULONG mem_alloced; // track how much memory we are using
  827. #ifdef S_VS
  828. UCHAR *MicroCodeImage; // mem buf for micro code to download to unit
  829. ULONG MicroCodeSize; // size of it in bytes
  830. // This is the handle for the protocol returned by ndisregisterprotocol
  831. NDIS_HANDLE NdisProtocolHandle;
  832. ULONG ndis_version; // 3=NT3.51, 4=NT4.0(includes dynamic binding)
  833. // for auto-find boxes, make a list of boxes which respond with
  834. // there mac address. Keep 2 extra bytes, byte [6] is for
  835. // flags in response tells us if main-driver-app loaded,
  836. // while last byte[7] we stuff with the nic-index which responded.
  837. int NumBoxMacs;
  838. BYTE BoxMacs[MAX_NUM_BOXES*8];
  839. // following is a counter per mac-address added to list where
  840. // the list entry will be removed after it ticks down to zero.
  841. // when the mac-address is added to the list or found again,
  842. // the counter is initialized to some non-zero value(say 5)
  843. // and then each time a broadcast query is sent out, all the
  844. // counters are decremented by 1. When they hit zero, they
  845. // are removed from the list.
  846. BYTE BoxMacsCounter[MAX_NUM_BOXES];
  847. #else
  848. UCHAR *ModemLoaderCodeImage; // --> mem buf for modem loader code to download to unit
  849. ULONG ModemLoaderCodeSize; // size in bytes
  850. UCHAR *ModemCodeImage; // --> mem buf for modem code to download to unit
  851. ULONG ModemCodeSize; // size in bytes
  852. #endif
  853. int NoPnpPorts; // flag to tell if we should eject port pdo's
  854. #ifdef S_RK
  855. PSERIAL_DEVICE_EXTENSION irq_ext; // board ext doing global irq, null if not used
  856. #endif
  857. //int NT50_PnP;
  858. int NumDevices; // configuration count of NumDevices for NT4.0
  859. int Stop_Poll; // flag to stop poll access
  860. KSPIN_LOCK TimerLock; // Timer DPC(ISR) lock to sync up code
  861. #ifdef S_VS
  862. HANDLE threadHandle;
  863. int threadCount;
  864. //int TotalNTPorts; // this should go away(vs uses it)
  865. #endif
  866. LARGE_INTEGER IsrSysTime; // ISR service routine gets this every time
  867. // so we know what are time base is.
  868. LARGE_INTEGER LastIsrSysTime; // used to recalculate the tick rate periodically
  869. ULONG TickBaseCnt; // used to recalculate the tick rate periodically
  870. // this is the isr-tick rate in 100us units. Timers called by the
  871. // isr-service routine can assume they are called periodically based
  872. // on this rate. Needed for accurate time bases(VS protocol timers).
  873. ULONG Tick100usBase;
  874. // one of these made, and is used to support the global driver
  875. // object which the applications can open and talk to driver.
  876. PSERIAL_DEVICE_EXTENSION driver_ext;
  877. } DRIVER_CONTROL;
  878. typedef struct {
  879. char *imagepath;
  880. char *imagetype;
  881. UCHAR *image;
  882. ULONG imagesize;
  883. int rc;
  884. } MODEM_IMAGE;
  885. /* Configuration information structure for one port */
  886. typedef struct {
  887. ULONG BusNumber;
  888. ULONG PCI_Slot;
  889. ULONG PCI_DevID;
  890. ULONG PCI_RevID;
  891. ULONG BaseIoAddr;
  892. ULONG Irq;
  893. ULONG NumPorts;
  894. ULONG PCI_SVID;
  895. ULONG PCI_SID;
  896. ULONG Claimed; // 1 if we assigned or used it.
  897. } PCI_CONFIG;
  898. typedef
  899. NTSTATUS
  900. (*PSERIAL_START_ROUTINE) (
  901. IN PSERIAL_DEVICE_EXTENSION
  902. );
  903. typedef
  904. VOID
  905. (*PSERIAL_GET_NEXT_ROUTINE) (
  906. IN PIRP *CurrentOpIrp,
  907. IN PLIST_ENTRY QueueToProcess,
  908. OUT PIRP *NewIrp,
  909. IN BOOLEAN CompleteCurrent,
  910. PSERIAL_DEVICE_EXTENSION Extension
  911. );
  912. typedef struct _SERIAL_UPDATE_CHAR {
  913. PSERIAL_DEVICE_EXTENSION Extension;
  914. ULONG CharsCopied;
  915. BOOLEAN Completed;
  916. } SERIAL_UPDATE_CHAR,*PSERIAL_UPDATE_CHAR;
  917. //
  918. // The following simple structure is used to send a pointer
  919. // the device extension and an ioctl specific pointer
  920. // to data.
  921. //
  922. typedef struct _SERIAL_IOCTL_SYNC {
  923. PSERIAL_DEVICE_EXTENSION Extension;
  924. PVOID Data;
  925. } SERIAL_IOCTL_SYNC,*PSERIAL_IOCTL_SYNC;
  926. //
  927. // Return values for mouse detection callback
  928. //
  929. //#define SERIAL_FOUNDPOINTER_PORT 1
  930. //#define SERIAL_FOUNDPOINTER_VECTOR 2
  931. //
  932. // The following three macros are used to initialize, increment
  933. // and decrement reference counts in IRPs that are used by
  934. // this driver. The reference count is stored in the fourth
  935. // argument of the irp, which is never used by any operation
  936. // accepted by this driver.
  937. //
  938. #define SERIAL_REF_ISR (0x00000001)
  939. #define SERIAL_REF_CANCEL (0x00000002)
  940. #define SERIAL_REF_TOTAL_TIMER (0x00000004)
  941. #define SERIAL_REF_INT_TIMER (0x00000008)
  942. #define SERIAL_REF_XOFF_REF (0x00000010)
  943. #define SERIAL_INIT_REFERENCE(Irp) { \
  944. ASSERT(sizeof(LONG) <= sizeof(PVOID)); \
  945. IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4 = NULL; \
  946. }
  947. #define SERIAL_SET_REFERENCE(Irp,RefType) \
  948. do { \
  949. LONG _refType = (RefType); \
  950. PLONG _arg4 = (PVOID)&IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4; \
  951. GAssert(515,!(*_arg4 & _refType)); \
  952. *_arg4 |= _refType; \
  953. } while (0)
  954. #define SERIAL_CLEAR_REFERENCE(Irp,RefType) \
  955. do { \
  956. LONG _refType = (RefType); \
  957. PLONG _arg4 = (PVOID)&IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4; \
  958. *_arg4 &= ~_refType; \
  959. } while (0)
  960. //GAssert(516,*_arg4 & _refType); \ (pull out, not valid, kpb, 1-18-98)
  961. //#define SERIAL_INC_REFERENCE(Irp) \
  962. // ((*((LONG *)(&(IoGetCurrentIrpStackLocation((Irp)))->Parameters.Others.Argument4)))++)
  963. //#define SERIAL_DEC_REFERENCE(Irp) \
  964. // ((*((LONG *)(&(IoGetCurrentIrpStackLocation((Irp)))->Parameters.Others.Argument4)))--)
  965. #define SERIAL_REFERENCE_COUNT(Irp) \
  966. ((LONG)((IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4)))
  967. extern ULONG RocketDebugLevel;
  968. extern DRIVER_CONTROL Driver; // driver related options and references
  969. #ifdef S_RK
  970. extern PCI_CONFIG PciConfig[MAX_NUM_BOXES+1]; // array of all our pci-boards in sys
  971. #endif
  972. extern int LoadModemCode(char *firm_pathname,char *flm_pathname);
  973. extern void FreeModemFiles();