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.

157 lines
3.6 KiB

  1. #include <wdm.h>
  2. #include <smbus.h>
  3. #include <ec.h>
  4. #include <devioctl.h>
  5. #include <acpiioct.h>
  6. #define DEBUG 1
  7. //
  8. // Debuging
  9. //
  10. extern ULONG SMBHCDebug;
  11. #if DEBUG
  12. #define SmbPrint(l,m) if(l & SMBHCDebug) DbgPrint m
  13. #else
  14. #define SmbPrint(l,m)
  15. #endif
  16. //
  17. // Control methods used by EC
  18. //
  19. #define CM_EC_METHOD (ULONG) (0,'CE_')
  20. #define SMB_LOW 0x00000010
  21. #define SMB_STATE 0x00000020
  22. #define SMB_NOTE 0x00000001
  23. #define SMB_WARN 0x00000002
  24. #define SMB_ERROR 0x00000004
  25. //
  26. // SMB Host Controller interface definitions
  27. //
  28. typedef struct {
  29. UCHAR Protocol;
  30. UCHAR Status;
  31. UCHAR Address;
  32. UCHAR Command;
  33. UCHAR Data[SMB_MAX_DATA_SIZE];
  34. UCHAR BlockLength;
  35. UCHAR AlarmAddress;
  36. UCHAR AlarmData[2];
  37. } SMB_HC, *PSMB_HC;
  38. //
  39. // Protocol values
  40. //
  41. #define SMB_HC_NOT_BUSY 0x00
  42. #define SMB_HC_WRITE_QUICK 0x02 // quick cmd with data bit = 0
  43. #define SMB_HC_READ_QUICK 0x03 // quick cmd with data bit = 1
  44. #define SMB_HC_SEND_BYTE 0x04
  45. #define SMB_HC_RECEIVE_BYTE 0x05
  46. #define SMB_HC_WRITE_BYTE 0x06
  47. #define SMB_HC_READ_BYTE 0x07
  48. #define SMB_HC_WRITE_WORD 0x08
  49. #define SMB_HC_READ_WORD 0x09
  50. #define SMB_HC_WRITE_BLOCK 0x0A
  51. #define SMB_HC_READ_BLOCK 0x0B
  52. #define SMB_HC_PROCESS_CALL 0x0C
  53. //
  54. // Status field masks
  55. //
  56. #define SMB_DONE 0x80
  57. #define SMB_ALRM 0x40
  58. #define SMB_STATUS_MASK 0x1F
  59. //
  60. // SMB Host Controller Device object extenstion
  61. //
  62. typedef struct {
  63. PDEVICE_OBJECT DeviceObject;
  64. PDEVICE_OBJECT NextFdo;
  65. PDEVICE_OBJECT Pdo; //Pdo corresponding to this fdo
  66. PDEVICE_OBJECT LowerDeviceObject;
  67. PSMB_CLASS Class; // Shared class data
  68. //
  69. // Configuration information
  70. //
  71. UCHAR EcQuery; // EC Query value
  72. UCHAR EcBase; // EC Base value
  73. //
  74. // Miniport data
  75. //
  76. PIRP StatusIrp; // IRP in progress to read status without user irp
  77. UCHAR IoState; // Io state
  78. UCHAR IoWaitingState; // Io state once register read/write completed
  79. UCHAR IoStatusState; // Io state to revert to if idle status
  80. UCHAR IoReadData; // Size of data buffer read after complete status
  81. SMB_HC HcState; // Current host controller registers
  82. } SMB_DATA, *PSMB_DATA;
  83. //
  84. // IoState, IoWaitingState, IoStatusState, StatusState,
  85. //
  86. #define SMB_IO_INVALID 0
  87. #define SMB_IO_IDLE 1
  88. #define SMB_IO_CHECK_IDLE 2
  89. #define SMB_IO_WAITING_FOR_HC_REG_IO 3
  90. #define SMB_IO_WAITING_FOR_STATUS 4
  91. #define SMB_IO_START_TRANSFER 5
  92. #define SMB_IO_READ_STATUS 6
  93. #define SMB_IO_CHECK_STATUS 7
  94. #define SMB_IO_COMPLETE_REQUEST 8
  95. #define SMB_IO_COMPLETE_REG_IO 9
  96. #define SMB_IO_CHECK_ALARM 10
  97. #define SMB_IO_START_PROTOCOL 11
  98. //
  99. // Driver supports the following class driver version
  100. //
  101. #define SMB_HC_MAJOR_VERSION 0x0001
  102. #define SMB_HC_MINOR_VERSION 0x0000
  103. //
  104. // Prototypes
  105. //
  106. VOID
  107. SmbHcStartIo (
  108. IN PSMB_CLASS SmbClass,
  109. IN PVOID SmbMiniport
  110. );
  111. VOID
  112. SmbHcQueryEvent (
  113. IN ULONG QueryVector,
  114. IN PSMB_DATA SmbData
  115. );
  116. VOID
  117. SmbHcServiceIoLoop (
  118. IN PSMB_CLASS SmbClass,
  119. IN PSMB_DATA SmbData
  120. );