Aspifunc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // ----------------------------------------------
  2. // - ASPIFUNC header file -
  3. // - Written 1996-1998 by Christoph Schmelnik -
  4. // ----------------------------------------------
  5. // Version 1.40 : 24.02.1998
  6. // Changes:
  7. // function prototype for WaitSCSIRequest extended by immediate parameter
  8. #ifndef _ASPIFUNC_H
  9. #define _ASPIFUNC_H
  10. #ifndef STRICT
  11. #define STRICT // Enable strict tape checking
  12. #define WIN32_LEAN_AND_MEAN // Include only needed header files
  13. #endif
  14. #include <windows.h>
  15. #include <stdio.h>
  16. #include <winioctl.h>
  17. #include "winaspi.h"
  18. #include "scsidefs.h"
  19. /*#ifdef DLL
  20. #define DACDLL __declspec(dllexport)
  21. #else
  22. #define DACDLL __declspec(dllimport)
  23. #endif*/
  24. #define DACDLL
  25. typedef DWORD (__cdecl *VOIDPROC)();
  26. typedef DWORD (__cdecl *SRBPROC)(LPSRB);
  27. typedef BYTE TOpcode[30];
  28. // NT DeviceIO Structures
  29. #define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
  30. #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
  31. #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  32. typedef struct _IO_SCSI_CAPABILITIES {
  33. ULONG Length;
  34. ULONG MaximumTransferLength;
  35. ULONG MaximumPhysicalPages;
  36. ULONG SupportedAsynchronousEvents;
  37. ULONG AlignmentMask;
  38. BOOLEAN TaggedQueuing;
  39. BOOLEAN AdapterScansDown;
  40. BOOLEAN AdapterUsesPio;
  41. } IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
  42. typedef struct _SCSI_PASS_THROUGH_DIRECT {
  43. USHORT Length;
  44. UCHAR ScsiStatus;
  45. UCHAR PathId;
  46. UCHAR TargetId;
  47. UCHAR Lun;
  48. UCHAR CdbLength;
  49. UCHAR SenseInfoLength;
  50. UCHAR DataIn;
  51. ULONG DataTransferLength;
  52. ULONG TimeOutValue;
  53. PVOID DataBuffer;
  54. ULONG SenseInfoOffset;
  55. UCHAR Cdb[16];
  56. } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
  57. typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER {
  58. SCSI_PASS_THROUGH_DIRECT sptd;
  59. ULONG Filler; // realign buffer to double word boundary
  60. UCHAR ucSenseBuf[32];
  61. } SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
  62. extern HMODULE hDLL;
  63. extern VOIDPROC GetASPI32SupportInfo;
  64. extern SRBPROC SendASPI32Command;
  65. extern int ASPIInstalled;
  66. extern int RunningNT;
  67. extern int NumberOfHostAdapters;
  68. // base ASPI functions
  69. int DACDLL GetDeviceType(int HostAdapterNumber,int TargetId,int LUN);
  70. BOOL ExecuteSCSIRequest(int HostAdapterNumber,int TargetId,int LUN,int RequestFlags,
  71. TOpcode OpC, BYTE OpCLen,void *DataPtr, int DataLen,HANDLE hDriveEvent);
  72. void ExecuteSCSIRequest(SRB_ExecSCSICmd &MySRB,HANDLE hDriveEvent);
  73. void FillSCSIRequest(int HostAdapterNumber,int TargetId,int LUN,int RequestFlags,
  74. TOpcode OpC, BYTE OpCLen,void *DataPtr, int DataLen,SRB_ExecSCSICmd &MySRB,HANDLE hDriveEvent);
  75. BYTE WaitSCSIRequest(SRB_ExecSCSICmd &MySRB,HANDLE hDriveEvent,BOOL bImmediate=FALSE);
  76. BOOL AbortSCSIRequest(SRB_ExecSCSICmd &StuckSRB);
  77. int GetDeviceInfo(int HostAdapterNumber,int TargetId,int LUN,BYTE &SCSIType,char *VendorID,
  78. char *ProductID,char *ProductRevision,HANDLE hDriveEvent);
  79. BOOL HAInquiry(int HostAdapterNumber,char *ManagerID, char *HAID,THAUnique &HAUnique);
  80. BOOL TestUnitReady(int HostAdapterNumber,int TargetId,int LUN,HANDLE hDriveEvent);
  81. BOOL ModeSense(int HostAdapterNumber,int TargetId,int LUN,TDriveMode &ModeData,int Size,int PageCode,HANDLE hDriveEvent);
  82. BOOL ATAPIModeSense(int HostAdapterNumber,int TargetId,int LUN,TDriveMode &ModeData,int Size,int PageCode,HANDLE hDriveEvent);
  83. BOOL addModeSense(int HostAdapterNumber,int TargetId,int LUN,TDriveMode &ModeData,int Size,HANDLE hDriveEvent);
  84. BOOL ModeSelect(int HostAdapterNumber,int TargetId,int LUN,TDriveMode &ModeData,int Size,HANDLE hDriveEvent);
  85. BOOL addModeSelect(int HostAdapterNumber,int TargetId,int LUN,TDriveMode &ModeData,int Size,HANDLE hDriveEvent);
  86. BOOL SCSIMaxBlocks(HANDLE fh, int *mb);
  87. #endif //_ASPIFUNC_H