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.

229 lines
5.3 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. smbus.h
  5. Abstract:
  6. SMBus Class Driver Header File
  7. Author:
  8. Ken Reneris
  9. Environment:
  10. Notes:
  11. Revision History:
  12. --*/
  13. //
  14. // SMB Request packet
  15. //
  16. #define SMB_MAX_DATA_SIZE 32
  17. typedef struct {
  18. UCHAR Status; // Completion status
  19. UCHAR Protocol;
  20. UCHAR Address;
  21. UCHAR Command;
  22. UCHAR BlockLength;
  23. UCHAR Data[SMB_MAX_DATA_SIZE];
  24. } SMB_REQUEST, *PSMB_REQUEST;
  25. //
  26. // Protocol values
  27. //
  28. #define SMB_WRITE_QUICK 0x00 // Issue quick command data bit = 0
  29. #define SMB_READ_QUICK 0x01 // Issue quick command data bit = 1
  30. #define SMB_SEND_BYTE 0x02
  31. #define SMB_RECEIVE_BYTE 0x03
  32. #define SMB_WRITE_BYTE 0x04
  33. #define SMB_READ_BYTE 0x05
  34. #define SMB_WRITE_WORD 0x06
  35. #define SMB_READ_WORD 0x07
  36. #define SMB_WRITE_BLOCK 0x08
  37. #define SMB_READ_BLOCK 0x09
  38. #define SMB_PROCESS_CALL 0x0A
  39. #define SMB_BLOCK_PROCESS_CALL 0x0B
  40. #define SMB_MAXIMUM_PROTOCOL 0x0B
  41. //
  42. // SMB Bus Status codes
  43. //
  44. #define SMB_STATUS_OK 0x00
  45. #define SMB_UNKNOWN_FAILURE 0x07
  46. #define SMB_ADDRESS_NOT_ACKNOWLEDGED 0x10
  47. #define SMB_DEVICE_ERROR 0x11
  48. #define SMB_COMMAND_ACCESS_DENIED 0x12
  49. #define SMB_UNKNOWN_ERROR 0x13
  50. #define SMB_DEVICE_ACCESS_DENIED 0x17
  51. #define SMB_TIMEOUT 0x18
  52. #define SMB_UNSUPPORTED_PROTOCOL 0x19
  53. #define SMB_BUS_BUSY 0x1A
  54. //
  55. // Alarm register/deregister requests
  56. //
  57. typedef
  58. VOID
  59. (*SMB_ALARM_NOTIFY) (
  60. PVOID Context,
  61. UCHAR Address,
  62. USHORT Data
  63. );
  64. // input buffer is SMB_REGISTER_ALARM. output buffer is PVOID handle for registration.
  65. // PVOID is passed in via DEREGISTER request to free registration
  66. typedef struct {
  67. UCHAR MinAddress; // Min address for notifications
  68. UCHAR MaxAddress; // Max address for notifications
  69. SMB_ALARM_NOTIFY NotifyFunction;
  70. PVOID NotifyContext;
  71. } SMB_REGISTER_ALARM, *PSMB_REGISTER_ALARM;
  72. //
  73. // Internal ioctls to SMB class driver
  74. //
  75. #define SMB_BUS_REQUEST CTL_CODE(FILE_DEVICE_UNKNOWN, 0, METHOD_NEITHER, FILE_ANY_ACCESS)
  76. #define SMB_REGISTER_ALARM_NOTIFY CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS)
  77. #define SMB_DEREGISTER_ALARM_NOTIFY CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS)
  78. //
  79. // Shared SMB Class / Miniport driver structure
  80. //
  81. typedef
  82. NTSTATUS
  83. (*SMB_RESET_DEVICE)(
  84. IN struct _SMB_CLASS *SmbClass,
  85. IN PVOID SmbMiniport
  86. );
  87. typedef
  88. VOID
  89. (*SMB_START_IO)(
  90. IN struct _SMB_CLASS *SmbClass,
  91. IN PVOID SmbMiniport
  92. );
  93. typedef
  94. NTSTATUS
  95. (*SMB_STOP_DEVICE)(
  96. IN struct _SMB_CLASS *SmbClass,
  97. IN PVOID SmbMiniport
  98. );
  99. typedef struct _SMB_CLASS {
  100. USHORT MajorVersion;
  101. USHORT MinorVersion;
  102. PVOID Miniport; // Miniport extension data
  103. PDEVICE_OBJECT DeviceObject; // Device object for this miniport
  104. PDEVICE_OBJECT PDO; // PDO for this miniport
  105. PDEVICE_OBJECT LowerDeviceObject;
  106. //
  107. // Current IO
  108. //
  109. PIRP CurrentIrp; // current request
  110. PSMB_REQUEST CurrentSmb; // pointer to SMB_REQUEST in the CurrentIrp
  111. //
  112. // Miniport functions
  113. //
  114. SMB_RESET_DEVICE ResetDevice; // Initialize/Reset, start device
  115. SMB_START_IO StartIo; // Perform IO
  116. SMB_STOP_DEVICE StopDevice; // Stop device
  117. } SMB_CLASS, *PSMB_CLASS;
  118. #define SMB_CLASS_MAJOR_VERSION 0x0001
  119. #define SMB_CLASS_MINOR_VERSION 0x0000
  120. //
  121. // Class driver initializtion functions
  122. //
  123. #if !defined(SMBCLASS)
  124. #define SMBCLASSAPI DECLSPEC_IMPORT
  125. #else
  126. #define SMBCLASSAPI
  127. #endif
  128. typedef
  129. NTSTATUS
  130. (*PSMB_INITIALIZE_MINIPORT) (
  131. IN PSMB_CLASS SmbClass,
  132. IN PVOID MiniportExtension,
  133. IN PVOID MiniportContext
  134. );
  135. NTSTATUS
  136. SMBCLASSAPI
  137. SmbClassInitializeDevice (
  138. IN ULONG MajorVersion,
  139. IN ULONG MinorVersion,
  140. IN PDRIVER_OBJECT DriverObject
  141. );
  142. NTSTATUS
  143. SMBCLASSAPI
  144. SmbClassCreateFdo (
  145. IN PDRIVER_OBJECT DriverObject,
  146. IN PDEVICE_OBJECT PDO,
  147. IN ULONG MiniportExtensionSize,
  148. IN PSMB_INITIALIZE_MINIPORT MiniportInitialize,
  149. IN PVOID MiniportContext,
  150. OUT PDEVICE_OBJECT *FDO
  151. );
  152. //
  153. // Class driver interface functions for use by the miniport
  154. //
  155. VOID
  156. SMBCLASSAPI
  157. SmbClassCompleteRequest (
  158. IN PSMB_CLASS SmbClass
  159. );
  160. VOID
  161. SMBCLASSAPI
  162. SmbClassAlarm (
  163. IN PSMB_CLASS SmbClass,
  164. IN UCHAR Address,
  165. IN USHORT Data
  166. );
  167. VOID
  168. SMBCLASSAPI
  169. SmbClassLockDevice (
  170. IN PSMB_CLASS SmbClass
  171. );
  172. VOID
  173. SMBCLASSAPI
  174. SmbClassUnlockDevice (
  175. IN PSMB_CLASS SmbClass
  176. );