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.

104 lines
2.5 KiB

  1. /*++
  2. Module Name:
  3. modmflow.c
  4. Environment:
  5. Kernel mode
  6. Revision History :
  7. --*/
  8. #include "precomp.h"
  9. BOOLEAN
  10. MoxaSetupNewHandFlow(
  11. IN PVOID Context
  12. )
  13. {
  14. PMOXA_IOCTL_SYNC S = Context;
  15. PMOXA_DEVICE_EXTENSION Extension = S->Extension;
  16. PSERIAL_HANDFLOW NewHandFlow = S->Data;
  17. SERIAL_HANDFLOW New = *NewHandFlow;
  18. USHORT flowControl = 0;
  19. PUCHAR ofs = Extension->PortOfs;
  20. if ((!Extension->DeviceIsOpened) ||
  21. ((Extension->HandFlow.ControlHandShake & SERIAL_CTS_HANDSHAKE) !=
  22. (New.ControlHandShake & SERIAL_CTS_HANDSHAKE)) ||
  23. ((Extension->HandFlow.FlowReplace & SERIAL_AUTO_TRANSMIT) !=
  24. (New.FlowReplace & SERIAL_AUTO_TRANSMIT)) ||
  25. ((Extension->HandFlow.FlowReplace & SERIAL_AUTO_RECEIVE) !=
  26. (New.FlowReplace & SERIAL_AUTO_RECEIVE)) ||
  27. ((Extension->HandFlow.FlowReplace & SERIAL_RTS_HANDSHAKE) !=
  28. (New.FlowReplace & SERIAL_RTS_HANDSHAKE))) {
  29. if (New.ControlHandShake & SERIAL_CTS_HANDSHAKE)
  30. flowControl |= CTS_FlowCtl;
  31. if (New.FlowReplace & SERIAL_RTS_HANDSHAKE)
  32. flowControl |= RTS_FlowCtl;
  33. if (New.FlowReplace & SERIAL_AUTO_TRANSMIT)
  34. flowControl |= Tx_FlowCtl;
  35. if (New.FlowReplace & SERIAL_AUTO_RECEIVE)
  36. flowControl |= Rx_FlowCtl;
  37. MoxaFunc(ofs, FC_SetFlowCtl, flowControl);
  38. }
  39. if ((New.ControlHandShake & SERIAL_DTR_MASK) !=
  40. SERIAL_DTR_HANDSHAKE) {
  41. if ((New.ControlHandShake & SERIAL_DTR_MASK) ==
  42. SERIAL_DTR_CONTROL) {
  43. MoxaFunc(ofs, FC_DTRcontrol, 1); /* set DTR */
  44. MoxaFlagBit[Extension->PortNo] |= 1;
  45. } else {
  46. MoxaFunc(ofs, FC_DTRcontrol, 0); /* clear DTR */
  47. MoxaFlagBit[Extension->PortNo] &= 0xFE;
  48. }
  49. }
  50. if ((!Extension->DeviceIsOpened) ||
  51. ((Extension->HandFlow.FlowReplace & SERIAL_RTS_HANDSHAKE) !=
  52. (New.FlowReplace & SERIAL_RTS_HANDSHAKE))) {
  53. if (New.FlowReplace & SERIAL_RTS_HANDSHAKE) {
  54. MoxaFunc(ofs, FC_RTScontrol, 1); /* set RTS */
  55. MoxaFlagBit[Extension->PortNo] |= 2;
  56. }
  57. }
  58. if ((New.FlowReplace & SERIAL_RTS_MASK) !=
  59. SERIAL_RTS_HANDSHAKE) {
  60. if ((New.FlowReplace & SERIAL_RTS_MASK) ==
  61. SERIAL_RTS_CONTROL) {
  62. MoxaFunc(ofs, FC_RTScontrol, 1); /* set RTS */
  63. MoxaFlagBit[Extension->PortNo] |= 2;
  64. } else {
  65. MoxaFunc(ofs, FC_RTScontrol, 0); /* clear RTS */
  66. MoxaFlagBit[Extension->PortNo] &= 0xFD;
  67. }
  68. }
  69. MoxaFunc(ofs, FC_SetXoffLimit, (USHORT)New.XoffLimit);
  70. MoxaFunc(ofs, FC_SetFlowRepl, (USHORT)New.FlowReplace);
  71. Extension->HandFlow = New;
  72. return FALSE;
  73. }
  74.