home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / ddk / smbus.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  4.5 KB  |  195 lines

  1. /*
  2.  * smbus.h
  3.  *
  4.  * System Management Bus driver interface
  5.  *
  6.  * This file is part of the w32api package.
  7.  *
  8.  * Contributors:
  9.  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
  10.  *
  11.  * THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  * This source code is offered for use in the public domain. You may
  14.  * use, modify or distribute it freely.
  15.  *
  16.  * This code is distributed in the hope that it will be useful but
  17.  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  * DISCLAIMED. This includes but is not limited to warranties of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  */
  22.  
  23. #ifndef __SMBUS_H
  24. #define __SMBUS_H
  25.  
  26. #if __GNUC__ >=3
  27. #pragma GCC system_header
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #pragma pack(push,4)
  35.  
  36. #if !defined(SMBCLASS)
  37.   #define SMBCLASSAPI DECLSPEC_IMPORT
  38. #else
  39.   #define SMBCLASSAPI DECLSPEC_EXPORT
  40. #endif
  41.  
  42. #define SMB_BUS_REQUEST \
  43.   CTL_CODE(FILE_DEVICE_UNKNOWN, 0, METHOD_NEITHER, FILE_ANY_ACCESS)
  44.  
  45. #define SMB_DEREGISTER_ALARM_NOTIFY \
  46.   CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS)
  47.  
  48. #define SMB_REGISTER_ALARM_NOTIFY \
  49.   CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS)
  50.  
  51.  
  52. struct _SMB_CLASS;
  53.  
  54. #define SMB_MAX_DATA_SIZE                 32
  55.  
  56. /* SMB_REQUEST.Status constants */
  57. #define SMB_STATUS_OK                     0x00
  58. #define SMB_UNKNOWN_FAILURE               0x07
  59. #define SMB_ADDRESS_NOT_ACKNOWLEDGED      0x10
  60. #define SMB_DEVICE_ERROR                  0x11
  61. #define SMB_COMMAND_ACCESS_DENIED         0x12
  62. #define SMB_UNKNOWN_ERROR                 0x13
  63. #define SMB_DEVICE_ACCESS_DENIED          0x17
  64. #define SMB_TIMEOUT                       0x18
  65. #define SMB_UNSUPPORTED_PROTOCOL          0x19
  66. #define SMB_BUS_BUSY                      0x1A
  67.  
  68. /* SMB_REQUEST.Protocol constants */
  69. #define SMB_WRITE_QUICK                   0x00
  70. #define SMB_READ_QUICK                    0x01
  71. #define SMB_SEND_BYTE                     0x02
  72. #define SMB_RECEIVE_BYTE                  0x03
  73. #define SMB_WRITE_BYTE                    0x04
  74. #define SMB_READ_BYTE                     0x05
  75. #define SMB_WRITE_WORD                    0x06
  76. #define SMB_READ_WORD                     0x07
  77. #define SMB_WRITE_BLOCK                   0x08
  78. #define SMB_READ_BLOCK                    0x09
  79. #define SMB_PROCESS_CALL                  0x0A
  80. #define SMB_MAXIMUM_PROTOCOL              0x0A
  81.  
  82. typedef struct _SMB_REQUEST {
  83.   UCHAR  Status;
  84.   UCHAR  Protocol;
  85.   UCHAR  Address;
  86.   UCHAR  Command;
  87.   UCHAR  BlockLength;
  88.   UCHAR  Data[SMB_MAX_DATA_SIZE];
  89. } SMB_REQUEST, *PSMB_REQUEST;
  90.  
  91. typedef VOID STDCALL
  92. (*SMB_ALARM_NOTIFY)(
  93.   PVOID  Context,
  94.   UCHAR  Address,
  95.   USHORT  Data);
  96.  
  97. typedef struct _SMB_REGISTER_ALARM {
  98.   UCHAR  MinAddress;
  99.   UCHAR  MaxAddress;
  100.   SMB_ALARM_NOTIFY  NotifyFunction;
  101.   PVOID  NotifyContext;
  102. } SMB_REGISTER_ALARM, *PSMB_REGISTER_ALARM;
  103.  
  104. /* SMB_CLASS.XxxVersion constants */
  105. #define SMB_CLASS_MAJOR_VERSION           0x0001
  106. #define SMB_CLASS_MINOR_VERSION           0x0000
  107.  
  108. typedef NTSTATUS DDKAPI
  109. (*SMB_RESET_DEVICE)(
  110.   IN struct _SMB_CLASS  *SmbClass,
  111.   IN PVOID  SmbMiniport);
  112.  
  113. typedef VOID DDKAPI
  114. (*SMB_START_IO)(
  115.   IN struct _SMB_CLASS  *SmbClass,
  116.   IN PVOID  SmbMiniport);
  117.  
  118. typedef NTSTATUS DDKAPI
  119. (*SMB_STOP_DEVICE)(
  120.   IN struct _SMB_CLASS  *SmbClass,
  121.   IN PVOID  SmbMiniport);
  122.  
  123. typedef struct _SMB_CLASS {
  124.   USHORT  MajorVersion;
  125.   USHORT  MinorVersion;
  126.   PVOID  Miniport;
  127.   PDEVICE_OBJECT  DeviceObject;
  128.   PDEVICE_OBJECT  PDO;
  129.   PDEVICE_OBJECT  LowerDeviceObject;
  130.   PIRP  CurrentIrp;
  131.   PSMB_REQUEST  CurrentSmb;
  132.   SMB_RESET_DEVICE  ResetDevice;
  133.   SMB_START_IO  StartIo;
  134.   SMB_STOP_DEVICE  StopDevice;
  135. } SMB_CLASS, *PSMB_CLASS;
  136.  
  137. SMBCLASSAPI
  138. VOID
  139. DDKAPI
  140. SmbClassAlarm(
  141.   IN PSMB_CLASS  SmbClass,
  142.   IN UCHAR  Address,
  143.   IN USHORT  Data);
  144.  
  145. SMBCLASSAPI
  146. VOID
  147. DDKAPI
  148. SmbClassCompleteRequest(
  149.   IN PSMB_CLASS  SmbClass);
  150.  
  151. typedef NTSTATUS DDKAPI
  152. (*PSMB_INITIALIZE_MINIPORT)(
  153.   IN PSMB_CLASS  SmbClass,
  154.   IN PVOID  MiniportExtension,
  155.   IN PVOID  MiniportContext);
  156.  
  157. SMBCLASSAPI
  158. NTSTATUS
  159. DDKAPI
  160. SmbClassCreateFdo(
  161.   IN PDRIVER_OBJECT  DriverObject,
  162.   IN PDEVICE_OBJECT  PDO,
  163.   IN ULONG  MiniportExtensionSize,
  164.   IN PSMB_INITIALIZE_MINIPORT  MiniportInitialize,
  165.   IN PVOID  MiniportContext,
  166.   OUT PDEVICE_OBJECT  *FDO);
  167.  
  168. SMBCLASSAPI
  169. NTSTATUS
  170. DDKAPI
  171. SmbClassInitializeDevice(
  172.   IN ULONG  MajorVersion,
  173.   IN ULONG  MinorVersion,
  174.   IN PDRIVER_OBJECT  DriverObject);
  175.  
  176. SMBCLASSAPI
  177. VOID
  178. DDKAPI
  179. SmbClassLockDevice(
  180.   IN PSMB_CLASS  SmbClass);
  181.  
  182. SMBCLASSAPI
  183. VOID
  184. DDKAPI
  185. SmbClassUnlockDevice(
  186.   IN PSMB_CLASS  SmbClass);
  187.  
  188. #pragma pack(pop)
  189.  
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193.  
  194. #endif /* __SMBUS_H */
  195.