Windows NT 4.0 source code leak
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.

113 lines
2.5 KiB

4 years ago
  1. /*
  2. * PARALLAX.C
  3. *
  4. *
  5. *
  6. */
  7. #ifndef IRMINILIB
  8. #include "dongle.h"
  9. /*
  10. * The programming interface to a UART (COM serial port)
  11. * consists of eight consecutive registers.
  12. * These are the port offsets from the UART's base I/O address.
  13. */
  14. typedef enum comPortRegOffsets {
  15. XFER_REG_OFFSET = 0,
  16. INT_ENABLE_REG_OFFSET = 1,
  17. INT_ID_AND_FIFO_CNTRL_REG_OFFSET = 2,
  18. LINE_CONTROL_REG_OFFSET = 3,
  19. MODEM_CONTROL_REG_OFFSET = 4,
  20. LINE_STAT_REG_OFFSET = 5,
  21. MODEM_STAT_REG_OFFSET = 6,
  22. SCRATCH_REG_OFFSET = 7
  23. } comPortRegOffset;
  24. #define PARALLAX_IRDA_SPEEDS ( \
  25. NDIS_IRDA_SPEED_2400 | \
  26. NDIS_IRDA_SPEED_9600 | \
  27. NDIS_IRDA_SPEED_19200 | \
  28. NDIS_IRDA_SPEED_38400 | \
  29. NDIS_IRDA_SPEED_57600 | \
  30. NDIS_IRDA_SPEED_115200 \
  31. )
  32. BOOLEAN PARALLAX_Init(UINT comBase, dongleCapabilities *caps, UINT *context)
  33. {
  34. UCHAR modemCntrlVal;
  35. IRMINI_RawReadPort(comBase+MODEM_CONTROL_REG_OFFSET, &modemCntrlVal);
  36. modemCntrlVal |= 3;
  37. IRMINI_RawWritePort(comBase+MODEM_CONTROL_REG_OFFSET, modemCntrlVal);
  38. IRMINI_StallExecution(1000);
  39. caps->supportedSpeedsMask = PARALLAX_IRDA_SPEEDS;
  40. caps->turnAroundTime_usec = 5000;
  41. caps->extraBOFsRequired = 0;
  42. *context = 0;
  43. return TRUE;
  44. }
  45. VOID PARALLAX_Deinit(UINT comBase, UINT context)
  46. {
  47. }
  48. BOOLEAN PARALLAX_SetSpeed(UINT comBase, UINT bitsPerSec, UINT context)
  49. {
  50. UCHAR modemCntrlVal;
  51. UINT numToggles;
  52. IRMINI_RawReadPort(comBase+MODEM_CONTROL_REG_OFFSET, &modemCntrlVal);
  53. /*
  54. * First set the speed to 115200 baud.
  55. */
  56. modemCntrlVal &= ~2;
  57. IRMINI_RawWritePort(comBase+MODEM_CONTROL_REG_OFFSET, modemCntrlVal);
  58. IRMINI_StallExecution(1000);
  59. modemCntrlVal |= 2;
  60. IRMINI_RawWritePort(comBase+MODEM_CONTROL_REG_OFFSET, modemCntrlVal);
  61. IRMINI_StallExecution(1000);
  62. /*
  63. * Now, "count down" from 115.2 Kbaud.
  64. */
  65. switch (bitsPerSec){
  66. case 2400: numToggles = 6; break;
  67. case 4800: numToggles = 5; break;
  68. case 9600: numToggles = 4; break;
  69. case 19200: numToggles = 3; break;
  70. case 38400: numToggles = 2; break;
  71. case 57600: numToggles = 1; break;
  72. case 115200: numToggles = 0; break;
  73. default:
  74. /*
  75. * Illegal speed
  76. */
  77. return FALSE;
  78. }
  79. while (numToggles-- > 0){
  80. modemCntrlVal &= ~1;
  81. IRMINI_RawWritePort(comBase+MODEM_CONTROL_REG_OFFSET, modemCntrlVal);
  82. IRMINI_StallExecution(1000);
  83. modemCntrlVal |= 1;
  84. IRMINI_RawWritePort(comBase+MODEM_CONTROL_REG_OFFSET, modemCntrlVal);
  85. IRMINI_StallExecution(1000);
  86. }
  87. return TRUE;
  88. }
  89. #endif