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.

146 lines
5.3 KiB

  1. #ifndef _CIO
  2. #define _CIO
  3. #include <STI.H>
  4. #include <DEVIOCTL.H>
  5. #include <SCSISCAN.H>
  6. //
  7. // These BUS_TYPE defines must match the ones in wiamicro.h
  8. // I don't include wiamicro.h in this file, because
  9. // the IO layer shouldn't know anything about the Micro driver
  10. // except BUS_TYPE, and it makes a clean / non-circular include system
  11. //
  12. #define IO_BUS_TYPE_SCSI 200
  13. #define IO_BUS_TYPE_USB 201
  14. #define IO_BUS_TYPE_PARALLEL 202
  15. #define IO_BUS_TYPE_FIREWIRE 203
  16. //
  17. // SCSI
  18. //
  19. //
  20. // SRB Functions
  21. //
  22. #define SRB_FUNCTION_EXECUTE_SCSI 0x00
  23. #define SRB_FUNCTION_CLAIM_DEVICE 0x01
  24. #define SRB_FUNCTION_IO_CONTROL 0x02
  25. #define SRB_FUNCTION_RECEIVE_EVENT 0x03
  26. #define SRB_FUNCTION_RELEASE_QUEUE 0x04
  27. #define SRB_FUNCTION_ATTACH_DEVICE 0x05
  28. #define SRB_FUNCTION_RELEASE_DEVICE 0x06
  29. #define SRB_FUNCTION_SHUTDOWN 0x07
  30. #define SRB_FUNCTION_FLUSH 0x08
  31. #define SRB_FUNCTION_ABORT_COMMAND 0x10
  32. #define SRB_FUNCTION_RELEASE_RECOVERY 0x11
  33. #define SRB_FUNCTION_RESET_BUS 0x12
  34. #define SRB_FUNCTION_RESET_DEVICE 0x13
  35. #define SRB_FUNCTION_TERMINATE_IO 0x14
  36. #define SRB_FUNCTION_FLUSH_QUEUE 0x15
  37. #define SRB_FUNCTION_REMOVE_DEVICE 0x16
  38. //
  39. // SRB Status
  40. //
  41. #define SRB_STATUS_PENDING 0x00
  42. #define SRB_STATUS_SUCCESS 0x01
  43. #define SRB_STATUS_ABORTED 0x02
  44. #define SRB_STATUS_ABORT_FAILED 0x03
  45. #define SRB_STATUS_ERROR 0x04
  46. #define SRB_STATUS_BUSY 0x05
  47. #define SRB_STATUS_INVALID_REQUEST 0x06
  48. #define SRB_STATUS_INVALID_PATH_ID 0x07
  49. #define SRB_STATUS_NO_DEVICE 0x08
  50. #define SRB_STATUS_TIMEOUT 0x09
  51. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  52. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  53. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  54. #define SRB_STATUS_BUS_RESET 0x0E
  55. #define SRB_STATUS_PARITY_ERROR 0x0F
  56. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  57. #define SRB_STATUS_NO_HBA 0x11
  58. #define SRB_STATUS_DATA_OVERRUN 0x12
  59. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  60. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  61. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  62. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  63. #define SRB_STATUS_INVALID_LUN 0x20
  64. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  65. #define SRB_STATUS_BAD_FUNCTION 0x22
  66. #define SRB_STATUS_ERROR_RECOVERY 0x23
  67. #define SCSI_DIR_NONE 0
  68. #define SCSI_DIR_IN 0x08
  69. #define SCSI_DIR_OUT 0x10
  70. #define MAX_CDB_LENGTH 12
  71. #define MAX_SENSE_LENGTH 16
  72. #define SCSIREQLEN 16
  73. typedef struct {
  74. BYTE SRB_Cmd;
  75. BYTE SRB_HaId;
  76. BYTE SRB_Target;
  77. BYTE SRB_HaStat;
  78. BYTE SRB_TargStat;
  79. BYTE SRB_Status;
  80. BYTE SRB_CDBLen;
  81. BYTE CDBByte[MAX_CDB_LENGTH];
  82. BYTE SRB_SenseLen;
  83. DWORD SRB_BufLen;
  84. BYTE SRB_Flags;
  85. BYTE bReserved;
  86. LPBYTE SRB_BufPointer;
  87. BYTE SenseArea[MAX_SENSE_LENGTH];
  88. LPVOID lpUserArea;
  89. } CFM_SRB_ExecSCSICmd, *PCFM_SRB_ExecSCSICmd;
  90. #define SENSE_LENGTH 18
  91. class CIO {
  92. public:
  93. CIO(HANDLE hIO = NULL);
  94. ~CIO();
  95. VOID SetBusType(LONG lBusType);
  96. VOID SetIOHandle(HANDLE hIO);
  97. VOID IO_INIT_EXT6SCANNERCMD( BYTE bCommand, BYTE bDirection, DWORD dwLength, LPBYTE lpBuffer );
  98. VOID IO_INIT_6SCANNERCMD(BYTE bCommand, BYTE bDirection, DWORD dwLength, LPBYTE lpBuffer);
  99. VOID IO_INIT_10SCANNERCMD(BYTE bCommand, BYTE bDirection, DWORD dwLength, LPBYTE lpBuffer);
  100. VOID IO_INIT_12SCANNERCMD(BYTE bCommand, BYTE bDirection, DWORD dwLength, LPBYTE lpBuffer);
  101. VOID IO_SET_SCANNERCMDINDEX( USHORT usIndex, BYTE bNewValue );
  102. BYTE IO_GET_DATAINDEX( USHORT usRequestedIndex );
  103. BOOL IO_COMMAND_NOT_OK( VOID );
  104. BYTE IO_GET_SENSEKEY( VOID );
  105. BYTE IO_GET_SENSECODE( VOID );
  106. BYTE IO_GET_SENSECODEQUALIFIER( VOID );
  107. USHORT IO_GET_FULLSENSE( VOID );
  108. BOOL IO_BUFFER_TO_BIG( VOID );
  109. BOOL IO_IS_EOM( VOID );
  110. BOOL IO_IS_ILI( VOID );
  111. DWORD IO_GET_MISSINGDATA( VOID );
  112. DWORD IO_GET_VALIDDATA( VOID );
  113. VOID IO_GETCOMMAND(CFM_SRB_ExecSCSICmd* psrb);
  114. VOID IO_SENDCOMMAND();
  115. VOID CreateScsiReadCommand(SCSISCAN_CMD *pScsiScan, BYTE bCommandLength, DWORD dwBufferLength);
  116. HRESULT SendCommand(STI_RAW_CONTROL_CODE EscapeFunction,
  117. LPVOID pInData,
  118. DWORD cbInDataSize,
  119. LPVOID pOutData,
  120. DWORD cbOutDataSize,
  121. LPDWORD pcbActualData);
  122. USHORT MOTOROLA_USHORT(USHORT us);
  123. ULONG MOTOROLA_ULONG(ULONG ul);
  124. private:
  125. UCHAR m_ucSrbStatus;
  126. BYTE m_abSenseArea[SENSE_LENGTH + 1];
  127. HANDLE m_hIO;
  128. LONG m_lBusType;
  129. protected:
  130. CFM_SRB_ExecSCSICmd m_srb;
  131. };
  132. #endif