|
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 #if !defined(SMBCLASS) |
|
35 #define SMBCLASSAPI DECLSPEC_IMPORT |
|
36 #else |
|
37 #define SMBCLASSAPI DECLSPEC_EXPORT |
|
38 #endif |
|
39 |
|
40 #define SMB_BUS_REQUEST \ |
|
41 CTL_CODE(FILE_DEVICE_UNKNOWN, 0, METHOD_NEITHER, FILE_ANY_ACCESS) |
|
42 |
|
43 #define SMB_DEREGISTER_ALARM_NOTIFY \ |
|
44 CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS) |
|
45 |
|
46 #define SMB_REGISTER_ALARM_NOTIFY \ |
|
47 CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS) |
|
48 |
|
49 |
|
50 struct _SMB_CLASS; |
|
51 |
|
52 #define SMB_MAX_DATA_SIZE 32 |
|
53 |
|
54 /* SMB_REQUEST.Status constants */ |
|
55 #define SMB_STATUS_OK 0x00 |
|
56 #define SMB_UNKNOWN_FAILURE 0x07 |
|
57 #define SMB_ADDRESS_NOT_ACKNOWLEDGED 0x10 |
|
58 #define SMB_DEVICE_ERROR 0x11 |
|
59 #define SMB_COMMAND_ACCESS_DENIED 0x12 |
|
60 #define SMB_UNKNOWN_ERROR 0x13 |
|
61 #define SMB_DEVICE_ACCESS_DENIED 0x17 |
|
62 #define SMB_TIMEOUT 0x18 |
|
63 #define SMB_UNSUPPORTED_PROTOCOL 0x19 |
|
64 #define SMB_BUS_BUSY 0x1A |
|
65 |
|
66 /* SMB_REQUEST.Protocol constants */ |
|
67 #define SMB_WRITE_QUICK 0x00 |
|
68 #define SMB_READ_QUICK 0x01 |
|
69 #define SMB_SEND_BYTE 0x02 |
|
70 #define SMB_RECEIVE_BYTE 0x03 |
|
71 #define SMB_WRITE_BYTE 0x04 |
|
72 #define SMB_READ_BYTE 0x05 |
|
73 #define SMB_WRITE_WORD 0x06 |
|
74 #define SMB_READ_WORD 0x07 |
|
75 #define SMB_WRITE_BLOCK 0x08 |
|
76 #define SMB_READ_BLOCK 0x09 |
|
77 #define SMB_PROCESS_CALL 0x0A |
|
78 #define SMB_MAXIMUM_PROTOCOL 0x0A |
|
79 |
|
80 typedef struct _SMB_REQUEST { |
|
81 UCHAR Status; |
|
82 UCHAR Protocol; |
|
83 UCHAR Address; |
|
84 UCHAR Command; |
|
85 UCHAR BlockLength; |
|
86 UCHAR Data[SMB_MAX_DATA_SIZE]; |
|
87 } SMB_REQUEST, *PSMB_REQUEST; |
|
88 |
|
89 typedef VOID STDCALL |
|
90 (*SMB_ALARM_NOTIFY)( |
|
91 PVOID Context, |
|
92 UCHAR Address, |
|
93 USHORT Data); |
|
94 |
|
95 typedef struct _SMB_REGISTER_ALARM { |
|
96 UCHAR MinAddress; |
|
97 UCHAR MaxAddress; |
|
98 SMB_ALARM_NOTIFY NotifyFunction; |
|
99 PVOID NotifyContext; |
|
100 } SMB_REGISTER_ALARM, *PSMB_REGISTER_ALARM; |
|
101 |
|
102 /* SMB_CLASS.XxxVersion constants */ |
|
103 #define SMB_CLASS_MAJOR_VERSION 0x0001 |
|
104 #define SMB_CLASS_MINOR_VERSION 0x0000 |
|
105 |
|
106 typedef NTSTATUS DDKAPI |
|
107 (*SMB_RESET_DEVICE)( |
|
108 /*IN*/ struct _SMB_CLASS *SmbClass, |
|
109 /*IN*/ PVOID SmbMiniport); |
|
110 |
|
111 typedef VOID DDKAPI |
|
112 (*SMB_START_IO)( |
|
113 /*IN*/ struct _SMB_CLASS *SmbClass, |
|
114 /*IN*/ PVOID SmbMiniport); |
|
115 |
|
116 typedef NTSTATUS DDKAPI |
|
117 (*SMB_STOP_DEVICE)( |
|
118 /*IN*/ struct _SMB_CLASS *SmbClass, |
|
119 /*IN*/ PVOID SmbMiniport); |
|
120 |
|
121 typedef struct _SMB_CLASS { |
|
122 USHORT MajorVersion; |
|
123 USHORT MinorVersion; |
|
124 PVOID Miniport; |
|
125 PDEVICE_OBJECT DeviceObject; |
|
126 PDEVICE_OBJECT PDO; |
|
127 PDEVICE_OBJECT LowerDeviceObject; |
|
128 PIRP CurrentIrp; |
|
129 PSMB_REQUEST CurrentSmb; |
|
130 SMB_RESET_DEVICE ResetDevice; |
|
131 SMB_START_IO StartIo; |
|
132 SMB_STOP_DEVICE StopDevice; |
|
133 } SMB_CLASS, *PSMB_CLASS; |
|
134 |
|
135 SMBCLASSAPI |
|
136 VOID |
|
137 DDKAPI |
|
138 SmbClassAlarm( |
|
139 /*IN*/ PSMB_CLASS SmbClass, |
|
140 /*IN*/ UCHAR Address, |
|
141 /*IN*/ USHORT Data); |
|
142 |
|
143 SMBCLASSAPI |
|
144 VOID |
|
145 DDKAPI |
|
146 SmbClassCompleteRequest( |
|
147 /*IN*/ PSMB_CLASS SmbClass); |
|
148 |
|
149 typedef NTSTATUS DDKAPI |
|
150 (*PSMB_INITIALIZE_MINIPORT)( |
|
151 /*IN*/ PSMB_CLASS SmbClass, |
|
152 /*IN*/ PVOID MiniportExtension, |
|
153 /*IN*/ PVOID MiniportContext); |
|
154 |
|
155 SMBCLASSAPI |
|
156 NTSTATUS |
|
157 DDKAPI |
|
158 SmbClassCreateFdo( |
|
159 /*IN*/ PDRIVER_OBJECT DriverObject, |
|
160 /*IN*/ PDEVICE_OBJECT PDO, |
|
161 /*IN*/ ULONG MiniportExtensionSize, |
|
162 /*IN*/ PSMB_INITIALIZE_MINIPORT MiniportInitialize, |
|
163 /*IN*/ PVOID MiniportContext, |
|
164 /*OUT*/ PDEVICE_OBJECT *FDO); |
|
165 |
|
166 SMBCLASSAPI |
|
167 NTSTATUS |
|
168 DDKAPI |
|
169 SmbClassInitializeDevice( |
|
170 /*IN*/ ULONG MajorVersion, |
|
171 /*IN*/ ULONG MinorVersion, |
|
172 /*IN*/ PDRIVER_OBJECT DriverObject); |
|
173 |
|
174 SMBCLASSAPI |
|
175 VOID |
|
176 DDKAPI |
|
177 SmbClassLockDevice( |
|
178 /*IN*/ PSMB_CLASS SmbClass); |
|
179 |
|
180 SMBCLASSAPI |
|
181 VOID |
|
182 DDKAPI |
|
183 SmbClassUnlockDevice( |
|
184 /*IN*/ PSMB_CLASS SmbClass); |
|
185 |
|
186 #ifdef __cplusplus |
|
187 } |
|
188 #endif |
|
189 |
|
190 #endif /* __SMBUS_H */ |