Removed obsolete ASPI cdrom access code for Win9x/ME

This commit is contained in:
Volker Ruppert 2013-10-22 19:46:46 +00:00
parent 70d91b179b
commit 519b369f56
4 changed files with 18 additions and 664 deletions

View File

@ -1,210 +0,0 @@
//
// iodev/aspi-win32.h
// $Id$
//
// This file was copied from cdrecord 1.9 under libscg/scg/aspi-win32.h.
// The only modification is related to use of the PACKED keyword.
//
#ifndef __ASPI_WIN32_H_
#define __ASPI_WIN32_H_
#include <windows.h>
#ifndef PACKED
// It seems that VC++ has no PACKED keyword but Cygwin does. We can just
// define PACKED to be empty if it's not already defined by the system
// headers.
#define PACKED /* empty */
#endif
/***************************************************************************
** SCSI MISCELLANEOUS EQUATES
***************************************************************************/
#define SENSE_LEN 14 /* Default sense buffer length */
#define SRB_DIR_SCSI 0x00 /* Direction determined by SCSI */
#define SRB_POSTING 0x01 /* Enable ASPI posting */
#define SRB_ENABLE_RESIDUAL_COUNT 0x04 /* Enable residual byte count */
/* reporting */
#define SRB_DIR_IN 0x08 /* Transfer from SCSI target to */
/* host */
#define SRB_DIR_OUT 0x10 /* Transfer from host to SCSI */
/* target */
#define SRB_EVENT_NOTIFY 0x40 /* Enable ASPI event notification */
#define RESIDUAL_COUNT_SUPPORTED 0x02 /* Extended buffer flag */
#define MAX_SRB_TIMEOUT 1080001u /* 30 hour maximum timeout in sec */
#define DEFAULT_SRB_TIMEOUT 1080001u /* use max.timeout by default */
/***************************************************************************
** ASPI command definitions
***************************************************************************/
#define SC_HA_INQUIRY 0x00 /* Host adapter inquiry */
#define SC_GET_DEV_TYPE 0x01 /* Get device type */
#define SC_EXEC_SCSI_CMD 0x02 /* Execute SCSI command */
#define SC_ABORT_SRB 0x03 /* Abort an SRB */
#define SC_RESET_DEV 0x04 /* SCSI bus device reset */
#define SC_SET_HA_PARMS 0x05 /* Set HA parameters */
#define SC_GET_DISK_INFO 0x06 /* Get Disk */
#define SC_RESCAN_SCSI_BUS 0x07 /* Rebuild SCSI device map */
#define SC_GETSET_TIMEOUTS 0x08 /* Get/Set target timeouts */
/***************************************************************************
** SRB Status
***************************************************************************/
#define SS_PENDING 0x00 /* SRB being processed */
#define SS_COMP 0x01 /* SRB completed without error */
#define SS_ABORTED 0x02 /* SRB aborted */
#define SS_ABORT_FAIL 0x03 /* Unable to abort SRB */
#define SS_ERR 0x04 /* SRB completed with error */
#define SS_INVALID_CMD 0x80 /* Invalid ASPI command */
#define SS_INVALID_HA 0x81 /* Invalid host adapter number */
#define SS_NO_DEVICE 0x82 /* SCSI device not installed */
#define SS_INVALID_SRB 0xE0 /* Invalid parameter set in SRB */
#define SS_OLD_MANAGER 0xE1 /* ASPI manager doesn't support */
/* windows */
#define SS_BUFFER_ALIGN 0xE1 /* Buffer not aligned (replaces */
/* SS_OLD_MANAGER in Win32) */
#define SS_ILLEGAL_MODE 0xE2 /* Unsupported Windows mode */
#define SS_NO_ASPI 0xE3 /* No ASPI managers */
#define SS_FAILED_INIT 0xE4 /* ASPI for windows failed init */
#define SS_ASPI_IS_BUSY 0xE5 /* No resources available to */
/* execute command */
#define SS_BUFFER_TO_BIG 0xE6 /* Buffer size too big to handle */
#define SS_BUFFER_TOO_BIG 0xE6 /* Correct spelling of 'too' */
#define SS_MISMATCHED_COMPONENTS 0xE7 /* The DLLs/EXEs of ASPI don't */
/* version check */
#define SS_NO_ADAPTERS 0xE8 /* No host adapters to manager */
#define SS_INSUFFICIENT_RESOURCES 0xE9 /* Couldn't allocate resources */
/* needed to init */
#define SS_ASPI_IS_SHUTDOWN 0xEA /* Call came to ASPI after */
/* PROCESS_DETACH */
#define SS_BAD_INSTALL 0xEB /* The DLL or other components */
/* are installed wrong */
/***************************************************************************
** Host Adapter Status
***************************************************************************/
#define HASTAT_OK 0x00 /* No error detected by HA */
#define HASTAT_SEL_TO 0x11 /* Selection Timeout */
#define HASTAT_DO_DU 0x12 /* Data overrun/data underrun */
#define HASTAT_BUS_FREE 0x13 /* Unexpected bus free */
#define HASTAT_PHASE_ERR 0x14 /* Target bus phase sequence */
#define HASTAT_TIMEOUT 0x09 /* Timed out while SRB was */
/* waiting to be processed */
#define HASTAT_COMMAND_TIMEOUT 0x0B /* Adapter timed out while */
/* processing SRB */
#define HASTAT_MESSAGE_REJECT 0x0D /* While processing the SRB, the */
/* adapter received a MESSAGE */
#define HASTAT_BUS_RESET 0x0E /* A bus reset was detected */
#define HASTAT_PARITY_ERROR 0x0F /* A parity error was detected */
#define HASTAT_REQUEST_SENSE_FAILED 0x10 /* The adapter failed in issuing */
/***************************************************************************
** SRB - HOST ADAPTER INQUIRIY - SC_HA_INQUIRY (0)
***************************************************************************/
typedef struct {
BYTE SRB_Cmd; /* 00/000 ASPI command code == SC_HA_INQUIRY */
BYTE SRB_Status; /* 01/001 ASPI command status byte */
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
BYTE SRB_Flags; /* 03/003 ASPI request flags */
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
BYTE HA_Count; /* 08/008 Number of host adapters present */
BYTE HA_SCSI_ID; /* 09/009 SCSI ID of host adapter */
BYTE HA_ManagerId[16]; /* 0a/010 String describing the manager */
BYTE HA_Identifier[16]; /* 1a/026 String describing the host adapter */
BYTE HA_Unique[16]; /* 2a/042 Host Adapter Unique parameters */
WORD HA_Rsvd1; /* 3a/058 Reserved, must = 0 */
} PACKED SRB_HAInquiry, *PSRB_HAInquiry, FAR *LPSRB_HAInquiry;
/***************************************************************************
** SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE (1)
***************************************************************************/
typedef struct
{
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_GET_DEV_TYPE */
BYTE SRB_Status; /* 01/001 ASPI command status byte */
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
BYTE SRB_Lun; /* 09/009 Target's LUN number */
BYTE SRB_DeviceType; /* 0a/010 Target's peripheral device type */
BYTE SRB_Rsvd1; /* 0b/011 Reserved, must = 0 */
} PACKED SRB_GDEVBlock, *PSRB_GDEVBlock, FAR *LPSRB_GDEVBlock;
/***************************************************************************
** SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD (2)
***************************************************************************/
typedef struct
{
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_EXEC_SCSI_CMD */
BYTE SRB_Status; /* 01/001 ASPI command status byte */
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
BYTE SRB_Lun; /* 09/009 Target's LUN */
WORD SRB_Rsvd1; /* 0a/010 Reserved for alignment */
DWORD SRB_BufLen; /* 0c/012 Data Allocation Length */
BYTE FAR *SRB_BufPointer; /* 10/016 Data Buffer Pointer */
BYTE SRB_SenseLen; /* 14/020 Sense Allocation Length */
BYTE SRB_CDBLen; /* 15/021 CDB Length */
BYTE SRB_HaStat; /* 16/022 Host Adapter Status */
BYTE SRB_TargStat; /* 17/023 Target Status */
VOID FAR *SRB_PostProc; /* 18/024 Post routine */
BYTE SRB_Rsvd2[20]; /* 1c/028 Reserved, must = 0 */
BYTE CDBByte[16]; /* 30/048 SCSI CDB */
BYTE SenseArea[SENSE_LEN+2]; /* 40/064 Request Sense buffer */
} PACKED SRB_ExecSCSICmd, *PSRB_ExecSCSICmd, FAR *LPSRB_ExecSCSICmd;
typedef struct
{
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_ABORT_SRB */
BYTE SRB_Status; /* 01/001 ASPI command status byte */
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
BYTE SRB_Flags; /* 03/003 Reserved, must = 0 */
DWORD SRB_Hdr_Rsvd; /* 04/004 Reserved, must = 0 */
void *SRB_ToAbort; /* 08/008 Pointer to SRB to abort */
} PACKED SRB_Abort, *PSRB_Abort, FAR *LPSRB_Abort;
/***************************************************************************
** SRB - BUS DEVICE RESET - SC_RESET_DEV (4)
***************************************************************************/
typedef struct
{
BYTE SRB_Cmd; /* 00/000 ASPI cmd code == SC_RESET_DEV */
BYTE SRB_Status; /* 01/001 ASPI command status byte */
BYTE SRB_HaId; /* 02/002 ASPI host adapter number */
DWORD SRB_Flags; /* 04/004 Reserved */
BYTE SRB_Target; /* 08/008 Target's SCSI ID */
BYTE SRB_Lun; /* 09/009 Target's LUN number */
BYTE SRB_Rsvd1[12]; /* 0A/010 Reserved for alignment */
BYTE SRB_HaStat; /* 16/022 Host Adapter Status */
BYTE SRB_TargStat; /* 17/023 Target Status */
VOID FAR *SRB_PostProc; /* 18/024 Post routine */
BYTE SRB_Rsvd2[36]; /* 1C/028 Reserved, must = 0 */
} SRB_BusDeviceReset, *PSRB_BusDeviceReset, FAR *LPSRB_BusDeviceReset;
typedef struct tag_ASPI32BUFF
{
PBYTE AB_BufPointer;
DWORD AB_BufLen;
DWORD AB_ZeroFill;
DWORD AB_Reserved;
} PACKED ASPI32BUFF, *PASPI32BUFF, FAR *LPASPI32BUFF;
typedef struct
{
BYTE SRB_Cmd;
BYTE SRB_Status;
BYTE SRB_HaId;
BYTE SRB_Flags;
DWORD SRB_Hdr_Rsvd;
} SRB, *PSRB, FAR *LPSRB;
#endif

View File

@ -72,13 +72,9 @@ private:
int fd;
char *path;
int using_file;
bx_bool using_file;
#ifdef WIN32
BOOL bUseASPI;
HANDLE hFile;
int hid;
int tid;
int lun;
#endif
#if BX_WITH_AMIGAOS
BPTR fda;

View File

@ -44,22 +44,11 @@ extern "C" {
#if defined(WIN32)
// windows.h included by bochs.h
#include <winioctl.h>
#include "aspi-win32.h"
#include "scsidefs.h"
DWORD (*GetASPI32SupportInfo)(void);
DWORD (*SendASPI32Command)(LPSRB);
BOOL (*GetASPI32Buffer)(PASPI32BUFF);
BOOL (*FreeASPI32Buffer)(PASPI32BUFF);
BOOL (*TranslateASPI32Address)(PDWORD,PDWORD);
DWORD (*GetASPI32DLLVersion)(void);
static OSVERSIONINFO osinfo;
static BOOL isWindowsXP;
static BOOL bHaveDev;
static BOOL isOldWindows;
static UINT cdromCount = 0;
static HINSTANCE hASPI = NULL;
#define BX_CD_FRAMESIZE 2048
#define CD_FRAMESIZE 2048
@ -111,86 +100,12 @@ typedef struct _CDROM_TOC_SESSION_DATA {
#include <stdio.h>
bool ReadCDSector(unsigned int hid, unsigned int tid, unsigned int lun, unsigned long frame, unsigned char *buf, int bufsize)
{
HANDLE hEventSRB;
SRB_ExecSCSICmd srb;
DWORD dwStatus;
hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL);
memset(&srb,0,sizeof(SRB_ExecSCSICmd));
srb.SRB_Cmd = SC_EXEC_SCSI_CMD;
srb.SRB_HaId = hid;
srb.SRB_Target = tid;
srb.SRB_Lun = lun;
srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
srb.SRB_SenseLen = SENSE_LEN;
srb.SRB_PostProc = hEventSRB;
srb.SRB_BufPointer = buf;
srb.SRB_BufLen = bufsize;
srb.SRB_CDBLen = 10;
srb.CDBByte[0] = SCSI_READ10;
srb.CDBByte[2] = (unsigned char) (frame>>24);
srb.CDBByte[3] = (unsigned char) (frame>>16);
srb.CDBByte[4] = (unsigned char) (frame>>8);
srb.CDBByte[5] = (unsigned char) (frame);
srb.CDBByte[7] = 0;
srb.CDBByte[8] = 1; /* read 1 frames */
ResetEvent(hEventSRB);
dwStatus = SendASPI32Command((SRB *)&srb);
if(dwStatus == SS_PENDING) {
WaitForSingleObject(hEventSRB, 100000);
}
CloseHandle(hEventSRB);
return (srb.SRB_TargStat == STATUS_GOOD);
}
int GetCDCapacity(unsigned int hid, unsigned int tid, unsigned int lun)
{
HANDLE hEventSRB;
SRB_ExecSCSICmd srb;
DWORD dwStatus;
unsigned char buf[8];
hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL);
memset(&buf, 0, sizeof(buf));
memset(&srb,0,sizeof(SRB_ExecSCSICmd));
srb.SRB_Cmd = SC_EXEC_SCSI_CMD;
srb.SRB_HaId = hid;
srb.SRB_Target = tid;
srb.SRB_Lun = lun;
srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
srb.SRB_SenseLen = SENSE_LEN;
srb.SRB_PostProc = hEventSRB;
srb.SRB_BufPointer = (unsigned char *)buf;
srb.SRB_BufLen = 8;
srb.SRB_CDBLen = 10;
srb.CDBByte[0] = SCSI_READCDCAP;
srb.CDBByte[2] = 0;
srb.CDBByte[3] = 0;
srb.CDBByte[4] = 0;
srb.CDBByte[5] = 0;
srb.CDBByte[8] = 0;
ResetEvent(hEventSRB);
dwStatus = SendASPI32Command((SRB *)&srb);
if(dwStatus == SS_PENDING) {
WaitForSingleObject(hEventSRB, 100000);
}
CloseHandle(hEventSRB);
return ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]) * ((buf[4] << 24) + (buf[5] << 16) + (buf[6] << 8) + buf[7]);
}
static unsigned int cdrom_count = 0;
cdrom_interface::cdrom_interface(const char *dev)
{
char prefix[6];
OSVERSIONINFO osinfo;
sprintf(prefix, "CD%d", ++cdrom_count);
put(prefix);
@ -202,11 +117,11 @@ cdrom_interface::cdrom_interface(const char *dev)
path = strdup(dev);
}
using_file=0;
bUseASPI = FALSE;
osinfo.dwOSVersionInfoSize = sizeof(osinfo);
GetVersionEx(&osinfo);
isWindowsXP = (osinfo.dwMajorVersion > 5) ||
((osinfo.dwMajorVersion == 5) && (osinfo.dwMinorVersion >= 1));
isOldWindows = (osinfo.dwPlatformId != VER_PLATFORM_WIN32_NT);
}
cdrom_interface::~cdrom_interface(void)
@ -222,11 +137,11 @@ bx_bool cdrom_interface::insert_cdrom(const char *dev)
// Load CD-ROM. Returns 0 if CD is not ready.
if (dev != NULL) path = strdup(dev);
BX_INFO (("load cdrom with path=%s", path));
BX_INFO (("load cdrom with path='%s'", path));
char drive[256];
if ((path[1] == ':') && (strlen(path) == 2))
{
if(osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if (!isOldWindows) {
// Use direct device access under windows NT/2k/XP
// With all the backslashes it's hard to see, but to open D: drive
@ -234,77 +149,17 @@ bx_bool cdrom_interface::insert_cdrom(const char *dev)
sprintf(drive, "\\\\.\\%s", path);
BX_INFO (("Using direct access for cdrom."));
// This trick only works for Win2k and WinNT, so warn the user of that.
using_file = 0;
} else {
BX_INFO(("Using ASPI for cdrom. Drive letters are unused yet."));
bUseASPI = TRUE;
BX_ERROR(("Your Windows version is no longer supported for direct access."));
return 0;
}
using_file = 0;
}
else
{
} else {
strcpy(drive,path);
using_file = 1;
BX_INFO (("Opening image file as a cd"));
}
if(bUseASPI) {
DWORD d;
UINT cdr, cnt, max;
UINT i, j, k;
SRB_HAInquiry sh;
SRB_GDEVBlock sd;
if (!hASPI) {
hASPI = LoadLibrary("WNASPI32.DLL");
if (hASPI) {
SendASPI32Command = (DWORD(*)(LPSRB))GetProcAddress(hASPI, "SendASPI32Command");
GetASPI32DLLVersion = (DWORD(*)(void))GetProcAddress(hASPI, "GetASPI32DLLVersion");
GetASPI32SupportInfo = (DWORD(*)(void))GetProcAddress(hASPI, "GetASPI32SupportInfo");
d = GetASPI32DLLVersion();
BX_INFO(("WNASPI32.DLL version %d.%02d initialized", d & 0xff, (d >> 8) & 0xff));
} else {
BX_PANIC(("Could not load ASPI drivers, so cdrom access will fail"));
return 0;
}
}
cdr = 0;
bHaveDev = FALSE;
d = GetASPI32SupportInfo();
cnt = LOBYTE(LOWORD(d));
for(i = 0; i < cnt; i++) {
memset(&sh, 0, sizeof(sh));
sh.SRB_Cmd = SC_HA_INQUIRY;
sh.SRB_HaId = i;
SendASPI32Command((LPSRB)&sh);
if(sh.SRB_Status != SS_COMP)
continue;
max = (int)sh.HA_Unique[3];
for(j = 0; j < max; j++) {
for(k = 0; k < 8; k++) {
memset(&sd, 0, sizeof(sd));
sd.SRB_Cmd = SC_GET_DEV_TYPE;
sd.SRB_HaId = i;
sd.SRB_Target = j;
sd.SRB_Lun = k;
SendASPI32Command((LPSRB)&sd);
if(sd.SRB_Status == SS_COMP) {
if(sd.SRB_DeviceType == DTYPE_CDROM) {
cdr++;
if(cdr > cdromCount) {
hid = i;
tid = j;
lun = k;
cdromCount++;
bHaveDev = TRUE;
}
}
}
if(bHaveDev) break;
}
if(bHaveDev) break;
}
}
fd=1;
} else {
if (!isOldWindows) {
hFile=CreateFile((char *)&drive, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
if (hFile !=(void *)0xFFFFFFFF)
fd=1;
@ -341,7 +196,7 @@ void cdrom_interface::eject_cdrom()
if (fd >= 0) {
if (using_file == 0) {
if (!bUseASPI) {
if (!isOldWindows) {
DWORD lpBytesReturned;
DeviceIoControl(hFile, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &lpBytesReturned, NULL);
}
@ -365,8 +220,7 @@ bx_bool cdrom_interface::read_toc(Bit8u* buf, int* length, bx_bool msf, int star
}
// the implementation below is the platform-dependent code required
// to read the TOC from a physical cdrom.
if (isWindowsXP)
{
if (isWindowsXP) {
// This only works with WinXP
CDROM_READ_TOC_EX input;
memset(&input, 0, sizeof(input));
@ -394,13 +248,11 @@ Bit32u cdrom_interface::capacity()
// Return CD-ROM capacity. I believe you want to return
// the number of blocks of capacity the actual media has.
if (bUseASPI) {
return ((GetCDCapacity(hid, tid, lun) / 2352) + 1);
} else if (using_file) {
if (using_file) {
ULARGE_INTEGER FileSize;
FileSize.LowPart = GetFileSize(hFile, &FileSize.HighPart);
return (Bit32u)(FileSize.QuadPart / 2048);
} else { /* direct device access */
} else if (!isOldWindows) { /* direct device access */
if (isWindowsXP) {
LARGE_INTEGER length;
DWORD iBytesReturned;
@ -413,6 +265,8 @@ Bit32u cdrom_interface::capacity()
GetDiskFreeSpaceEx(path, &FreeBytesForCaller, &TotalNumOfBytes, &TotalFreeBytes);
return (Bit32u)(TotalNumOfBytes.QuadPart / 2048);
}
} else {
return 0;
}
}
@ -438,10 +292,7 @@ bx_bool BX_CPP_AttrRegparmN(3) cdrom_interface::read_block(Bit8u* buf, Bit32u lb
buf1 = buf;
}
do {
if(bUseASPI) {
ReadCDSector(hid, tid, lun, lba, buf1, BX_CD_FRAMESIZE);
n = BX_CD_FRAMESIZE;
} else {
if (using_file || !isOldWindows) {
pos.QuadPart = (LONGLONG)lba*BX_CD_FRAMESIZE;
pos.LowPart = SetFilePointer(hFile, pos.LowPart, &pos.HighPart, SEEK_SET);
if ((pos.LowPart == 0xffffffff) && (GetLastError() != NO_ERROR)) {

View File

@ -1,283 +0,0 @@
/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// iodev/scsidefs.h
//
// This file was copied from ... ?
//
//***************************************************************************
// Name: SCSIDEFS.H
//
// Description: SCSI definitions ('C' Language)
//***************************************************************************
//***************************************************************************
// %%% TARGET STATUS VALUES %%%
//***************************************************************************
#define STATUS_GOOD 0x00 // Status Good
#define STATUS_CHKCOND 0x02 // Check Condition
#define STATUS_CONDMET 0x04 // Condition Met
#define STATUS_BUSY 0x08 // Busy
#define STATUS_INTERM 0x10 // Intermediate
#define STATUS_INTCDMET 0x14 // Intermediate-condition met
#define STATUS_RESCONF 0x18 // Reservation conflict
#define STATUS_COMTERM 0x22 // Command Terminated
#define STATUS_QFULL 0x28 // Queue full
//***************************************************************************
// %%% SCSI MISCELLANEOUS EQUATES %%%
//***************************************************************************
#define MAXLUN 7 // Maximum Logical Unit Id
#define MAXTARG 7 // Maximum Target Id
#define MAX_SCSI_LUNS 64 // Maximum Number of SCSI LUNs
#define MAX_NUM_HA 8 // Maximum Number of SCSI HA's
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
//
// %%% SCSI COMMAND OPCODES %%%
//
///\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
//***************************************************************************
// %%% Commands for all Device Types %%%
//***************************************************************************
#define SCSI_CHANGE_DEF 0x40 // Change Definition (Optional)
#define SCSI_COMPARE 0x39 // Compare (O)
#define SCSI_COPY 0x18 // Copy (O)
#define SCSI_COP_VERIFY 0x3A // Copy and Verify (O)
#define SCSI_INQUIRY 0x12 // Inquiry (MANDATORY)
#define SCSI_LOG_SELECT 0x4C // Log Select (O)
#define SCSI_LOG_SENSE 0x4D // Log Sense (O)
#define SCSI_MODE_SEL6 0x15 // Mode Select 6-byte (Device Specific)
#define SCSI_MODE_SEL10 0x55 // Mode Select 10-byte (Device Specific)
#define SCSI_MODE_SEN6 0x1A // Mode Sense 6-byte (Device Specific)
#define SCSI_MODE_SEN10 0x5A // Mode Sense 10-byte (Device Specific)
#define SCSI_READ_BUFF 0x3C // Read Buffer (O)
#define SCSI_REQ_SENSE 0x03 // Request Sense (MANDATORY)
#define SCSI_SEND_DIAG 0x1D // Send Diagnostic (O)
#define SCSI_TST_U_RDY 0x00 // Test Unit Ready (MANDATORY)
#define SCSI_WRITE_BUFF 0x3B // Write Buffer (O)
//***************************************************************************
// %%% Commands Unique to Direct Access Devices %%%
//***************************************************************************
#define SCSI_COMPARE 0x39 // Compare (O)
#define SCSI_FORMAT 0x04 // Format Unit (MANDATORY)
#define SCSI_LCK_UN_CAC 0x36 // Lock Unlock Cache (O)
#define SCSI_PREFETCH 0x34 // Prefetch (O)
#define SCSI_MED_REMOVL 0x1E // Prevent/Allow medium Removal (O)
#define SCSI_READ6 0x08 // Read 6-byte (MANDATORY)
#define SCSI_READ10 0x28 // Read 10-byte (MANDATORY)
#define SCSI_RD_CAPAC 0x25 // Read Capacity (MANDATORY)
#define SCSI_RD_DEFECT 0x37 // Read Defect Data (O)
#define SCSI_READ_LONG 0x3E // Read Long (O)
#define SCSI_REASS_BLK 0x07 // Reassign Blocks (O)
#define SCSI_RCV_DIAG 0x1C // Receive Diagnostic Results (O)
#define SCSI_RELEASE 0x17 // Release Unit (MANDATORY)
#define SCSI_REZERO 0x01 // Rezero Unit (O)
#define SCSI_SRCH_DAT_E 0x31 // Search Data Equal (O)
#define SCSI_SRCH_DAT_H 0x30 // Search Data High (O)
#define SCSI_SRCH_DAT_L 0x32 // Search Data Low (O)
#define SCSI_SEEK6 0x0B // Seek 6-Byte (O)
#define SCSI_SEEK10 0x2B // Seek 10-Byte (O)
#define SCSI_SEND_DIAG 0x1D // Send Diagnostics (MANDATORY)
#define SCSI_SET_LIMIT 0x33 // Set Limits (O)
#define SCSI_START_STP 0x1B // Start/Stop Unit (O)
#define SCSI_SYNC_CACHE 0x35 // Synchronize Cache (O)
#define SCSI_VERIFY 0x2F // Verify (O)
#define SCSI_WRITE6 0x0A // Write 6-Byte (MANDATORY)
#define SCSI_WRITE10 0x2A // Write 10-Byte (MANDATORY)
#define SCSI_WRT_VERIFY 0x2E // Write and Verify (O)
#define SCSI_WRITE_LONG 0x3F // Write Long (O)
#define SCSI_WRITE_SAME 0x41 // Write Same (O)
//***************************************************************************
// %%% Commands Unique to Sequential Access Devices %%%
//***************************************************************************
#define SCSI_ERASE 0x19 // Erase (MANDATORY)
#define SCSI_LOAD_UN 0x1B // Load/Unload (O)
#define SCSI_LOCATE 0x2B // Locate (O)
#define SCSI_RD_BLK_LIM 0x05 // Read Block Limits (MANDATORY)
#define SCSI_READ_POS 0x34 // Read Position (O)
#define SCSI_READ_REV 0x0F // Read Reverse (O)
#define SCSI_REC_BF_DAT 0x14 // Recover Buffer Data (O)
#define SCSI_RESERVE 0x16 // Reserve Unit (MANDATORY)
#define SCSI_REWIND 0x01 // Rewind (MANDATORY)
#define SCSI_SPACE 0x11 // Space (MANDATORY)
#define SCSI_VERIFY_T 0x13 // Verify (Tape) (O)
#define SCSI_WRT_FILE 0x10 // Write Filemarks (MANDATORY)
//***************************************************************************
// %%% Commands Unique to Printer Devices %%%
//***************************************************************************
#define SCSI_PRINT 0x0A // Print (MANDATORY)
#define SCSI_SLEW_PNT 0x0B // Slew and Print (O)
#define SCSI_STOP_PNT 0x1B // Stop Print (O)
#define SCSI_SYNC_BUFF 0x10 // Synchronize Buffer (O)
//***************************************************************************
// %%% Commands Unique to Processor Devices %%%
//***************************************************************************
#define SCSI_RECEIVE 0x08 // Receive (O)
#define SCSI_SEND 0x0A // Send (O)
//***************************************************************************
// %%% Commands Unique to Write-Once Devices %%%
//***************************************************************************
#define SCSI_MEDIUM_SCN 0x38 // Medium Scan (O)
#define SCSI_SRCHDATE10 0x31 // Search Data Equal 10-Byte (O)
#define SCSI_SRCHDATE12 0xB1 // Search Data Equal 12-Byte (O)
#define SCSI_SRCHDATH10 0x30 // Search Data High 10-Byte (O)
#define SCSI_SRCHDATH12 0xB0 // Search Data High 12-Byte (O)
#define SCSI_SRCHDATL10 0x32 // Search Data Low 10-Byte (O)
#define SCSI_SRCHDATL12 0xB2 // Search Data Low 12-Byte (O)
#define SCSI_SET_LIM_10 0x33 // Set Limits 10-Byte (O)
#define SCSI_SET_LIM_12 0xB3 // Set Limits 10-Byte (O)
#define SCSI_VERIFY10 0x2F // Verify 10-Byte (O)
#define SCSI_VERIFY12 0xAF // Verify 12-Byte (O)
#define SCSI_WRITE12 0xAA // Write 12-Byte (O)
#define SCSI_WRT_VER10 0x2E // Write and Verify 10-Byte (O)
#define SCSI_WRT_VER12 0xAE // Write and Verify 12-Byte (O)
//***************************************************************************
// %%% Commands Unique to CD-ROM Devices %%%
//***************************************************************************
#define SCSI_PLAYAUD_10 0x45 // Play Audio 10-Byte (O)
#define SCSI_PLAYAUD_12 0xA5 // Play Audio 12-Byte 12-Byte (O)
#define SCSI_PLAYAUDMSF 0x47 // Play Audio MSF (O)
#define SCSI_PLAYA_TKIN 0x48 // Play Audio Track/Index (O)
#define SCSI_PLYTKREL10 0x49 // Play Track Relative 10-Byte (O)
#define SCSI_PLYTKREL12 0xA9 // Play Track Relative 12-Byte (O)
#define SCSI_READCDCAP 0x25 // Read CD-ROM Capacity (MANDATORY)
#define SCSI_READHEADER 0x44 // Read Header (O)
#define SCSI_SUBCHANNEL 0x42 // Read Subchannel (O)
#define SCSI_READ_TOC 0x43 // Read TOC (O)
//***************************************************************************
// %%% Commands Unique to Scanner Devices %%%
//***************************************************************************
#define SCSI_GETDBSTAT 0x34 // Get Data Buffer Status (O)
#define SCSI_GETWINDOW 0x25 // Get Window (O)
#define SCSI_OBJECTPOS 0x31 // Object Postion (O)
#define SCSI_SCAN 0x1B // Scan (O)
#define SCSI_SETWINDOW 0x24 // Set Window (MANDATORY)
//***************************************************************************
// %%% Commands Unique to Optical Memory Devices %%%
//***************************************************************************
#define SCSI_UpdateBlk 0x3D // Update Block (O)
//***************************************************************************
// %%% Commands Unique to Medium Changer Devices %%%
//***************************************************************************
#define SCSI_EXCHMEDIUM 0xA6 // Exchange Medium (O)
#define SCSI_INITELSTAT 0x07 // Initialize Element Status (O)
#define SCSI_POSTOELEM 0x2B // Position to Element (O)
#define SCSI_REQ_VE_ADD 0xB5 // Request Volume Element Address (O)
#define SCSI_SENDVOLTAG 0xB6 // Send Volume Tag (O)
//***************************************************************************
// %%% Commands Unique to Communication Devices %%%
//***************************************************************************
#define SCSI_GET_MSG_6 0x08 // Get Message 6-Byte (MANDATORY)
#define SCSI_GET_MSG_10 0x28 // Get Message 10-Byte (O)
#define SCSI_GET_MSG_12 0xA8 // Get Message 12-Byte (O)
#define SCSI_SND_MSG_6 0x0A // Send Message 6-Byte (MANDATORY)
#define SCSI_SND_MSG_10 0x2A // Send Message 10-Byte (O)
#define SCSI_SND_MSG_12 0xAA // Send Message 12-Byte (O)
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
//
// %%% END OF SCSI COMMAND OPCODES %%%
//
///\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
//***************************************************************************
// %%% Request Sense Data Format %%%
//***************************************************************************
typedef struct {
BYTE ErrorCode; // Error Code (70H or 71H)
BYTE SegmentNum; // Number of current segment descriptor
BYTE SenseKey; // Sense Key(See bit definitions too)
BYTE InfoByte0; // Information MSB
BYTE InfoByte1; // Information MID
BYTE InfoByte2; // Information MID
BYTE InfoByte3; // Information LSB
BYTE AddSenLen; // Additional Sense Length
BYTE ComSpecInf0; // Command Specific Information MSB
BYTE ComSpecInf1; // Command Specific Information MID
BYTE ComSpecInf2; // Command Specific Information MID
BYTE ComSpecInf3; // Command Specific Information LSB
BYTE AddSenseCode; // Additional Sense Code
BYTE AddSenQual; // Additional Sense Code Qualifier
BYTE FieldRepUCode; // Field Replaceable Unit Code
BYTE SenKeySpec15; // Sense Key Specific 15th byte
BYTE SenKeySpec16; // Sense Key Specific 16th byte
BYTE SenKeySpec17; // Sense Key Specific 17th byte
BYTE AddSenseBytes; // Additional Sense Bytes
} SENSE_DATA_FMT;
//***************************************************************************
// %%% REQUEST SENSE ERROR CODE %%%
//***************************************************************************
#define SERROR_CURRENT 0x70 // Current Errors
#define SERROR_DEFERED 0x71 // Deferred Errors
//***************************************************************************
// %%% REQUEST SENSE BIT DEFINITIONS %%%
//***************************************************************************
#define SENSE_VALID 0x80 // Byte 0 Bit 7
#define SENSE_FILEMRK 0x80 // Byte 2 Bit 7
#define SENSE_EOM 0x40 // Byte 2 Bit 6
#define SENSE_ILI 0x20 // Byte 2 Bit 5
//***************************************************************************
// %%% REQUEST SENSE SENSE KEY DEFINITIONS %%%
//***************************************************************************
#define KEY_NOSENSE 0x00 // No Sense
#define KEY_RECERROR 0x01 // Recovered Error
#define KEY_NOTREADY 0x02 // Not Ready
#define KEY_MEDIUMERR 0x03 // Medium Error
#define KEY_HARDERROR 0x04 // Hardware Error
#define KEY_ILLGLREQ 0x05 // Illegal Request
#define KEY_UNITATT 0x06 // Unit Attention
#define KEY_DATAPROT 0x07 // Data Protect
#define KEY_BLANKCHK 0x08 // Blank Check
#define KEY_VENDSPEC 0x09 // Vendor Specific
#define KEY_COPYABORT 0x0A // Copy Abort
#define KEY_EQUAL 0x0C // Equal (Search)
#define KEY_VOLOVRFLW 0x0D // Volume Overflow
#define KEY_MISCOMP 0x0E // Miscompare (Search)
#define KEY_RESERVED 0x0F // Reserved
//***************************************************************************
// %%% PERIPHERAL DEVICE TYPE DEFINITIONS %%%
//***************************************************************************
#define DTYPE_DASD 0x00 // Disk Device
#define DTYPE_SEQD 0x01 // Tape Device
#define DTYPE_PRNT 0x02 // Printer
#define DTYPE_PROC 0x03 // Processor
#define DTYPE_WORM 0x04 // Write-once read-multiple
#define DTYPE_CROM 0x05 // CD-ROM device
#define DTYPE_CDROM 0x05 // CD-ROM device
#define DTYPE_SCAN 0x06 // Scanner device
#define DTYPE_OPTI 0x07 // Optical memory device
#define DTYPE_JUKE 0x08 // Medium Changer device
#define DTYPE_COMM 0x09 // Communications device
#define DTYPE_RESL 0x0A // Reserved (low)
#define DTYPE_RESH 0x1E // Reserved (high)
#define DTYPE_UNKNOWN 0x1F // Unknown or no device type
//***************************************************************************
// %%% ANSI APPROVED VERSION DEFINITIONS %%%
//***************************************************************************
#define ANSI_MAYBE 0x0 // Device may or may not be ANSI approved stand
#define ANSI_SCSI1 0x1 // Device complies to ANSI X3.131-1986 (SCSI-1)
#define ANSI_SCSI2 0x2 // Device complies to SCSI-2
#define ANSI_RESLO 0x3 // Reserved (low)
#define ANSI_RESHI 0x7 // Reserved (high)