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.

175 lines
6.5 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1996 - 1997 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //@@BEGIN_DDKSPLIT
  11. //
  12. // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  13. //
  14. // The files
  15. // \wdm10\ddk\inc\i2cgpio.h
  16. // \dev\ddk\inc\i2cgpio.h
  17. // Are the same.
  18. //
  19. // When changing either file, be sure to update the other file in the other
  20. // directory. This has been done to ensure that the DirectX DDK can pull
  21. // I2CGPIO.H into its DDK from \dev\ddk\inc, and not have to enlist in the
  22. // \wdm10 ddk.
  23. //
  24. //@@END_DDKSPLIT
  25. //==========================================================================;
  26. #if 0
  27. To access the IO functionality in a WDM driver or the VDD, WDM driver sends
  28. the following IRP to its parent.
  29. MajorFunction = IRP_MJ_PNP;
  30. MinorFunction = IRP_MN_QUERY_INTERFACE;
  31. Guid = DEFINE_GUID( GUID_GPIO_INTERFACE,
  32. 0x02295e87L, 0xbb3f, 0x11d0, 0x80, 0xce, 0x0, 0x20, 0xaf, 0xf7, 0x49, 0x1e);
  33. The QUERY_INTERFACE Irp will return an interface (set of function pointers)
  34. of the type xxxxINTERFACE, defined below. This is essentially a table of
  35. function pointers.
  36. #endif
  37. #ifndef __I2CGPIO_H__
  38. #define __I2CGPIO_H__
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif // __cplusplus
  42. // Guids
  43. //
  44. // DEFINE_GUID requires that you include wdm.h before this file.
  45. // #define INITGUID to actually initialize the guid in memory.
  46. //
  47. DEFINE_GUID( GUID_I2C_INTERFACE, 0x02295e86L, 0xbb3f, 0x11d0, 0x80, 0xce, 0x0, 0x20, 0xaf, 0xf7, 0x49, 0x1e);
  48. DEFINE_GUID( GUID_GPIO_INTERFACE,0x02295e87L, 0xbb3f, 0x11d0, 0x80, 0xce, 0x0, 0x20, 0xaf, 0xf7, 0x49, 0x1e);
  49. DEFINE_GUID( GUID_COPYPROTECTION_INTERFACE, 0x02295e88L, 0xbb3f, 0x11d0, 0x80, 0xce, 0x0, 0x20, 0xaf, 0xf7, 0x49, 0x1e);
  50. //==========================================================================;
  51. // used below if neccessary
  52. #ifndef BYTE
  53. #define BYTE UCHAR
  54. #endif
  55. #ifndef DWORD
  56. #define DWORD ULONG
  57. #endif
  58. //==========================================================================;
  59. //
  60. // I2C section
  61. //
  62. // I2C Commands
  63. #define I2C_COMMAND_NULL 0X0000
  64. #define I2C_COMMAND_READ 0X0001
  65. #define I2C_COMMAND_WRITE 0X0002
  66. #define I2C_COMMAND_STATUS 0X0004
  67. #define I2C_COMMAND_RESET 0X0008
  68. // The following flags are provided on a READ or WRITE command
  69. #define I2C_FLAGS_START 0X0001 // START + addx
  70. #define I2C_FLAGS_STOP 0X0002 // STOP
  71. #define I2C_FLAGS_DATACHAINING 0X0004 // STOP, START + addx
  72. #define I2C_FLAGS_ACK 0X0010 // ACKNOWLEDGE (normally set)
  73. // The following status flags are returned on completion of the operation
  74. #define I2C_STATUS_NOERROR 0X0000
  75. #define I2C_STATUS_BUSY 0X0001
  76. #define I2C_STATUS_ERROR 0X0002
  77. typedef struct _I2CControl {
  78. ULONG Command; // I2C_COMMAND_*
  79. DWORD dwCookie; // Context identifier returned on Open
  80. BYTE Data; // Data to write, or returned byte
  81. BYTE Reserved[3]; // Filler
  82. ULONG Flags; // I2C_FLAGS_*
  83. ULONG Status; // I2C_STATUS_*
  84. ULONG ClockRate; // Bus clockrate in Hz.
  85. } I2CControl, *PI2CControl;
  86. // this is the Interface definition for I2C
  87. //
  88. typedef NTSTATUS (STDMETHODCALLTYPE *I2COPEN)(PDEVICE_OBJECT, ULONG, PI2CControl);
  89. typedef NTSTATUS (STDMETHODCALLTYPE *I2CACCESS)(PDEVICE_OBJECT, PI2CControl);
  90. typedef struct {
  91. INTERFACE _vddInterface;
  92. I2COPEN i2cOpen;
  93. I2CACCESS i2cAccess;
  94. } I2CINTERFACE;
  95. //==========================================================================;
  96. //
  97. // GPIO section
  98. //
  99. // GPIO Commands
  100. #define GPIO_COMMAND_QUERY 0X0001 // get #pins and nBufferSize
  101. #define GPIO_COMMAND_OPEN 0X0001 // old open
  102. #define GPIO_COMMAND_OPEN_PINS 0X0002 // get dwCookie
  103. #define GPIO_COMMAND_CLOSE_PINS 0X0004 // invalidate cookie
  104. #define GPIO_COMMAND_READ_BUFFER 0X0008
  105. #define GPIO_COMMAND_WRITE_BUFFER 0X0010
  106. // The following flags are provided on a READ_BUFFER or WRITE_BUFFER command
  107. // lpPins bits set MUST have contiguous bits set for a read/write command.
  108. //
  109. // On a READ, if the number of pins set in the bitmask does not fill a
  110. // byte/word/dword, then zeros are returned for those positions.
  111. // on a WRITE, if the number of pins set in the bitmask does not fill a
  112. // byte/word/dword, a read/modify/write is done on the port/mmio position
  113. // that represents those bits.
  114. #define GPIO_FLAGS_BYTE 0x0001 // do byte read/write
  115. #define GPIO_FLAGS_WORD 0x0002 // do word read/write
  116. #define GPIO_FLAGS_DWORD 0x0004 // do dword read/write
  117. // The following status flags are returned on completion of the operation
  118. #define GPIO_STATUS_NOERROR 0X0000
  119. #define GPIO_STATUS_BUSY 0X0001
  120. #define GPIO_STATUS_ERROR 0X0002
  121. #define GPIO_STATUS_NO_ASYNCH 0X0004 // gpio provider does not do asynch xfer
  122. typedef struct _GPIOControl {
  123. ULONG Command; // GPIO_COMMAND_*
  124. ULONG Flags; // GPIO_FLAGS_*
  125. DWORD dwCookie; // Context identifier returned on Open
  126. ULONG Status; // GPIO_STATUS_*
  127. ULONG nBytes; // # of bytes to send or recieved
  128. ULONG nBufferSize; // max size of buffer
  129. ULONG nPins; // number of GPIO pins returned by Open
  130. UCHAR *Pins; // pointer to bitmask of pins to read/write
  131. UCHAR *Buffer; // pointer to GPIO data to send/recieve
  132. void (*AsynchCompleteCallback)(UCHAR *Buffer);
  133. // NULL if synchronous xfer, valid ptr if asynch.
  134. GUID PrivateInterfaceType;
  135. void (*PrivateInterface)();
  136. } GPIOControl, *PGPIOControl;
  137. // This is the GPIO interface
  138. //
  139. typedef NTSTATUS (STDMETHODCALLTYPE *GPIOOPEN)(PDEVICE_OBJECT, ULONG, PGPIOControl);
  140. typedef NTSTATUS (STDMETHODCALLTYPE *GPIOACCESS)(PDEVICE_OBJECT, PGPIOControl);
  141. typedef struct {
  142. INTERFACE _vddInterface;
  143. GPIOOPEN gpioOpen;
  144. GPIOACCESS gpioAccess;
  145. } GPIOINTERFACE;
  146. //==========================================================================;
  147. #ifdef __cplusplus
  148. }
  149. #endif // __cplusplus
  150. #endif //__I2CGPIO_H__