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.

140 lines
5.4 KiB

  1. //==========================================================================;
  2. //
  3. // I2CSCRPT.H
  4. // I2CScript class definitions.
  5. // Main Include Module.
  6. // Copyright (c) 1996 - 1998 ATI Technologies Inc. All Rights Reserved.
  7. //
  8. //==========================================================================;
  9. #ifndef _I2CSCRIPT_H_
  10. #define _I2CSCRIPT_H_
  11. #include "i2cgpio.h"
  12. #define I2CSCRIPT_LENGTH_MAXIMUM 100
  13. #define I2C_FIXED_CLOCK_RATE 10000
  14. // The I2CScript is build from the following primitives
  15. typedef struct tagI2CScriptPrimitive
  16. {
  17. BYTE byData; // Data to be used in the I2C operation
  18. BYTE byORData; // Data to be used for a logical OR operation
  19. BYTE byANDData; // Data to be used for a logical AND operation
  20. BYTE byFlags; // implementation specific internal Script flags for I2C operation
  21. ULONG ulProviderFlags; // I2CProvider specific flags
  22. ULONG ulCommand; // I2CProvider specific command
  23. } I2CScriptPrimitive, * PI2CScriptPrimitive;
  24. typedef struct
  25. {
  26. UCHAR uchModifyORValue;
  27. UCHAR uchModifyANDValue;
  28. } I2C_MODIFY_VALUES, * PI2C_MODIFY_VALUES;
  29. // New I2CScript control structure - extension to the old I2C access structure
  30. typedef struct tagI2CPacket
  31. {
  32. UCHAR uchChipAddress; // I2C Address
  33. UCHAR uchI2CResult; // valid in synchronous operation only
  34. USHORT cbWriteCount; // bytes to write ( included SubAddress, if exist)
  35. USHORT cbReadCount; // bytes to read ( usually one)
  36. USHORT usFlags; // describes the desired operation
  37. PUCHAR puchWriteBuffer; // buffer to write
  38. PUCHAR puchReadBuffer; // buffer to read
  39. UCHAR uchORValue; // applied only in Read-Modify-Write cycle
  40. UCHAR uchANDValue; // applied only in Read-Modify-Write cycle
  41. USHORT usReserved; //
  42. } I2CPacket, * PI2CPacket;
  43. // possible flags applied to usFlags
  44. #define I2COPERATION_READ 0x0001 // might not be needed - use bcReadCount
  45. #define I2COPERATION_WRITE 0x0002 // might be not needed - use bcReadCount
  46. #define I2COPERATION_READWRITE 0x0004
  47. #define I2COPERATION_RANDOMACCESS 0x0100 // to indicate 16 bits emulation to provide
  48. // built-in support for ITT decoder and ST24 series
  49. // of I2C driven EEPROM
  50. extern "C"
  51. {
  52. typedef VOID ( STREAMAPI * PHWCompletionRoutine)( IN PVOID pSrb);
  53. }
  54. class CI2CScript
  55. {
  56. public:
  57. CI2CScript ( PPORT_CONFIGURATION_INFORMATION pConfigInfo, PUINT puiError);
  58. PVOID operator new ( size_t stSize, PVOID pAllocation);
  59. // Attributes
  60. public:
  61. private:
  62. // I2C Provider related
  63. I2CINTERFACE m_i2cProviderInterface;
  64. PDEVICE_OBJECT m_pdoDriver;
  65. ULONG m_ulI2CAccessClockRate;
  66. DWORD m_dwI2CAccessKey;
  67. // I2CScript management related
  68. BOOL m_bExecutionInProcess;
  69. UINT m_nExecutionIndex;
  70. UINT m_nCompletionIndex;
  71. UINT m_nScriptLength;
  72. PHWCompletionRoutine m_pfnReturnWhenDone;
  73. I2CScriptPrimitive m_i2cScript[I2CSCRIPT_LENGTH_MAXIMUM];
  74. // Implementation
  75. public:
  76. BOOL LockI2CProviderEx ( void);
  77. BOOL ReleaseI2CProvider ( void);
  78. BOOL ExecuteI2CPacket ( IN OUT PI2CPacket);
  79. BOOL PerformI2CPacketOperation ( IN OUT PI2CPacket pI2CPacket);
  80. BOOL AppendToScript ( IN PI2CPacket);
  81. void ClearScript ( void);
  82. BOOL ExecuteScript ( IN PHW_STREAM_REQUEST_BLOCK pSrb,
  83. IN PHWCompletionRoutine pfnScriptCompletion);
  84. void InterpreterScript ( void);
  85. UINT GetScriptResults ( PUINT puiReadCount, PUCHAR puchReadBuffer);
  86. private:
  87. BOOL LockI2CProvider ( void);
  88. UINT AccessI2CProvider ( PDEVICE_OBJECT pdoClient, PI2CControl pi2cAccessBlock);
  89. BOOL InitializeAttachI2CProvider ( I2CINTERFACE * pI2CInterface, PDEVICE_OBJECT pDeviceObject);
  90. BOOL LocateAttachI2CProvider ( I2CINTERFACE * pI2CInterface, PDEVICE_OBJECT pDeviceObject, int nIrpMajorFunction);
  91. UINT CheckI2CScriptPacket ( IN PI2CPacket pI2CPacket);
  92. BOOL GetI2CProviderLockStatus ( void);
  93. };
  94. extern "C"
  95. NTSTATUS I2CScriptIoSynchCompletionRoutine ( IN PDEVICE_OBJECT pDeviceObject,
  96. IN PIRP pIrp,
  97. IN PVOID Event);
  98. // errors definition for internal use
  99. #define I2CSCRIPT_NOERROR 0x00
  100. #define I2CSCRIPT_ERROR_NOPROVIDER 0x01
  101. #define I2CSCRIPT_ERROR_NODATA 0x02
  102. #define I2CSCRIPT_ERROR_NOBUFFER 0x03
  103. #define I2CSCRIPT_ERROR_READWRITE 0x04
  104. #define I2CSCRIPT_ERROR_OVERFLOW 0x05
  105. // time definitions
  106. #define I2CSCRIPT_DELAY_OPENPROVIDER -2000
  107. #define I2CSCRIPT_DELAY_GETPROVIDERSTATUS -2000
  108. // time limits
  109. #define I2CSCRIPT_TIMELIMIT_OPENPROVIDER 50000000 // 5 seconds in 100 nsec.
  110. #endif // _I2CSCRIPT_H_
  111.