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.

175 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1997-1998 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. hook.c
  5. Abstract:
  6. Implements hook functions used by upper filters to directly control a PS/2
  7. device.
  8. Environment:
  9. Kernel mode only.
  10. Notes:
  11. Revision History:
  12. --*/
  13. #include "i8042prt.h"
  14. //
  15. // Mouse hook functions
  16. //
  17. VOID
  18. I8xMouseIsrWritePort(
  19. IN PDEVICE_OBJECT DeviceObject,
  20. IN UCHAR Value
  21. )
  22. /*++
  23. Routine Description:
  24. This routine runs at HIGH IRQL to write values to the mouse device
  25. Arguments:
  26. DeviceObject - The i8042prt FDO representing the mouse
  27. Value - Value to write to the mouse
  28. Return Value:
  29. None.
  30. --*/
  31. {
  32. #if DBG
  33. ASSERT(! ((PCOMMON_DATA) DeviceObject->DeviceExtension)->IsKeyboard);
  34. #else
  35. UNREFERENCED_PARAMETER(DeviceObject);
  36. #endif
  37. I8X_WRITE_CMD_TO_MOUSE();
  38. I8X_MOUSE_COMMAND( Value );
  39. }
  40. //
  41. // Keyboard hook functions
  42. //
  43. NTSTATUS
  44. I8xKeyboardSynchReadPort (
  45. IN PDEVICE_OBJECT DeviceObject,
  46. IN PUCHAR Value,
  47. IN BOOLEAN Dummy
  48. )
  49. /*++
  50. Routine Description:
  51. This routine runs at PASSIVE IRQL to synchronousely read a value from the
  52. keyboard device during the initialization of the device
  53. Arguments:
  54. DeviceObject - The i8042prt FDO representing the keyboard
  55. Value - Pointer in which to place the results of the read
  56. Return Value:
  57. status of the operation, STATUS_SUCCESS if successful
  58. --*/
  59. {
  60. #if DBG
  61. ASSERT(((PCOMMON_DATA) DeviceObject->DeviceExtension)->IsKeyboard);
  62. #else
  63. UNREFERENCED_PARAMETER(DeviceObject);
  64. #endif
  65. UNREFERENCED_PARAMETER(Dummy);
  66. return I8xGetBytePolled((CCHAR) KeyboardDeviceType,
  67. Value
  68. );
  69. }
  70. NTSTATUS
  71. I8xKeyboardSynchWritePort (
  72. IN PDEVICE_OBJECT DeviceObject,
  73. IN UCHAR Value,
  74. IN BOOLEAN WaitForACK
  75. )
  76. /*++
  77. Routine Description:
  78. This routine runs at PASSIVE IRQL to synchronousely write values to the
  79. keyboard device during the initialization of the device
  80. Arguments:
  81. DeviceObject - The i8042prt FDO representing the keyboard
  82. Value - Value to write to the keyboard
  83. WaitForACK - Whether we should wait the device to ACK the Value written
  84. Return Value:
  85. status of the operation, STATUS_SUCCESS if successful
  86. --*/
  87. {
  88. #if DBG
  89. ASSERT(((PCOMMON_DATA) DeviceObject->DeviceExtension)->IsKeyboard);
  90. #else
  91. UNREFERENCED_PARAMETER(DeviceObject);
  92. #endif
  93. return I8xPutBytePolled(
  94. DataPort,
  95. WaitForACK,
  96. (CCHAR) KeyboardDeviceType,
  97. Value
  98. );
  99. }
  100. VOID
  101. I8xKeyboardIsrWritePort(
  102. IN PDEVICE_OBJECT DeviceObject,
  103. IN UCHAR Value
  104. )
  105. /*++
  106. Routine Description:
  107. This routine runs at HIGH IRQL to write values to the keyboard device
  108. Arguments:
  109. DeviceObject - The i8042prt FDO representing the keyboard
  110. Value - Value to write to the keyboard
  111. Return Value:
  112. None.
  113. --*/
  114. {
  115. #if DBG
  116. ASSERT(((PCOMMON_DATA) DeviceObject->DeviceExtension)->IsKeyboard);
  117. #else
  118. UNREFERENCED_PARAMETER(DeviceObject);
  119. #endif
  120. I8xPutByteAsynchronous((CCHAR) DataPort,
  121. Value
  122. );
  123. }