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.

177 lines
4.6 KiB

  1. #include "precomp.h"
  2. // Paging
  3. #pragma alloc_text (PAGE, XXX_CardPowerDown)
  4. #pragma alloc_text (PAGE, XXX_CardPowerUp)
  5. #pragma alloc_text (PAGE, XXX_PortQueryPowerDown)
  6. #pragma alloc_text (PAGE, XXX_PortPowerDown)
  7. #pragma alloc_text (PAGE, XXX_PortPowerUp)
  8. // End paging
  9. ////////////////////////////////////////////////////////////////////////
  10. // XXX_CardPowerDown - Restores the state of the hardware & starts card.
  11. ////////////////////////////////////////////////////////////////////////
  12. NTSTATUS
  13. XXX_CardPowerDown(IN PCARD_DEVICE_EXTENSION pCard)
  14. {
  15. NTSTATUS status = STATUS_SUCCESS;
  16. // Stop Card from interrupting
  17. return status;
  18. }
  19. //////////////////////////////////////////////////////////////////////
  20. // XXX_CardPowerUp - Saves the state of the hardware & stops card.
  21. //////////////////////////////////////////////////////////////////////
  22. NTSTATUS
  23. XXX_CardPowerUp(IN PCARD_DEVICE_EXTENSION pCard)
  24. {
  25. NTSTATUS status = STATUS_SUCCESS;
  26. // Reset card and allow it to interrupt again.
  27. return status;
  28. }
  29. ////////////////////////////////////////////////////////////////////////
  30. // XXX_PortPowerDown - Decides whether it is safe to power down a port.
  31. ////////////////////////////////////////////////////////////////////////
  32. NTSTATUS
  33. XXX_PortQueryPowerDown(IN PPORT_DEVICE_EXTENSION pPort)
  34. {
  35. NTSTATUS status = STATUS_SUCCESS;
  36. return status;
  37. }
  38. ////////////////////////////////////////////////////////////////////////
  39. // XXX_PortPowerDown - Restores the state of the hardware & starts port.
  40. ////////////////////////////////////////////////////////////////////////
  41. NTSTATUS
  42. XXX_PortPowerDown(IN PPORT_DEVICE_EXTENSION pPort)
  43. {
  44. NTSTATUS status = STATUS_SUCCESS;
  45. DWORD ModemSignals = 0;
  46. PCARD_DEVICE_EXTENSION pCard = pPort->pParentCardExt;
  47. if(pPort->DeviceIsOpen) // Is the port open?
  48. {
  49. // Stop port from interrupting
  50. pPort->UartConfig.InterruptEnable = 0;
  51. pPort->pUartLib->UL_SetConfig_XXXX(pPort->pUart, &pPort->UartConfig, UC_INT_ENABLE_MASK);
  52. // Get the current modem signals...
  53. pPort->pUartLib->UL_ModemControl_XXXX(pPort->pUart, &ModemSignals, UL_MC_OP_STATUS);
  54. // Save the current modem signals...
  55. pPort->SavedModemControl = ModemSignals;
  56. }
  57. #ifdef MANAGE_HARDWARE_POWER_STATES
  58. // Power down RS232 line drivers
  59. switch(pPort->PortNumber)
  60. {
  61. case 0:
  62. pCard->LocalConfigRegisters[0x4 + 0x1] &= 0xFC;
  63. break;
  64. case 1:
  65. pCard->LocalConfigRegisters[0x4 + 0x1] &= 0xF3;
  66. break;
  67. case 2:
  68. pCard->LocalConfigRegisters[0x4 + 0x1] &= 0xCF;
  69. break;
  70. case 3:
  71. pCard->LocalConfigRegisters[0x4 + 0x1] &= 0x3F;
  72. break;
  73. default:
  74. break;
  75. }
  76. // Power down UART.
  77. pPort->UartConfig.SpecialMode = pPort->UartConfig.SpecialMode |= UC_SM_LOW_POWER_MODE;
  78. pPort->pUartLib->UL_SetConfig_XXXX(pPort->pUart, &pPort->UartConfig, UC_SPECIAL_MODE_MASK);
  79. #endif
  80. return status;
  81. }
  82. //////////////////////////////////////////////////////////////////////
  83. // XXX_PortPowerUp - Saves the state of the hardware & stops port.
  84. //////////////////////////////////////////////////////////////////////
  85. NTSTATUS
  86. XXX_PortPowerUp(IN PPORT_DEVICE_EXTENSION pPort)
  87. {
  88. NTSTATUS status = STATUS_SUCCESS;
  89. PCARD_DEVICE_EXTENSION pCard = pPort->pParentCardExt;
  90. #ifdef MANAGE_HARDWARE_POWER_STATES
  91. // Wake up the UART
  92. pPort->UartConfig.SpecialMode = pPort->UartConfig.SpecialMode &= ~UC_SM_LOW_POWER_MODE;
  93. pPort->pUartLib->UL_SetConfig_XXXX(pPort->pUart, &pPort->UartConfig, UC_SPECIAL_MODE_MASK);
  94. // Wake up the RS232 line drivers.
  95. switch(pPort->PortNumber)
  96. {
  97. case 0:
  98. pCard->LocalConfigRegisters[0x4 + 0x1] |= 0x3;
  99. break;
  100. case 1:
  101. pCard->LocalConfigRegisters[0x4 + 0x1] |= 0xC;
  102. break;
  103. case 2:
  104. pCard->LocalConfigRegisters[0x4 + 0x1] |= 0x30;
  105. break;
  106. case 3:
  107. pCard->LocalConfigRegisters[0x4 + 0x1] |= 0xC0;
  108. break;
  109. default:
  110. break;
  111. }
  112. #endif
  113. SerialReset(pPort);
  114. ApplyInitialPortSettings(pPort);
  115. if(pPort->DeviceIsOpen) // Was port open before?
  116. {
  117. if(pPort->SavedModemControl & UL_MC_DTR) // DTR active?
  118. SerialSetDTR(pPort); // Yes
  119. else
  120. SerialClrDTR(pPort); // No
  121. if(pPort->SavedModemControl & UL_MC_RTS) // RTS active?
  122. SerialSetRTS(pPort); // Yes
  123. else
  124. SerialClrRTS(pPort); // No
  125. pPort->pUartLib->UL_SetConfig_XXXX(pPort->pUart, &pPort->UartConfig, UC_FC_THRESHOLD_SETTING_MASK);
  126. // Re-enable interrupts
  127. pPort->UartConfig.InterruptEnable = UC_IE_RX_INT | UC_IE_TX_INT | UC_IE_RX_STAT_INT | UC_IE_MODEM_STAT_INT;
  128. pPort->pUartLib->UL_SetConfig_XXXX(pPort->pUart, &pPort->UartConfig, UC_INT_ENABLE_MASK);
  129. }
  130. else
  131. {
  132. SerialClrDTR(pPort);
  133. SerialClrRTS(pPort);
  134. }
  135. return status;
  136. }