NTScsi.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * distilled information from various header files from Microsoft's
  3. * DDK for Windows NT 4.0
  4. */
  5. #ifndef NTSCSI_H_INCLUDED
  6. #define NTSCSI_H_INCLUDED
  7. #include <windows.h>
  8. #include "Aspi.h"
  9. typedef struct {
  10. USHORT Length;
  11. UCHAR ScsiStatus;
  12. UCHAR PathId;
  13. UCHAR TargetId;
  14. UCHAR Lun;
  15. UCHAR CdbLength;
  16. UCHAR SenseInfoLength;
  17. UCHAR DataIn;
  18. ULONG DataTransferLength;
  19. ULONG TimeOutValue;
  20. ULONG DataBufferOffset;
  21. ULONG SenseInfoOffset;
  22. UCHAR Cdb[16];
  23. } SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
  24. typedef struct {
  25. USHORT Length;
  26. UCHAR ScsiStatus;
  27. UCHAR PathId;
  28. UCHAR TargetId;
  29. UCHAR Lun;
  30. UCHAR CdbLength;
  31. UCHAR SenseInfoLength;
  32. UCHAR DataIn;
  33. ULONG DataTransferLength;
  34. ULONG TimeOutValue;
  35. PVOID DataBuffer;
  36. ULONG SenseInfoOffset;
  37. UCHAR Cdb[16];
  38. } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
  39. typedef struct {
  40. SCSI_PASS_THROUGH spt;
  41. ULONG Filler;
  42. UCHAR ucSenseBuf[32];
  43. UCHAR ucDataBuf[512];
  44. } SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;
  45. typedef struct {
  46. SCSI_PASS_THROUGH_DIRECT spt;
  47. ULONG Filler;
  48. UCHAR ucSenseBuf[32];
  49. } SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
  50. typedef struct {
  51. UCHAR NumberOfLogicalUnits;
  52. UCHAR InitiatorBusId;
  53. ULONG InquiryDataOffset;
  54. } SCSI_BUS_DATA, *PSCSI_BUS_DATA;
  55. typedef struct {
  56. UCHAR NumberOfBusses;
  57. SCSI_BUS_DATA BusData[1];
  58. } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
  59. typedef struct {
  60. UCHAR PathId;
  61. UCHAR TargetId;
  62. UCHAR Lun;
  63. BOOLEAN DeviceClaimed;
  64. ULONG InquiryDataLength;
  65. ULONG NextInquiryDataOffset;
  66. UCHAR InquiryData[1];
  67. } SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
  68. typedef struct {
  69. ULONG Length;
  70. UCHAR PortNumber;
  71. UCHAR PathId;
  72. UCHAR TargetId;
  73. UCHAR Lun;
  74. } SCSI_ADDRESS, *PSCSI_ADDRESS;
  75. /*
  76. * method codes
  77. */
  78. #define METHOD_BUFFERED 0
  79. #define METHOD_IN_DIRECT 1
  80. #define METHOD_OUT_DIRECT 2
  81. #define METHOD_NEITHER 3
  82. /*
  83. * file access values
  84. */
  85. #define FILE_ANY_ACCESS 0
  86. #ifndef FILE_READ_ACCESS
  87. #define FILE_READ_ACCESS (0x0001)
  88. #define FILE_WRITE_ACCESS (0x0002)
  89. #endif
  90. #define IOCTL_SCSI_BASE 0x00000004
  91. /*
  92. * constants for DataIn member of SCSI_PASS_THROUGH* structures
  93. */
  94. #define SCSI_IOCTL_DATA_OUT 0
  95. #define SCSI_IOCTL_DATA_IN 1
  96. #define SCSI_IOCTL_DATA_UNSPECIFIED 2
  97. /*
  98. * Standard IOCTL define
  99. */
  100. #define CTL_CODE( DevType, Function, Method, Access ) ( \
  101. ((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  102. )
  103. #define IOCTL_SCSI_PASS_THROUGH CTL_CODE( IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS )
  104. #define IOCTL_SCSI_MINIPORT CTL_CODE( IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS )
  105. #define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE( IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
  106. #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE( IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
  107. #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE( IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS )
  108. #define IOCTL_SCSI_GET_ADDRESS CTL_CODE( IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS )
  109. int NtScsiInit( void );
  110. int NtScsiDeInit( void );
  111. BYTE NtScsiGetNumAdapters( void );
  112. DWORD NtScsiGetASPI32SupportInfo( void );
  113. DWORD NtScsiGetDeviceType( LPSRB_GDEVBLOCK lpsrb );
  114. BYTE NtScsiGetDeviceIndex( BYTE ha, BYTE tgt, BYTE lun );
  115. DWORD NtScsiHandleHaInquiry( LPSRB_HAINQUIRY lpsrb );
  116. extern "C" DWORD NtScsiSendASPI32Command( LPSRB lpsrb );
  117. DWORD NtScsiExecSCSICommand( LPSRB_EXECSCSICMD lpsrb, BOOL bBeenHereBefore );
  118. #endif