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.

319 lines
7.8 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. #include "readwrit.h"
  15. USHORT
  16. ParExportedDetermineIeeeModes(
  17. IN PDEVICE_EXTENSION Extension
  18. )
  19. /*++
  20. Routine Description:
  21. Called by filter drivers to find out what Ieee Modes there Device Supports.
  22. Arguments:
  23. Extension - Device Extension
  24. Return Value:
  25. STATUS_SUCCESS if successful.
  26. --*/
  27. {
  28. Extension->BadProtocolModes = 0;
  29. IeeeDetermineSupportedProtocols(Extension);
  30. return Extension->ProtocolModesSupported;
  31. }
  32. NTSTATUS
  33. ParExportedIeeeFwdToRevMode(
  34. IN PDEVICE_EXTENSION Extension
  35. )
  36. /*++
  37. Routine Description:
  38. Called by filter drivers to put there device into reverse Ieee Mode.
  39. The Mode is determined by what was passed into the function
  40. ParExportedNegotiateIeeeMode() as the Reverse Protocol with the
  41. ModeMaskRev.
  42. Arguments:
  43. Extension - Device Extension
  44. Return Value:
  45. STATUS_SUCCESS if successful.
  46. --*/
  47. {
  48. return ( ParForwardToReverse( Extension ) );
  49. }
  50. NTSTATUS
  51. ParExportedIeeeRevToFwdMode(
  52. IN PDEVICE_EXTENSION Extension
  53. )
  54. /*++
  55. Routine Description:
  56. Called by filter drivers to put there device into forward Ieee Mode.
  57. The Mode is determined by what was passed into the function
  58. ParExportedNegotiateIeeeMode() as the Forward Protocol with the
  59. ModeMaskFwd.
  60. Arguments:
  61. Extension - Device Extension
  62. Return Value:
  63. STATUS_SUCCESS if successful.
  64. --*/
  65. {
  66. return ( ParReverseToForward( Extension ) );
  67. }
  68. NTSTATUS
  69. ParExportedNegotiateIeeeMode(
  70. IN PDEVICE_EXTENSION Extension,
  71. IN USHORT ModeMaskFwd,
  72. IN USHORT ModeMaskRev,
  73. IN PARALLEL_SAFETY ModeSafety,
  74. IN BOOLEAN IsForward
  75. )
  76. /*++
  77. Routine Description:
  78. Called by filter drivers to negotiate an IEEE mode.
  79. Arguments:
  80. Extension - Device Extension
  81. Extensibility - IEEE 1284 Extensibility
  82. Return Value:
  83. STATUS_SUCCESS if successful.
  84. --*/
  85. {
  86. NTSTATUS Status = STATUS_SUCCESS;
  87. if (Extension->Connected)
  88. {
  89. ParDump2( PARERRORS, ("ParExportedNegotiateIeeeMode: Already Connected.\n"));
  90. return STATUS_DEVICE_PROTOCOL_ERROR;
  91. }
  92. if (ModeSafety == UNSAFE_MODE)
  93. {
  94. ParDump2( PARINFO, ("ParExportedNegotiateIeeeMode: UNSAFE_MODE.\n"));
  95. // Checking to see if we are doing forward compatability
  96. // and reverse Nibble or Byte
  97. if ( (ModeMaskFwd & CENTRONICS) || (ModeMaskFwd & IEEE_COMPATIBILITY) ) {
  98. if ( !((ModeMaskRev & NIBBLE) || (ModeMaskRev & CHANNEL_NIBBLE) || (ModeMaskRev & BYTE_BIDIR)) ) {
  99. ParDump2( PARERRORS, ("ParExportedNegotiateIeeeMode: UNSAFE_MODE Not correct modes.\n"));
  100. return STATUS_UNSUCCESSFUL;
  101. }
  102. } else {
  103. // Unsafe mode is only possible if the Fwd and Rev PCTLs
  104. // the same if Other than above.
  105. if (ModeMaskFwd != ModeMaskRev) {
  106. ParDump2( PARERRORS, ("ParExportedNegotiateIeeeMode: UNSAFE_MODE Forward and Reverse Modes do not match.\n"));
  107. return STATUS_UNSUCCESSFUL;
  108. }
  109. }
  110. // Need to fill in....
  111. // Todo....
  112. // Mark in the extension
  113. ParDump2( PARINFO, ("ParExportedNegotiateIeeeMode: UNSAFE_MODE Forward and Reverse Modes OK.\n"));
  114. Extension->ModeSafety = ModeSafety;
  115. ParDump2( PARINFO, ("ParExportedNegotiateIeeeMode: ModeSafety is %x.\n", Extension->ModeSafety));
  116. Status = IeeeNegotiateMode(Extension, ModeMaskRev, ModeMaskFwd);
  117. }
  118. else
  119. {
  120. ParDump2( PARINFO, ("ParExportedNegotiateIeeeMode: Negotiating Modes.\n"));
  121. Extension->ModeSafety = ModeSafety;
  122. Status = IeeeNegotiateMode(Extension, ModeMaskRev, ModeMaskFwd);
  123. }
  124. if (IsForward)
  125. {
  126. if (afpForward[Extension->IdxForwardProtocol].fnConnect)
  127. Status = afpForward[Extension->IdxForwardProtocol].fnConnect(Extension, FALSE);
  128. }
  129. else
  130. {
  131. if (arpReverse[Extension->IdxReverseProtocol].fnConnect)
  132. Status = arpReverse[Extension->IdxReverseProtocol].fnConnect(Extension, FALSE);
  133. }
  134. return Status;
  135. }
  136. NTSTATUS
  137. ParExportedTerminateIeeeMode(
  138. IN PDEVICE_EXTENSION Extension
  139. )
  140. /*++
  141. Routine Description:
  142. Called by filter drivers to terminate from an IEEE mode.
  143. Arguments:
  144. Extension - Device Extension
  145. Return Value:
  146. STATUS_SUCCESS if successful.
  147. --*/
  148. {
  149. // Check the extension for UNSAFE_MODE
  150. // and do the right thing
  151. if ( Extension->ModeSafety == UNSAFE_MODE ) {
  152. // Need to fill in....
  153. // Todo....
  154. // Mark in the extension
  155. }
  156. // dvdr
  157. ParDump2(PARENTRY, ("ParExportedTerminateIeeeMode: Entering\n"));
  158. if (Extension->CurrentPhase == PHASE_REVERSE_IDLE ||
  159. Extension->CurrentPhase == PHASE_REVERSE_XFER)
  160. {
  161. ParDump2(PARINFO, ("ParExportedTerminateIeeeMode: Calling Terminate Reverse Function\n"));
  162. if (arpReverse[Extension->IdxReverseProtocol].fnDisconnect)
  163. {
  164. ParDump2(PARINFO, ("ParExportedTerminateIeeeMode: Calling arpReverse.fnDisconnect\n"));
  165. arpReverse[Extension->IdxReverseProtocol].fnDisconnect (Extension);
  166. }
  167. }
  168. else
  169. {
  170. ParDump2(PARINFO, ("ParExportedTerminateIeeeMode: Calling Terminate Forward Function\n"));
  171. if (afpForward[Extension->IdxForwardProtocol].fnDisconnect)
  172. {
  173. ParDump2(PARINFO, ("ParExportedTerminateIeeeMode: Calling afpForward.fnDisconnect\n"));
  174. afpForward[Extension->IdxForwardProtocol].fnDisconnect (Extension);
  175. }
  176. }
  177. // dvdr
  178. ParDump2(PAREXIT, ("ParExportedTerminateIeeeMode: Leaving\n"));
  179. Extension->ModeSafety = SAFE_MODE;
  180. return STATUS_SUCCESS;
  181. }
  182. NTSTATUS
  183. ParExportedParallelRead(
  184. IN PDEVICE_EXTENSION Extension,
  185. IN PVOID Buffer,
  186. IN ULONG NumBytesToRead,
  187. OUT PULONG NumBytesRead,
  188. IN UCHAR Channel
  189. )
  190. /*++
  191. Routine Description:
  192. Called by filter drivers to terminate from a currently connected mode.
  193. Arguments:
  194. Extension - Device Extension
  195. Return Value:
  196. STATUS_SUCCESS if successful.
  197. --*/
  198. {
  199. UNREFERENCED_PARAMETER( Channel );
  200. return ParRead( Extension, Buffer, NumBytesToRead, NumBytesRead);
  201. }
  202. NTSTATUS
  203. ParExportedParallelWrite(
  204. IN PDEVICE_EXTENSION Extension,
  205. OUT PVOID Buffer,
  206. IN ULONG NumBytesToWrite,
  207. OUT PULONG NumBytesWritten,
  208. IN UCHAR Channel
  209. )
  210. /*++
  211. Routine Description:
  212. Called by filter drivers to terminate from a currently connected mode.
  213. Arguments:
  214. Extension - Device Extension
  215. Return Value:
  216. STATUS_SUCCESS if successful.
  217. --*/
  218. {
  219. UNREFERENCED_PARAMETER( Channel );
  220. ParDump2(PARINFO, ("ParExportedParallelWrite: Entering\n"));
  221. ParDump2(PARINFO, ("ParExportedParallelWrite: Calling ParWrite\n"));
  222. return ParWrite( Extension, Buffer, NumBytesToWrite, NumBytesWritten);
  223. }
  224. NTSTATUS
  225. ParExportedTrySelect(
  226. IN PDEVICE_EXTENSION Extension,
  227. IN PARALLEL_1284_COMMAND Command
  228. )
  229. {
  230. return( STATUS_UNSUCCESSFUL );
  231. }
  232. NTSTATUS
  233. ParExportedDeSelect(
  234. IN PDEVICE_EXTENSION Extension,
  235. IN PARALLEL_1284_COMMAND Command
  236. )
  237. {
  238. return( STATUS_UNSUCCESSFUL );
  239. }