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