DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/dos/wnaspi32.h
00001 /******************************************************************************
00002 **
00003 **  Module Name:    wnaspi32.h
00004 **
00005 **  Description:    Header file for ASPI for Win32.  This header includes
00006 **                  macro and type declarations, and can be included without
00007 **                  modification when using Borland C++ or Microsoft Visual
00008 **                  C++ with 32-bit compilation.  If you are using a different
00009 **                  compiler then you MUST ensure that structures are packed
00010 **                  onto byte alignments, and that C++ name mangling is turned
00011 **                  off.
00012 **
00013 **  Notes:          This file created using 4 spaces per tab.
00014 **
00015 ******************************************************************************/
00016 
00017 #ifndef __WNASPI32_H__
00018 #define __WNASPI32_H__
00019 
00020 /*
00021 ** Make sure structures are packed and undecorated.
00022 */
00023 
00024 #ifdef __BORLANDC__
00025 #pragma option -a1
00026 #endif //__BORLANDC__
00027 
00028 #ifdef _MSC_VER
00029 #pragma pack(1)
00030 #endif //__MSC_VER
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif //__cplusplus
00035 
00036 //*****************************************************************************
00037 //      %%% SCSI MISCELLANEOUS EQUATES %%%
00038 //*****************************************************************************
00039 
00040 #define SENSE_LEN                   14          // Default sense buffer length
00041 #define SRB_DIR_SCSI                0x00        // Direction determined by SCSI
00042 #define SRB_POSTING                 0x01        // Enable ASPI posting
00043 #define SRB_ENABLE_RESIDUAL_COUNT   0x04        // Enable residual byte count reporting
00044 #define SRB_DIR_IN                  0x08        // Transfer from SCSI target to host
00045 #define SRB_DIR_OUT                 0x10        // Transfer from host to SCSI target
00046 #define SRB_EVENT_NOTIFY            0x40        // Enable ASPI event notification
00047 
00048 #define RESIDUAL_COUNT_SUPPORTED    0x02        // Extended buffer flag
00049 #define MAX_SRB_TIMEOUT             108000lu    // 30 hour maximum timeout in s
00050 #define DEFAULT_SRB_TIMEOUT         108000lu    // Max timeout by default
00051 
00052 
00053 //*****************************************************************************
00054 //      %%% ASPI Command Definitions %%%
00055 //*****************************************************************************
00056 
00057 #define SC_HA_INQUIRY               0x00        // Host adapter inquiry
00058 #define SC_GET_DEV_TYPE             0x01        // Get device type
00059 #define SC_EXEC_SCSI_CMD            0x02        // Execute SCSI command
00060 #define SC_ABORT_SRB                0x03        // Abort an SRB
00061 #define SC_RESET_DEV                0x04        // SCSI bus device reset
00062 #define SC_SET_HA_PARMS             0x05        // Set HA parameters
00063 #define SC_GET_DISK_INFO            0x06        // Get Disk information
00064 #define SC_RESCAN_SCSI_BUS          0x07        // ReBuild SCSI device map
00065 #define SC_GETSET_TIMEOUTS          0x08        // Get/Set target timeouts
00066 
00067 //*****************************************************************************
00068 //      %%% SRB Status %%%
00069 //*****************************************************************************
00070 
00071 #define SS_PENDING                  0x00        // SRB being processed
00072 #define SS_COMP                     0x01        // SRB completed without error
00073 #define SS_ABORTED                  0x02        // SRB aborted
00074 #define SS_ABORT_FAIL               0x03        // Unable to abort SRB
00075 #define SS_ERR                      0x04        // SRB completed with error
00076 
00077 #define SS_INVALID_CMD              0x80        // Invalid ASPI command
00078 #define SS_INVALID_HA               0x81        // Invalid host adapter number
00079 #define SS_NO_DEVICE                0x82        // SCSI device not installed
00080 
00081 #define SS_INVALID_SRB              0xE0        // Invalid parameter set in SRB
00082 #define SS_OLD_MANAGER              0xE1        // ASPI manager doesn't support Windows
00083 #define SS_BUFFER_ALIGN             0xE1        // Buffer not aligned (replaces OLD_MANAGER in Win32)
00084 #define SS_ILLEGAL_MODE             0xE2        // Unsupported Windows mode
00085 #define SS_NO_ASPI                  0xE3        // No ASPI managers resident
00086 #define SS_FAILED_INIT              0xE4        // ASPI for windows failed init
00087 #define SS_ASPI_IS_BUSY             0xE5        // No resources available to execute cmd
00088 #define SS_BUFFER_TO_BIG            0xE6        // Buffer size to big to handle!
00089 #define SS_MISMATCHED_COMPONENTS    0xE7        // The DLLs/EXEs of ASPI don't version check
00090 #define SS_NO_ADAPTERS              0xE8        // No host adapters to manage
00091 #define SS_INSUFFICIENT_RESOURCES   0xE9        // Couldn't allocate resources needed to init
00092 #define SS_ASPI_IS_SHUTDOWN         0xEA        // Call came to ASPI after PROCESS_DETACH
00093 #define SS_BAD_INSTALL              0xEB        // The DLL or other components are installed wrong
00094 
00095 //*****************************************************************************
00096 //      %%% Host Adapter Status %%%
00097 //*****************************************************************************
00098 
00099 #define HASTAT_OK                   0x00        // Host adapter did not detect an                                                                                                                       // error
00100 #define HASTAT_SEL_TO               0x11        // Selection Timeout
00101 #define HASTAT_DO_DU                0x12        // Data overrun data underrun
00102 #define HASTAT_BUS_FREE             0x13        // Unexpected bus free
00103 #define HASTAT_PHASE_ERR            0x14        // Target bus phase sequence                                                                                                                            // failure
00104 #define HASTAT_TIMEOUT              0x09        // Timed out while SRB was                                                                                                                                      waiting to beprocessed.
00105 #define HASTAT_COMMAND_TIMEOUT      0x0B        // Adapter timed out processing SRB.
00106 #define HASTAT_MESSAGE_REJECT       0x0D        // While processing SRB, the                                                                                                                            // adapter received a MESSAGE
00107 #define HASTAT_BUS_RESET            0x0E        // A bus reset was detected.
00108 #define HASTAT_PARITY_ERROR         0x0F        // A parity error was detected.
00109 #define HASTAT_REQUEST_SENSE_FAILED 0x10        // The adapter failed in issuing
00110 
00111 //*****************************************************************************
00112 //          %%% SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY (0) %%%
00113 //*****************************************************************************
00114 
00115 typedef struct                                  // Offset
00116 {                                               // HX/DEC
00117     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_HA_INQUIRY
00118     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00119     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00120     BYTE        SRB_Flags;                      // 03/003 ASPI request flags
00121     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved, MUST = 0
00122     BYTE        HA_Count;                       // 08/008 Number of host adapters present
00123     BYTE        HA_SCSI_ID;                     // 09/009 SCSI ID of host adapter
00124     BYTE        HA_ManagerId[16];               // 0A/010 String describing the manager
00125     BYTE        HA_Identifier[16];              // 1A/026 String describing the host adapter
00126     BYTE        HA_Unique[16];                  // 2A/042 Host Adapter Unique parameters
00127     WORD        HA_Rsvd1;                       // 3A/058 Reserved, MUST = 0
00128 }
00129 SRB_HAInquiry, *PSRB_HAInquiry, FAR *LPSRB_HAInquiry;
00130 
00131 //*****************************************************************************
00132 //          %%% SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE (1) %%%
00133 //*****************************************************************************
00134 
00135 typedef struct                                  // Offset
00136 {                                               // HX/DEC
00137     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_GET_DEV_TYPE
00138     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00139     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00140     BYTE        SRB_Flags;                      // 03/003 Reserved, MUST = 0
00141     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved, MUST = 0
00142     BYTE        SRB_Target;                     // 08/008 Target's SCSI ID
00143     BYTE        SRB_Lun;                        // 09/009 Target's LUN number
00144     BYTE        SRB_DeviceType;                 // 0A/010 Target's peripheral device type
00145     BYTE        SRB_Rsvd1;                      // 0B/011 Reserved, MUST = 0
00146 }
00147 SRB_GDEVBlock, *PSRB_GDEVBlock, FAR *LPSRB_GDEVBlock;
00148 
00149 //*****************************************************************************
00150 //          %%% SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD (2) %%%
00151 //*****************************************************************************
00152 
00153 typedef struct                                  // Offset
00154 {                                               // HX/DEC
00155     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_EXEC_SCSI_CMD
00156     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00157     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00158     BYTE        SRB_Flags;                      // 03/003 ASPI request flags
00159     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved
00160     BYTE        SRB_Target;                     // 08/008 Target's SCSI ID
00161     BYTE        SRB_Lun;                        // 09/009 Target's LUN number
00162     WORD        SRB_Rsvd1;                      // 0A/010 Reserved for Alignment
00163     DWORD       SRB_BufLen;                     // 0C/012 Data Allocation Length
00164     BYTE        FAR *SRB_BufPointer;            // 10/016 Data Buffer Pointer
00165     BYTE        SRB_SenseLen;                   // 14/020 Sense Allocation Length
00166     BYTE        SRB_CDBLen;                     // 15/021 CDB Length
00167     BYTE        SRB_HaStat;                     // 16/022 Host Adapter Status
00168     BYTE        SRB_TargStat;                   // 17/023 Target Status
00169     VOID        FAR *SRB_PostProc;              // 18/024 Post routine
00170     BYTE        SRB_Rsvd2[20];                  // 1C/028 Reserved, MUST = 0
00171     BYTE        CDBByte[16];                    // 30/048 SCSI CDB
00172     BYTE        SenseArea[SENSE_LEN+2];         // 50/064 Request Sense buffer
00173 }
00174 SRB_ExecSCSICmd, *PSRB_ExecSCSICmd, FAR *LPSRB_ExecSCSICmd;
00175 
00176 //*****************************************************************************
00177 //          %%% SRB - ABORT AN SRB - SC_ABORT_SRB (3) %%%
00178 //*****************************************************************************
00179 
00180 typedef struct                                  // Offset
00181 {                                               // HX/DEC
00182     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_ABORT_SRB
00183     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00184     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00185     BYTE        SRB_Flags;                      // 03/003 Reserved
00186     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved
00187     VOID        FAR *SRB_ToAbort;               // 08/008 Pointer to SRB to abort
00188 }
00189 SRB_Abort, *PSRB_Abort, FAR *LPSRB_Abort;
00190 
00191 //*****************************************************************************
00192 //          %%% SRB - BUS DEVICE RESET - SC_RESET_DEV (4) %%%
00193 //*****************************************************************************
00194 
00195 typedef struct                                  // Offset
00196 {                                               // HX/DEC
00197     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_RESET_DEV
00198     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00199     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00200     BYTE        SRB_Flags;                      // 03/003 ASPI request flags
00201     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved
00202     BYTE        SRB_Target;                     // 08/008 Target's SCSI ID
00203     BYTE        SRB_Lun;                        // 09/009 Target's LUN number
00204     BYTE        SRB_Rsvd1[12];                  // 0A/010 Reserved for Alignment
00205     BYTE        SRB_HaStat;                     // 16/022 Host Adapter Status
00206     BYTE        SRB_TargStat;                   // 17/023 Target Status
00207     VOID        FAR *SRB_PostProc;              // 18/024 Post routine
00208     BYTE        SRB_Rsvd2[36];                  // 1C/028 Reserved, MUST = 0
00209 }
00210 SRB_BusDeviceReset, *PSRB_BusDeviceReset, FAR *LPSRB_BusDeviceReset;
00211 
00212 //*****************************************************************************
00213 //          %%% SRB - GET DISK INFORMATION - SC_GET_DISK_INFO %%%
00214 //*****************************************************************************
00215 
00216 typedef struct                                  // Offset
00217 {                                               // HX/DEC
00218     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_GET_DISK_INFO
00219     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00220     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00221     BYTE        SRB_Flags;                      // 03/003 Reserved, MUST = 0
00222     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved, MUST = 0
00223     BYTE        SRB_Target;                     // 08/008 Target's SCSI ID
00224     BYTE        SRB_Lun;                        // 09/009 Target's LUN number
00225     BYTE        SRB_DriveFlags;                 // 0A/010 Driver flags
00226     BYTE        SRB_Int13HDriveInfo;            // 0B/011 Host Adapter Status
00227     BYTE        SRB_Heads;                      // 0C/012 Preferred number of heads translation
00228     BYTE        SRB_Sectors;                    // 0D/013 Preferred number of sectors translation
00229     BYTE        SRB_Rsvd1[10];                  // 0E/014 Reserved, MUST = 0
00230 }
00231 SRB_GetDiskInfo, *PSRB_GetDiskInfo, FAR *LPSRB_GetDiskInfo;
00232 
00233 //*****************************************************************************
00234 //          %%%  SRB - RESCAN SCSI BUS(ES) ON SCSIPORT %%%
00235 //*****************************************************************************
00236 
00237 typedef struct                                  // Offset
00238 {                                               // HX/DEC
00239     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_RESCAN_SCSI_BUS
00240     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00241     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00242     BYTE        SRB_Flags;                      // 03/003 Reserved, MUST = 0
00243     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved, MUST = 0
00244 }
00245 SRB_RescanPort, *PSRB_RescanPort, FAR *LPSRB_RescanPort;
00246 
00247 //*****************************************************************************
00248 //          %%% SRB - GET/SET TARGET TIMEOUTS %%%
00249 //*****************************************************************************
00250 
00251 typedef struct                                  // Offset
00252 {                                               // HX/DEC
00253     BYTE        SRB_Cmd;                        // 00/000 ASPI command code = SC_GETSET_TIMEOUTS
00254     BYTE        SRB_Status;                     // 01/001 ASPI command status byte
00255     BYTE        SRB_HaId;                       // 02/002 ASPI host adapter number
00256     BYTE        SRB_Flags;                      // 03/003 ASPI request flags
00257     DWORD       SRB_Hdr_Rsvd;                   // 04/004 Reserved, MUST = 0
00258     BYTE        SRB_Target;                     // 08/008 Target's SCSI ID
00259     BYTE        SRB_Lun;                        // 09/009 Target's LUN number
00260     DWORD       SRB_Timeout;                    // 0A/010 Timeout in half seconds
00261 }
00262 SRB_GetSetTimeouts, *PSRB_GetSetTimeouts, FAR *LPSRB_GetSetTimeouts;
00263 
00264 //*****************************************************************************
00265 //          %%% ASPIBUFF - Structure For Controllng I/O Buffers %%%
00266 //*****************************************************************************
00267 
00268 typedef struct tag_ASPI32BUFF                   // Offset
00269 {                                               // HX/DEC
00270     PBYTE                   AB_BufPointer;      // 00/000 Pointer to the ASPI allocated buffer
00271     DWORD                   AB_BufLen;          // 04/004 Length in bytes of the buffer
00272     DWORD                   AB_ZeroFill;        // 08/008 Flag set to 1 if buffer should be zeroed
00273     DWORD                   AB_Reserved;        // 0C/012 Reserved
00274 }
00275 ASPI32BUFF, *PASPI32BUFF, FAR *LPASPI32BUFF;
00276 
00277 //*****************************************************************************
00278 //          %%% TOC structures %%%
00279 //*****************************************************************************
00280 
00281 typedef struct
00282 {
00283  unsigned char  reserved1;
00284  unsigned char  cAdrCtrl;
00285  unsigned char  cTrackNum;
00286  unsigned char  reserved2;
00287  unsigned long  lAddr;
00288 } TOC_TRACK;
00289 
00290 typedef struct
00291 {
00292  unsigned short usTocDataLen;
00293  unsigned char  cFirstTrack;
00294  unsigned char  cLastTrack;
00295  TOC_TRACK      tracks[100];
00296 } TOC, *PTOC, FAR *LPTOC;
00297 
00298 //*****************************************************************************
00299 //          %%% PROTOTYPES - User Callable ASPI for Win32 Functions %%%
00300 //*****************************************************************************
00301 
00302 typedef struct 
00303 {
00304   BYTE      SRB_Cmd;
00305   BYTE      SRB_Status;
00306   BYTE      SRB_HaId;
00307   BYTE      SRB_Flags;
00308   DWORD     SRB_Hdr_Rsvd;
00309 } SRB, *PSRB, FAR *LPSRB;
00310 
00311 
00312 #if defined(__BORLANDC__)
00313 
00314 DWORD _import GetASPI32SupportInfo( void );
00315 DWORD _import SendASPI32Command( LPSRB );
00316 BOOL _import GetASPI32Buffer( PASPI32BUFF );
00317 BOOL _import FreeASPI32Buffer( PASPI32BUFF );
00318 BOOL _import TranslateASPI32Address( PDWORD, PDWORD );
00319 
00320 #elif defined(_MSC_VER)
00321 
00322 __declspec(dllimport) DWORD GetASPI32SupportInfo( void );
00323 __declspec(dllimport) DWORD SendASPI32Command( LPSRB );
00324 __declspec(dllimport) BOOL GetASPI32Buffer( PASPI32BUFF );
00325 __declspec(dllimport) BOOL FreeASPI32Buffer( PASPI32BUFF );
00326 __declspec(dllimport) BOOL TranslateASPI32Address( PDWORD, PDWORD );
00327 
00328 #else
00329 
00330 extern DWORD GetASPI32SupportInfo( void );
00331 extern DWORD GetASPI32Command( LPSRB );
00332 extern BOOL GetASPI32Buffer( PASPI32BUFF );
00333 extern BOOL FreeASPI32Buffer( PASPI32BUFF );
00334 extern BOOL TranslateASPI32Address( PDWORD, PDWORD );
00335 
00336 #endif
00337 
00338 /*
00339 ** Restore compiler default packing and close off the C declarations.
00340 */
00341 
00342 #ifdef __BORLANDC__
00343 #pragma option -a.
00344 #endif //__BORLANDC__
00345 
00346 #ifdef _MSC_VER
00347 #pragma pack()
00348 #endif //_MSC_VER
00349 
00350 #ifdef __cplusplus
00351 }
00352 #endif //__cplusplus
00353 
00354 #endif //__WNASPI32_H__