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.

286 lines
6.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: exports.c
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // This file contains the functions exported in response to IOCTL_INTERNAL_PARCLASS_CONNECT
  12. //
  13. #include "pch.h"
  14. USHORT
  15. ParExportedDetermineIeeeModes(
  16. IN PPDO_EXTENSION Extension
  17. )
  18. /*++
  19. Routine Description:
  20. Called by filter drivers to find out what Ieee Modes there Device Supports.
  21. Arguments:
  22. Extension - Device Extension
  23. Return Value:
  24. STATUS_SUCCESS if successful.
  25. --*/
  26. {
  27. Extension->BadProtocolModes = 0;
  28. IeeeDetermineSupportedProtocols(Extension);
  29. return Extension->ProtocolModesSupported;
  30. }
  31. NTSTATUS
  32. ParExportedIeeeFwdToRevMode(
  33. IN PPDO_EXTENSION Extension
  34. )
  35. /*++
  36. Routine Description:
  37. Called by filter drivers to put there device into reverse Ieee Mode.
  38. The Mode is determined by what was passed into the function
  39. ParExportedNegotiateIeeeMode() as the Reverse Protocol with the
  40. ModeMaskRev.
  41. Arguments:
  42. Extension - Device Extension
  43. Return Value:
  44. STATUS_SUCCESS if successful.
  45. --*/
  46. {
  47. return ( ParForwardToReverse( Extension ) );
  48. }
  49. NTSTATUS
  50. ParExportedIeeeRevToFwdMode(
  51. IN PPDO_EXTENSION Extension
  52. )
  53. /*++
  54. Routine Description:
  55. Called by filter drivers to put there device into forward Ieee Mode.
  56. The Mode is determined by what was passed into the function
  57. ParExportedNegotiateIeeeMode() as the Forward Protocol with the
  58. ModeMaskFwd.
  59. Arguments:
  60. Extension - Device Extension
  61. Return Value:
  62. STATUS_SUCCESS if successful.
  63. --*/
  64. {
  65. return ( ParReverseToForward( Extension ) );
  66. }
  67. NTSTATUS
  68. ParExportedNegotiateIeeeMode(
  69. IN PPDO_EXTENSION Extension,
  70. IN USHORT ModeMaskFwd,
  71. IN USHORT ModeMaskRev,
  72. IN PARALLEL_SAFETY ModeSafety,
  73. IN BOOLEAN IsForward
  74. )
  75. /*++
  76. Routine Description:
  77. Called by filter drivers to negotiate an IEEE mode.
  78. Arguments:
  79. Extension - Device Extension
  80. Extensibility - IEEE 1284 Extensibility
  81. Return Value:
  82. STATUS_SUCCESS if successful.
  83. --*/
  84. {
  85. NTSTATUS Status = STATUS_SUCCESS;
  86. if (Extension->Connected) {
  87. DD((PCE)Extension,DDE,"ParExportedNegotiateIeeeMode - FAIL - already connected\n");
  88. return STATUS_DEVICE_PROTOCOL_ERROR;
  89. }
  90. if (ModeSafety == UNSAFE_MODE) {
  91. // Checking to see if we are doing forward compatability and reverse Nibble or Byte
  92. if ( (ModeMaskFwd & CENTRONICS) || (ModeMaskFwd & IEEE_COMPATIBILITY) ) {
  93. if ( !((ModeMaskRev & NIBBLE) || (ModeMaskRev & CHANNEL_NIBBLE) || (ModeMaskRev & BYTE_BIDIR)) ) {
  94. DD((PCE)Extension,DDE,"ParExportedNegotiateIeeeMode - FAIL - invalid modes\n");
  95. return STATUS_UNSUCCESSFUL;
  96. }
  97. } else {
  98. // Unsafe mode is only possible if the Fwd and Rev PCTLs the same if other than above.
  99. if (ModeMaskFwd != ModeMaskRev) {
  100. DD((PCE)Extension,DDE,"ParExportedNegotiateIeeeMode - FAIL - Fwd and Rev modes do not match\n");
  101. return STATUS_UNSUCCESSFUL;
  102. }
  103. }
  104. // RMT - Need to fill in....
  105. // Todo....
  106. // Mark in the extension
  107. Extension->ModeSafety = ModeSafety;
  108. Status = IeeeNegotiateMode(Extension, ModeMaskRev, ModeMaskFwd);
  109. } else {
  110. Extension->ModeSafety = ModeSafety;
  111. Status = IeeeNegotiateMode(Extension, ModeMaskRev, ModeMaskFwd);
  112. }
  113. if (IsForward) {
  114. if (afpForward[Extension->IdxForwardProtocol].fnConnect) {
  115. Status = afpForward[Extension->IdxForwardProtocol].fnConnect(Extension, FALSE);
  116. }
  117. } else {
  118. if (arpReverse[Extension->IdxReverseProtocol].fnConnect) {
  119. Status = arpReverse[Extension->IdxReverseProtocol].fnConnect(Extension, FALSE);
  120. }
  121. }
  122. return Status;
  123. }
  124. NTSTATUS
  125. ParExportedTerminateIeeeMode(
  126. IN PPDO_EXTENSION Extension
  127. )
  128. /*++
  129. Routine Description:
  130. Called by filter drivers to terminate from an IEEE mode.
  131. Arguments:
  132. Extension - Device Extension
  133. Return Value:
  134. STATUS_SUCCESS if successful.
  135. --*/
  136. {
  137. // Check the extension for UNSAFE_MODE
  138. // and do the right thing
  139. if ( Extension->ModeSafety == UNSAFE_MODE ) {
  140. DD((PCE)Extension,DDT,"ParExportedTerminateIeeeMode in UNSAFE_MODE\n");
  141. // Need to fill in....
  142. // Todo....
  143. // Mark in the extension
  144. }
  145. if (Extension->CurrentPhase == PHASE_REVERSE_IDLE || Extension->CurrentPhase == PHASE_REVERSE_XFER) {
  146. if (arpReverse[Extension->IdxReverseProtocol].fnDisconnect) {
  147. arpReverse[Extension->IdxReverseProtocol].fnDisconnect( Extension );
  148. }
  149. } else {
  150. if (afpForward[Extension->IdxForwardProtocol].fnDisconnect) {
  151. afpForward[Extension->IdxForwardProtocol].fnDisconnect( Extension );
  152. }
  153. }
  154. Extension->ModeSafety = SAFE_MODE;
  155. return STATUS_SUCCESS;
  156. }
  157. NTSTATUS
  158. ParExportedParallelRead(
  159. IN PPDO_EXTENSION Extension,
  160. IN PVOID Buffer,
  161. IN ULONG NumBytesToRead,
  162. OUT PULONG NumBytesRead,
  163. IN UCHAR Channel
  164. )
  165. /*++
  166. Routine Description:
  167. Called by filter drivers to terminate from a currently connected mode.
  168. Arguments:
  169. Extension - Device Extension
  170. Return Value:
  171. STATUS_SUCCESS if successful.
  172. --*/
  173. {
  174. UNREFERENCED_PARAMETER( Channel );
  175. return ParRead( Extension, Buffer, NumBytesToRead, NumBytesRead);
  176. }
  177. NTSTATUS
  178. ParExportedParallelWrite(
  179. IN PPDO_EXTENSION Extension,
  180. OUT PVOID Buffer,
  181. IN ULONG NumBytesToWrite,
  182. OUT PULONG NumBytesWritten,
  183. IN UCHAR Channel
  184. )
  185. {
  186. UNREFERENCED_PARAMETER( Channel );
  187. return ParWrite( Extension, Buffer, NumBytesToWrite, NumBytesWritten);
  188. }
  189. NTSTATUS
  190. ParExportedTrySelect(
  191. IN PPDO_EXTENSION Extension,
  192. IN PARALLEL_1284_COMMAND Command
  193. )
  194. {
  195. UNREFERENCED_PARAMETER( Extension );
  196. UNREFERENCED_PARAMETER( Command );
  197. return STATUS_UNSUCCESSFUL;
  198. }
  199. NTSTATUS
  200. ParExportedDeSelect(
  201. IN PPDO_EXTENSION Extension,
  202. IN PARALLEL_1284_COMMAND Command
  203. )
  204. {
  205. UNREFERENCED_PARAMETER( Extension );
  206. UNREFERENCED_PARAMETER( Command );
  207. return STATUS_UNSUCCESSFUL;
  208. }