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.

892 lines
19 KiB

  1. /*--------------------------------------------------------------------------
  2. *
  3. * Copyright (C) Cyclades Corporation, 1997-2001.
  4. * All rights reserved.
  5. *
  6. * Cyclades-Z Port Driver
  7. *
  8. * This file: cyzportp.h
  9. *
  10. * Description: Prototypes and macros that are used throughout the
  11. * driver.
  12. *
  13. * Notes: This code supports Windows 2000 and x86 processor.
  14. *
  15. * Complies with Cyclades SW Coding Standard rev 1.3.
  16. *
  17. *--------------------------------------------------------------------------
  18. */
  19. /*-------------------------------------------------------------------------
  20. *
  21. * Change History
  22. *
  23. *--------------------------------------------------------------------------
  24. *
  25. *
  26. *--------------------------------------------------------------------------
  27. */
  28. typedef
  29. NTSTATUS
  30. (*PSERIAL_START_ROUTINE) (
  31. IN PCYZ_DEVICE_EXTENSION
  32. );
  33. typedef
  34. VOID
  35. (*PSERIAL_GET_NEXT_ROUTINE) (
  36. IN PIRP *CurrentOpIrp,
  37. IN PLIST_ENTRY QueueToProcess,
  38. OUT PIRP *NewIrp,
  39. IN BOOLEAN CompleteCurrent,
  40. PCYZ_DEVICE_EXTENSION Extension
  41. );
  42. // cyzinit.c prototypes
  43. NTSTATUS
  44. DriverEntry(
  45. IN PDRIVER_OBJECT DriverObject,
  46. IN PUNICODE_STRING RegistryPath
  47. );
  48. VOID
  49. CyzDisableInterfacesResources(IN PDEVICE_OBJECT PDevObj,
  50. BOOLEAN DisableUART);
  51. VOID
  52. CyzKillPendingIrps(PDEVICE_OBJECT DeviceObject);
  53. CYZ_MEM_COMPARES
  54. CyzMemCompare(
  55. IN PHYSICAL_ADDRESS A,
  56. IN ULONG SpanOfA,
  57. IN PHYSICAL_ADDRESS B,
  58. IN ULONG SpanOfB
  59. );
  60. VOID
  61. CyzReleaseResources(IN PCYZ_DEVICE_EXTENSION PDevExt);
  62. NTSTATUS
  63. CyzRemoveDevObj(IN PDEVICE_OBJECT PDevObj);
  64. BOOLEAN
  65. CyzDoesPortExist(
  66. IN PCYZ_DEVICE_EXTENSION Extension,
  67. IN PUNICODE_STRING InsertString
  68. );
  69. BOOLEAN
  70. CyzReset(
  71. IN PVOID Context
  72. );
  73. VOID
  74. CyzUnload(
  75. IN PDRIVER_OBJECT DriverObject
  76. );
  77. NTSTATUS
  78. CyzInitController(IN PDEVICE_OBJECT PDevObj, IN PCONFIG_DATA PConfigData);
  79. VOID
  80. CyzResetBoard( PCYZ_DEVICE_EXTENSION Extension );
  81. NTSTATUS
  82. CyzFindInitController(IN PDEVICE_OBJECT PDevObj, IN PCONFIG_DATA PConfig);
  83. VOID
  84. CyzCommError(
  85. IN PKDPC Dpc,
  86. IN PVOID DeferredContext,
  87. IN PVOID SystemContext1,
  88. IN PVOID SystemContext2
  89. );
  90. // end cyzinit.c
  91. NTSTATUS
  92. CyzRead(
  93. IN PDEVICE_OBJECT DeviceObject,
  94. IN PIRP Irp
  95. );
  96. NTSTATUS
  97. CyzStartRead(
  98. IN PCYZ_DEVICE_EXTENSION Extension
  99. );
  100. VOID
  101. CyzCompleteRead(
  102. IN PKDPC Dpc,
  103. IN PVOID DeferredContext,
  104. IN PVOID SystemContext1,
  105. IN PVOID SystemContext2
  106. );
  107. VOID
  108. CyzReadTimeout(
  109. IN PKDPC Dpc,
  110. IN PVOID DeferredContext,
  111. IN PVOID SystemContext1,
  112. IN PVOID SystemContext2
  113. );
  114. VOID
  115. CyzIntervalReadTimeout(
  116. IN PKDPC Dpc,
  117. IN PVOID DeferredContext,
  118. IN PVOID SystemContext1,
  119. IN PVOID SystemContext2
  120. );
  121. NTSTATUS
  122. CyzFlush(
  123. IN PDEVICE_OBJECT DeviceObject,
  124. IN PIRP Irp
  125. );
  126. NTSTATUS
  127. CyzWrite(
  128. IN PDEVICE_OBJECT DeviceObject,
  129. IN PIRP Irp
  130. );
  131. NTSTATUS
  132. CyzStartWrite(
  133. IN PCYZ_DEVICE_EXTENSION Extension
  134. );
  135. VOID
  136. CyzGetNextWrite(
  137. IN PIRP *CurrentOpIrp,
  138. IN PLIST_ENTRY QueueToProcess,
  139. IN PIRP *NewIrp,
  140. IN BOOLEAN CompleteCurrent,
  141. IN PCYZ_DEVICE_EXTENSION Extension
  142. );
  143. VOID
  144. CyzCompleteWrite(
  145. IN PKDPC Dpc,
  146. IN PVOID DeferredContext,
  147. IN PVOID SystemContext1,
  148. IN PVOID SystemContext2
  149. );
  150. BOOLEAN
  151. CyzTxStart(
  152. IN PVOID Context
  153. );
  154. BOOLEAN
  155. CyzSendXon(
  156. IN PVOID Context
  157. );
  158. BOOLEAN
  159. CyzSendXoff(
  160. IN PVOID Context
  161. );
  162. BOOLEAN
  163. CyzProcessEmptyTransmit(
  164. IN PVOID Context
  165. );
  166. VOID
  167. CyzWriteTimeout(
  168. IN PKDPC Dpc,
  169. IN PVOID DeferredContext,
  170. IN PVOID SystemContext1,
  171. IN PVOID SystemContext2
  172. );
  173. NTSTATUS
  174. CyzCleanup(
  175. IN PDEVICE_OBJECT DeviceObject,
  176. IN PIRP Irp
  177. );
  178. NTSTATUS
  179. CyzCreateOpen(
  180. IN PDEVICE_OBJECT DeviceObject,
  181. IN PIRP Irp
  182. );
  183. NTSTATUS
  184. CyzClose(
  185. IN PDEVICE_OBJECT DeviceObject,
  186. IN PIRP Irp
  187. );
  188. BOOLEAN
  189. CyzDisableHw(
  190. IN PVOID Context
  191. );
  192. BOOLEAN
  193. CyzTryToDisableTimer(
  194. IN PVOID Context
  195. );
  196. BOOLEAN
  197. CyzSetDTR(
  198. IN PVOID Context
  199. );
  200. BOOLEAN
  201. CyzClrDTR(
  202. IN PVOID Context
  203. );
  204. BOOLEAN
  205. CyzSetRTS(
  206. IN PVOID Context
  207. );
  208. BOOLEAN
  209. CyzClrRTS(
  210. IN PVOID Context
  211. );
  212. BOOLEAN
  213. CyzSetChars(
  214. IN PVOID Context
  215. );
  216. BOOLEAN
  217. CyzSetBaud(
  218. IN PVOID Context
  219. );
  220. BOOLEAN
  221. CyzSetLineControl(
  222. IN PVOID Context
  223. );
  224. BOOLEAN
  225. CyzSetupNewHandFlow(
  226. IN PCYZ_DEVICE_EXTENSION Extension,
  227. IN PSERIAL_HANDFLOW NewHandFlow
  228. );
  229. BOOLEAN
  230. CyzSetHandFlow(
  231. IN PVOID Context
  232. );
  233. BOOLEAN
  234. CyzTurnOnBreak(
  235. IN PVOID Context
  236. );
  237. BOOLEAN
  238. CyzTurnOffBreak(
  239. IN PVOID Context
  240. );
  241. BOOLEAN
  242. CyzPretendXoff(
  243. IN PVOID Context
  244. );
  245. BOOLEAN
  246. CyzPretendXon(
  247. IN PVOID Context
  248. );
  249. VOID
  250. CyzHandleReducedIntBuffer(
  251. IN PCYZ_DEVICE_EXTENSION Extension
  252. );
  253. VOID
  254. CyzProdXonXoff(
  255. IN PCYZ_DEVICE_EXTENSION Extension,
  256. IN BOOLEAN SendXon
  257. );
  258. NTSTATUS
  259. CyzIoControl(
  260. IN PDEVICE_OBJECT DeviceObject,
  261. IN PIRP Irp
  262. );
  263. NTSTATUS
  264. CyzStartMask(
  265. IN PCYZ_DEVICE_EXTENSION Extension
  266. );
  267. VOID
  268. CyzCancelWait(
  269. IN PDEVICE_OBJECT DeviceObject,
  270. IN PIRP Irp
  271. );
  272. VOID
  273. CyzCompleteWait(
  274. IN PKDPC Dpc,
  275. IN PVOID DeferredContext,
  276. IN PVOID SystemContext1,
  277. IN PVOID SystemContext2
  278. );
  279. VOID
  280. CyzStartImmediate(
  281. IN PCYZ_DEVICE_EXTENSION Extension
  282. );
  283. VOID
  284. CyzCompleteImmediate(
  285. IN PKDPC Dpc,
  286. IN PVOID DeferredContext,
  287. IN PVOID SystemContext1,
  288. IN PVOID SystemContext2
  289. );
  290. VOID
  291. CyzTimeoutImmediate(
  292. IN PKDPC Dpc,
  293. IN PVOID DeferredContext,
  294. IN PVOID SystemContext1,
  295. IN PVOID SystemContext2
  296. );
  297. VOID
  298. CyzTimeoutXoff(
  299. IN PKDPC Dpc,
  300. IN PVOID DeferredContext,
  301. IN PVOID SystemContext1,
  302. IN PVOID SystemContext2
  303. );
  304. VOID
  305. CyzCompleteXoff(
  306. IN PKDPC Dpc,
  307. IN PVOID DeferredContext,
  308. IN PVOID SystemContext1,
  309. IN PVOID SystemContext2
  310. );
  311. NTSTATUS
  312. CyzStartPurge(
  313. IN PCYZ_DEVICE_EXTENSION Extension
  314. );
  315. BOOLEAN
  316. CyzPurgeInterruptBuff(
  317. IN PVOID Context
  318. );
  319. NTSTATUS
  320. CyzQueryInformationFile(
  321. IN PDEVICE_OBJECT DeviceObject,
  322. IN PIRP Irp
  323. );
  324. NTSTATUS
  325. CyzSetInformationFile(
  326. IN PDEVICE_OBJECT DeviceObject,
  327. IN PIRP Irp
  328. );
  329. VOID
  330. CyzKillAllReadsOrWrites(
  331. IN PDEVICE_OBJECT DeviceObject,
  332. IN PLIST_ENTRY QueueToClean,
  333. IN PIRP *CurrentOpIrp
  334. );
  335. VOID
  336. CyzGetNextIrp(
  337. IN PIRP *CurrentOpIrp,
  338. IN PLIST_ENTRY QueueToProcess,
  339. OUT PIRP *NextIrp,
  340. IN BOOLEAN CompleteCurrent,
  341. IN PCYZ_DEVICE_EXTENSION Extension
  342. );
  343. VOID
  344. CyzTryToCompleteCurrent(
  345. IN PCYZ_DEVICE_EXTENSION Extension,
  346. IN PKSYNCHRONIZE_ROUTINE SynchRoutine OPTIONAL,
  347. IN KIRQL IrqlForRelease,
  348. IN NTSTATUS StatusToUse,
  349. IN PIRP *CurrentOpIrp,
  350. IN PLIST_ENTRY QueueToProcess,
  351. IN PKTIMER IntervalTimer,
  352. IN PKTIMER TotalTimer,
  353. IN PSERIAL_START_ROUTINE Starter,
  354. IN PSERIAL_GET_NEXT_ROUTINE GetNextIrp,
  355. IN LONG RefType
  356. );
  357. NTSTATUS
  358. CyzStartOrQueue(
  359. IN PCYZ_DEVICE_EXTENSION Extension,
  360. IN PIRP Irp,
  361. IN PLIST_ENTRY QueueToExamine,
  362. IN PIRP *CurrentOpIrp,
  363. IN PSERIAL_START_ROUTINE Starter
  364. );
  365. VOID
  366. CyzCancelQueued(
  367. PDEVICE_OBJECT DeviceObject,
  368. PIRP Irp
  369. );
  370. NTSTATUS
  371. CyzCompleteIfError(
  372. PDEVICE_OBJECT DeviceObject,
  373. PIRP Irp
  374. );
  375. ULONG
  376. CyzHandleModemUpdate(
  377. IN PCYZ_DEVICE_EXTENSION Extension,
  378. IN BOOLEAN DoingTX,
  379. IN ULONG Reason
  380. );
  381. #ifdef POLL
  382. VOID
  383. CyzPollingDpc(
  384. IN PKDPC Dpc,
  385. IN PVOID DeferredContext,
  386. IN PVOID SystemContext1,
  387. IN PVOID SystemContext2
  388. );
  389. #else
  390. BOOLEAN
  391. CyzIsr(
  392. IN PKINTERRUPT InterruptObject,
  393. IN PVOID Context
  394. );
  395. VOID
  396. CyzRx(
  397. IN PCYZ_DEVICE_EXTENSION Extension
  398. );
  399. VOID
  400. CyzTx(
  401. IN PCYZ_DEVICE_EXTENSION Extension
  402. );
  403. #endif
  404. BOOLEAN
  405. CyzPerhapsLowerRTS(
  406. IN PVOID Context
  407. );
  408. VOID
  409. CyzStartTimerLowerRTS(
  410. IN PKDPC Dpc,
  411. IN PVOID DeferredContext,
  412. IN PVOID SystemContext1,
  413. IN PVOID SystemContext2
  414. );
  415. VOID
  416. CyzInvokePerhapsLowerRTS(
  417. IN PKDPC Dpc,
  418. IN PVOID DeferredContext,
  419. IN PVOID SystemContext1,
  420. IN PVOID SystemContext2
  421. );
  422. VOID
  423. CyzCleanupDevice(
  424. IN PCYZ_DEVICE_EXTENSION Extension
  425. );
  426. UCHAR
  427. CyzProcessLSR(
  428. IN PCYZ_DEVICE_EXTENSION Extension,
  429. IN UCHAR LineStatus
  430. );
  431. LARGE_INTEGER
  432. CyzGetCharTime(
  433. IN PCYZ_DEVICE_EXTENSION Extension
  434. );
  435. BOOLEAN
  436. CyzMarkClose(
  437. IN PVOID Context
  438. );
  439. BOOLEAN
  440. CyzIndexedMultiportIsr(
  441. IN PKINTERRUPT InterruptObject,
  442. IN PVOID Context
  443. );
  444. BOOLEAN
  445. CyzBitMappedMultiportIsr(
  446. IN PKINTERRUPT InterruptObject,
  447. IN PVOID Context
  448. );
  449. VOID
  450. CyzPutChar(
  451. IN PCYZ_DEVICE_EXTENSION Extension,
  452. IN UCHAR CharToPut
  453. );
  454. BOOLEAN
  455. CyzGetStats(
  456. IN PVOID Context
  457. );
  458. BOOLEAN
  459. CyzClearStats(
  460. IN PVOID Context
  461. );
  462. // cyzreg.c
  463. NTSTATUS
  464. CyzGetConfigDefaults(
  465. IN PCYZ_REGISTRY_DATA DriverDefaultsPtr,
  466. IN PUNICODE_STRING RegistryPath
  467. );
  468. NTSTATUS
  469. CyzGetRegistryKeyValue (
  470. IN HANDLE Handle,
  471. IN PWCHAR KeyNameString,
  472. IN ULONG KeyNameStringLength,
  473. IN PVOID Data,
  474. IN ULONG DataLength
  475. );
  476. ULONG
  477. CyzGetRegistryKeyValueLength (
  478. IN HANDLE Handle,
  479. IN PWCHAR KeyNameString,
  480. IN ULONG KeyNameStringLength);
  481. NTSTATUS
  482. CyzPutRegistryKeyValue(IN HANDLE Handle, IN PWCHAR PKeyNameString,
  483. IN ULONG KeyNameStringLength, IN ULONG Dtype,
  484. IN PVOID PData, IN ULONG DataLength);
  485. // cyzpnp.c
  486. NTSTATUS
  487. CyzAddDevice(
  488. IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PLowerDevObj);
  489. //NTSTATUS
  490. //CyzCreateDevObj(IN PDRIVER_OBJECT DriverObject,
  491. // OUT PDEVICE_OBJECT *NewDeviceObject);
  492. NTSTATUS
  493. CyzCreateDevObj(IN PDRIVER_OBJECT DriverObject,
  494. IN PDEVICE_OBJECT PPdo,
  495. OUT PDEVICE_OBJECT *NewDeviceObject);
  496. NTSTATUS
  497. CyzFinishStartDevice(IN PDEVICE_OBJECT PDevObj,
  498. IN PCM_RESOURCE_LIST PResList,
  499. IN PCM_RESOURCE_LIST PTrResList);
  500. NTSTATUS
  501. CyzGetPortInfo(IN PDEVICE_OBJECT PDevObj, IN PCM_RESOURCE_LIST PResList,
  502. IN PCM_RESOURCE_LIST PTrResList, OUT PCONFIG_DATA PConfig);
  503. NTSTATUS
  504. CyzStartDevice(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp);
  505. NTSTATUS
  506. CyzSyncCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp,
  507. IN PKEVENT CyzSyncEvent);
  508. NTSTATUS
  509. CyzPnpDispatch(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp);
  510. NTSTATUS
  511. CyzDoExternalNaming(IN PCYZ_DEVICE_EXTENSION PDevExt,
  512. IN PDRIVER_OBJECT PDrvObj);
  513. VOID
  514. CyzUndoExternalNaming(IN PCYZ_DEVICE_EXTENSION Extension);
  515. UINT32
  516. CyzReportMaxBaudRate(ULONG Bauds);
  517. // cyzioctl.c
  518. VOID
  519. CyzGetProperties(
  520. IN PCYZ_DEVICE_EXTENSION Extension,
  521. IN PSERIAL_COMMPROP Properties
  522. );
  523. NTSTATUS
  524. CyzInternalIoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
  525. BOOLEAN
  526. CyzSetMCRContents(IN PVOID Context);
  527. BOOLEAN
  528. CyzGetMCRContents(IN PVOID Context);
  529. BOOLEAN
  530. CyzSetFCRContents(IN PVOID Context);
  531. VOID
  532. CyzIssueCmd(
  533. PCYZ_DEVICE_EXTENSION Extension,
  534. ULONG cmd,
  535. ULONG param,
  536. BOOLEAN wait
  537. );
  538. // cyzpower.c
  539. NTSTATUS
  540. CyzPowerDispatch(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp);
  541. NTSTATUS
  542. CyzGotoPowerState(IN PDEVICE_OBJECT PDevObj,
  543. IN PCYZ_DEVICE_EXTENSION PDevExt,
  544. IN DEVICE_POWER_STATE DevPowerState);
  545. NTSTATUS
  546. CyzSendWaitWake(PCYZ_DEVICE_EXTENSION PDevExt);
  547. VOID
  548. CyzRestoreDeviceState(IN PCYZ_DEVICE_EXTENSION PDevExt);
  549. NTSTATUS
  550. CyzSetPowerD0(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp);
  551. NTSTATUS
  552. CyzSetPowerD3(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp);
  553. VOID
  554. CyzSaveDeviceState(IN PCYZ_DEVICE_EXTENSION PDevExt);
  555. NTSTATUS
  556. CyzWakeCompletion(IN PDEVICE_OBJECT PDevObj, IN UCHAR MinorFunction,
  557. IN POWER_STATE PowerState, IN PVOID Context,
  558. IN PIO_STATUS_BLOCK IoStatus);
  559. // cyzwmi.c
  560. NTSTATUS
  561. CyzQueryWmiDataBlock(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp,
  562. IN ULONG GuidIndex,
  563. IN ULONG InstanceIndex,
  564. IN ULONG InstanceCount,
  565. IN OUT PULONG InstanceLengthArray,
  566. IN ULONG OutBufferSize,
  567. OUT PUCHAR PBuffer);
  568. NTSTATUS
  569. CyzQueryWmiRegInfo(IN PDEVICE_OBJECT PDevObj, OUT PULONG PRegFlags,
  570. OUT PUNICODE_STRING PInstanceName,
  571. OUT PUNICODE_STRING *PRegistryPath,
  572. OUT PUNICODE_STRING MofResourceName,
  573. OUT PDEVICE_OBJECT *Pdo);
  574. NTSTATUS
  575. CyzSetWmiDataBlock(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp,
  576. IN ULONG GuidIndex, IN ULONG InstanceIndex,
  577. IN ULONG BufferSize,
  578. IN PUCHAR PBuffer);
  579. NTSTATUS
  580. CyzSetWmiDataItem(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp,
  581. IN ULONG GuidIndex, IN ULONG InstanceIndex,
  582. IN ULONG DataItemId,
  583. IN ULONG BufferSize, IN PUCHAR PBuffer);
  584. NTSTATUS
  585. CyzSystemControlDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
  586. NTSTATUS
  587. CyzTossWMIRequest(IN PDEVICE_OBJECT PDevObj, IN PIRP PIrp,
  588. IN ULONG GuidIndex);
  589. // cyzutils.c
  590. BOOLEAN
  591. CyzCancelTimer(IN PKTIMER Timer, IN PCYZ_DEVICE_EXTENSION PDevExt);
  592. VOID
  593. CyzDpcEpilogue(IN PCYZ_DEVICE_EXTENSION PDevExt, PKDPC PDpc);
  594. VOID
  595. CyzGetNextIrpLocked(
  596. IN PIRP *CurrentOpIrp,
  597. IN PLIST_ENTRY QueueToProcess,
  598. OUT PIRP *NextIrp,
  599. IN BOOLEAN CompleteCurrent,
  600. IN PCYZ_DEVICE_EXTENSION extension,
  601. IN KIRQL OldIrql
  602. );
  603. BOOLEAN
  604. CyzInsertQueueDpc(IN PRKDPC PDpc, IN PVOID Sarg1, IN PVOID Sarg2,
  605. IN PCYZ_DEVICE_EXTENSION PDevExt);
  606. NTSTATUS
  607. CyzIRPPrologue(IN PIRP PIrp, IN PCYZ_DEVICE_EXTENSION PDevExt);
  608. VOID
  609. CyzIRPEpilogue(IN PCYZ_DEVICE_EXTENSION PDevExt);
  610. NTSTATUS
  611. CyzIoCallDriver(PCYZ_DEVICE_EXTENSION PDevExt, PDEVICE_OBJECT PDevObj,
  612. PIRP PIrp);
  613. VOID
  614. CyzKillAllStalled(IN PDEVICE_OBJECT PDevObj);
  615. VOID
  616. CyzLogError(
  617. IN PDRIVER_OBJECT DriverObject,
  618. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  619. IN PHYSICAL_ADDRESS P1,
  620. IN PHYSICAL_ADDRESS P2,
  621. IN ULONG SequenceNumber,
  622. IN UCHAR MajorFunctionCode,
  623. IN UCHAR RetryCount,
  624. IN ULONG UniqueErrorValue,
  625. IN NTSTATUS FinalStatus,
  626. IN NTSTATUS SpecificIOStatus,
  627. IN ULONG LengthOfInsert1,
  628. IN PWCHAR Insert1,
  629. IN ULONG LengthOfInsert2,
  630. IN PWCHAR Insert2
  631. );
  632. VOID
  633. CyzMarkHardwareBroken(IN PCYZ_DEVICE_EXTENSION PDevExt);
  634. NTSTATUS
  635. CyzPoCallDriver(PCYZ_DEVICE_EXTENSION PDevExt, PDEVICE_OBJECT PDevObj,
  636. PIRP PIrp);
  637. VOID
  638. CyzSetDeviceFlags(IN PCYZ_DEVICE_EXTENSION PDevExt, OUT PULONG PFlags,
  639. IN ULONG Value, IN BOOLEAN Set);
  640. BOOLEAN
  641. CyzSetTimer(IN PKTIMER Timer, IN LARGE_INTEGER DueTime,
  642. IN PKDPC Dpc OPTIONAL, IN PCYZ_DEVICE_EXTENSION PDevExt);
  643. VOID
  644. CyzUnlockPages(IN PKDPC PDpc, IN PVOID PDeferredContext,
  645. IN PVOID PSysContext1, IN PVOID PSysContext2);
  646. VOID
  647. CyzUnstallIrps(IN PCYZ_DEVICE_EXTENSION PDevExt);
  648. // cyzpoll.c
  649. ULONG
  650. CyzAmountInTxBuffer(
  651. IN PCYZ_DEVICE_EXTENSION Extension
  652. );
  653. ULONG
  654. CyzAmountInRxBuffer(
  655. IN PCYZ_DEVICE_EXTENSION extension
  656. );
  657. VOID
  658. CyzQueueCompleteWrite(
  659. IN PCYZ_DEVICE_EXTENSION Extension
  660. );
  661. BOOLEAN
  662. CyzCheckIfTxEmpty(
  663. IN PVOID Context
  664. );
  665. // End of prototypes
  666. typedef struct _SERIAL_UPDATE_CHAR {
  667. PCYZ_DEVICE_EXTENSION Extension;
  668. ULONG CharsCopied;
  669. BOOLEAN Completed;
  670. } SERIAL_UPDATE_CHAR,*PSERIAL_UPDATE_CHAR;
  671. //
  672. // The following simple structure is used to send a pointer
  673. // the device extension and an ioctl specific pointer
  674. // to data.
  675. //
  676. typedef struct _CYZ_IOCTL_SYNC {
  677. PCYZ_DEVICE_EXTENSION Extension;
  678. PVOID Data;
  679. } CYZ_IOCTL_SYNC,*PCYZ_IOCTL_SYNC;
  680. typedef struct _CYZ_IOCTL_BAUD {
  681. PCYZ_DEVICE_EXTENSION Extension;
  682. ULONG Baud;
  683. } CYZ_IOCTL_BAUD,*PCYZ_IOCTL_BAUD;
  684. typedef struct _CYZ_CLOSE_SYNC {
  685. PCYZ_DEVICE_EXTENSION Extension;
  686. PVOID Data;
  687. } CYZ_CLOSE_SYNC,*PCYZ_CLOSE_SYNC;
  688. #define CyzSetFlags(PDevExt, Value) \
  689. CyzSetDeviceFlags((PDevExt), &(PDevExt)->Flags, (Value), TRUE)
  690. #define CyzClearFlags(PDevExt, Value) \
  691. CyzSetDeviceFlags((PDevExt), &(PDevExt)->Flags, (Value), FALSE)
  692. #define CyzSetAccept(PDevExt, Value) \
  693. CyzSetDeviceFlags((PDevExt), &(PDevExt)->DevicePNPAccept, (Value), TRUE)
  694. #define CyzClearAccept(PDevExt, Value) \
  695. CyzSetDeviceFlags((PDevExt), &(PDevExt)->DevicePNPAccept, (Value), FALSE)
  696. //
  697. // The following three macros are used to initialize, set
  698. // and clear references in IRPs that are used by
  699. // this driver. The reference is stored in the fourth
  700. // argument of the irp, which is never used by any operation
  701. // accepted by this driver.
  702. //
  703. #define SERIAL_REF_ISR (0x00000001)
  704. #define SERIAL_REF_CANCEL (0x00000002)
  705. #define SERIAL_REF_TOTAL_TIMER (0x00000004)
  706. #define SERIAL_REF_INT_TIMER (0x00000008)
  707. #define SERIAL_REF_XOFF_REF (0x00000010)
  708. #define SERIAL_INIT_REFERENCE(Irp) { \
  709. ASSERT(sizeof(ULONG_PTR) <= sizeof(PVOID)); \
  710. IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4 = NULL; \
  711. }
  712. #define SERIAL_SET_REFERENCE(Irp,RefType) \
  713. do { \
  714. LONG _refType = (RefType); \
  715. PULONG_PTR _arg4 = (PVOID)&IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4; \
  716. ASSERT(!(*_arg4 & _refType)); \
  717. *_arg4 |= _refType; \
  718. } while (0)
  719. #define SERIAL_CLEAR_REFERENCE(Irp,RefType) \
  720. do { \
  721. LONG _refType = (RefType); \
  722. PULONG_PTR _arg4 = (PVOID)&IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4; \
  723. ASSERT(*_arg4 & _refType); \
  724. *_arg4 &= ~_refType; \
  725. } while (0)
  726. #define SERIAL_REFERENCE_COUNT(Irp) \
  727. ((ULONG_PTR)((IoGetCurrentIrpStackLocation((Irp))->Parameters.Others.Argument4)))