Naveen Neel / shedskin
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers smbus.h Source File

smbus.h

00001 /*
00002  * smbus.h
00003  *
00004  * System Management Bus driver interface
00005  *
00006  * This file is part of the w32api package.
00007  *
00008  * Contributors:
00009  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
00010  *
00011  * THIS SOFTWARE IS NOT COPYRIGHTED
00012  *
00013  * This source code is offered for use in the public domain. You may
00014  * use, modify or distribute it freely.
00015  *
00016  * This code is distributed in the hope that it will be useful but
00017  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00018  * DISCLAIMED. This includes but is not limited to warranties of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00020  *
00021  */
00022 
00023 #ifndef __SMBUS_H
00024 #define __SMBUS_H
00025 
00026 #if __GNUC__ >=3
00027 #pragma GCC system_header
00028 #endif
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #if !defined(SMBCLASS)
00035   #define SMBCLASSAPI DECLSPEC_IMPORT
00036 #else
00037   #define SMBCLASSAPI DECLSPEC_EXPORT
00038 #endif
00039 
00040 #define SMB_BUS_REQUEST \
00041   CTL_CODE(FILE_DEVICE_UNKNOWN, 0, METHOD_NEITHER, FILE_ANY_ACCESS)
00042 
00043 #define SMB_DEREGISTER_ALARM_NOTIFY \
00044   CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_NEITHER, FILE_ANY_ACCESS)
00045 
00046 #define SMB_REGISTER_ALARM_NOTIFY \
00047   CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_NEITHER, FILE_ANY_ACCESS)
00048 
00049 
00050 struct _SMB_CLASS;
00051 
00052 #define SMB_MAX_DATA_SIZE                 32
00053 
00054 /* SMB_REQUEST.Status constants */
00055 #define SMB_STATUS_OK                     0x00
00056 #define SMB_UNKNOWN_FAILURE               0x07
00057 #define SMB_ADDRESS_NOT_ACKNOWLEDGED      0x10
00058 #define SMB_DEVICE_ERROR                  0x11
00059 #define SMB_COMMAND_ACCESS_DENIED         0x12
00060 #define SMB_UNKNOWN_ERROR                 0x13
00061 #define SMB_DEVICE_ACCESS_DENIED          0x17
00062 #define SMB_TIMEOUT                       0x18
00063 #define SMB_UNSUPPORTED_PROTOCOL          0x19
00064 #define SMB_BUS_BUSY                      0x1A
00065 
00066 /* SMB_REQUEST.Protocol constants */
00067 #define SMB_WRITE_QUICK                   0x00
00068 #define SMB_READ_QUICK                    0x01
00069 #define SMB_SEND_BYTE                     0x02
00070 #define SMB_RECEIVE_BYTE                  0x03
00071 #define SMB_WRITE_BYTE                    0x04
00072 #define SMB_READ_BYTE                     0x05
00073 #define SMB_WRITE_WORD                    0x06
00074 #define SMB_READ_WORD                     0x07
00075 #define SMB_WRITE_BLOCK                   0x08
00076 #define SMB_READ_BLOCK                    0x09
00077 #define SMB_PROCESS_CALL                  0x0A
00078 #define SMB_MAXIMUM_PROTOCOL              0x0A
00079 
00080 typedef struct _SMB_REQUEST {
00081   UCHAR  Status;
00082   UCHAR  Protocol;
00083   UCHAR  Address;
00084   UCHAR  Command;
00085   UCHAR  BlockLength;
00086   UCHAR  Data[SMB_MAX_DATA_SIZE];
00087 } SMB_REQUEST, *PSMB_REQUEST;
00088 
00089 typedef VOID STDCALL
00090 (*SMB_ALARM_NOTIFY)(
00091   PVOID  Context,
00092   UCHAR  Address,
00093   USHORT  Data);
00094 
00095 typedef struct _SMB_REGISTER_ALARM {
00096   UCHAR  MinAddress;
00097   UCHAR  MaxAddress;
00098   SMB_ALARM_NOTIFY  NotifyFunction;
00099   PVOID  NotifyContext;
00100 } SMB_REGISTER_ALARM, *PSMB_REGISTER_ALARM;
00101 
00102 /* SMB_CLASS.XxxVersion constants */
00103 #define SMB_CLASS_MAJOR_VERSION           0x0001
00104 #define SMB_CLASS_MINOR_VERSION           0x0000
00105 
00106 typedef NTSTATUS DDKAPI
00107 (*SMB_RESET_DEVICE)(
00108   /*IN*/ struct _SMB_CLASS  *SmbClass,
00109   /*IN*/ PVOID  SmbMiniport);
00110 
00111 typedef VOID DDKAPI
00112 (*SMB_START_IO)(
00113   /*IN*/ struct _SMB_CLASS  *SmbClass,
00114   /*IN*/ PVOID  SmbMiniport);
00115 
00116 typedef NTSTATUS DDKAPI
00117 (*SMB_STOP_DEVICE)(
00118   /*IN*/ struct _SMB_CLASS  *SmbClass,
00119   /*IN*/ PVOID  SmbMiniport);
00120 
00121 typedef struct _SMB_CLASS {
00122   USHORT  MajorVersion;
00123   USHORT  MinorVersion;
00124   PVOID  Miniport;
00125   PDEVICE_OBJECT  DeviceObject;
00126   PDEVICE_OBJECT  PDO;
00127   PDEVICE_OBJECT  LowerDeviceObject;
00128   PIRP  CurrentIrp;
00129   PSMB_REQUEST  CurrentSmb;
00130   SMB_RESET_DEVICE  ResetDevice;
00131   SMB_START_IO  StartIo;
00132   SMB_STOP_DEVICE  StopDevice;
00133 } SMB_CLASS, *PSMB_CLASS;
00134 
00135 SMBCLASSAPI
00136 VOID
00137 DDKAPI
00138 SmbClassAlarm(
00139   /*IN*/ PSMB_CLASS  SmbClass,
00140   /*IN*/ UCHAR  Address,
00141   /*IN*/ USHORT  Data);
00142 
00143 SMBCLASSAPI
00144 VOID
00145 DDKAPI
00146 SmbClassCompleteRequest(
00147   /*IN*/ PSMB_CLASS  SmbClass);
00148 
00149 typedef NTSTATUS DDKAPI
00150 (*PSMB_INITIALIZE_MINIPORT)(
00151   /*IN*/ PSMB_CLASS  SmbClass,
00152   /*IN*/ PVOID  MiniportExtension,
00153   /*IN*/ PVOID  MiniportContext);
00154 
00155 SMBCLASSAPI
00156 NTSTATUS
00157 DDKAPI
00158 SmbClassCreateFdo(
00159   /*IN*/ PDRIVER_OBJECT  DriverObject,
00160   /*IN*/ PDEVICE_OBJECT  PDO,
00161   /*IN*/ ULONG  MiniportExtensionSize,
00162   /*IN*/ PSMB_INITIALIZE_MINIPORT  MiniportInitialize,
00163   /*IN*/ PVOID  MiniportContext,
00164   /*OUT*/ PDEVICE_OBJECT  *FDO);
00165 
00166 SMBCLASSAPI
00167 NTSTATUS
00168 DDKAPI
00169 SmbClassInitializeDevice(
00170   /*IN*/ ULONG  MajorVersion,
00171   /*IN*/ ULONG  MinorVersion,
00172   /*IN*/ PDRIVER_OBJECT  DriverObject);
00173 
00174 SMBCLASSAPI
00175 VOID
00176 DDKAPI
00177 SmbClassLockDevice(
00178   /*IN*/ PSMB_CLASS  SmbClass);
00179 
00180 SMBCLASSAPI
00181 VOID
00182 DDKAPI
00183 SmbClassUnlockDevice(
00184   /*IN*/ PSMB_CLASS  SmbClass);
00185 
00186 #ifdef __cplusplus
00187 }
00188 #endif
00189 
00190 #endif /* __SMBUS_H */