winescsi.h 3.37 KB
Newer Older
1 2 3 4 5 6 7
#ifndef __WINESCSI_H__
#define __WINESCSI_H__

#ifdef linux
/* Copy of info from 2.2.x kernel */
#define SG_MAX_SENSE 16   /* too little, unlikely to change in 2.2.x */

8 9 10 11
#define SG_NEXT_CMD_LEN 0x2283  /* override SCSI command length with given
		   number on the next write() on this file descriptor */

/* This is what the linux kernel thinks.... */
12
static const unsigned char scsi_command_size[8] =
13 14 15 16 17
{
	6, 10, 10, 12,
	12, 12, 10, 10
};

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
struct sg_header
{
    int pack_len;    /* [o] reply_len (ie useless), ignored as input */
    int reply_len;   /* [i] max length of expected reply (inc. sg_header) */
    int pack_id;     /* [io] id number of packet (use ints >= 0) */
    int result;      /* [o] 0==ok, else (+ve) Unix errno (best ignored) */
    unsigned int twelve_byte:1; 
        /* [i] Force 12 byte command length for group 6 & 7 commands  */
    unsigned int target_status:5;   /* [o] scsi status from target */
    unsigned int host_status:8;     /* [o] host status (see "DID" codes) */
    unsigned int driver_status:8;   /* [o] driver status+suggestion */
    unsigned int other_flags:10;    /* unused */
    unsigned char sense_buffer[SG_MAX_SENSE]; /* [o] Output in 3 cases:
           when target_status is CHECK_CONDITION or 
           when target_status is COMMAND_TERMINATED or
           when (driver_status & DRIVER_SENSE) is true. */
};      /* This structure is 36 bytes long on i386 */

#define SCSI_OFF sizeof(struct sg_header)

#define SG_SET_TIMEOUT	0x2201
#define SG_GET_TIMEOUT	0x2202
#define SCSI_DEFAULT_TIMEOUT 6000*5 /* 5 minutes */
#endif


/* RegKey used for SCSI info under HKEY_DYN_DATA */
#define KEYNAME_SCSI "WineScsi"
46
#define KEYNAME_SCSI_CONTROLLERMAP "ControllerMap"
47 48 49 50 51 52 53 54 55 56 57 58 59 60

/* Function prototypes from dlls/wnaspi32/aspi.c */
void
SCSI_Init();

int
ASPI_GetNumControllers();

int
SCSI_OpenDevice( int h, int c, int t, int d );

int
SCSI_LinuxSetTimeout( int fd, int timeout );

61
#ifdef linux
62 63 64 65 66
BOOL
SCSI_LinuxDeviceIo( int fd,
		struct sg_header * lpvInBuffer, DWORD cbInBuffer,
		struct sg_header * lpvOutBuffer, DWORD cbOutBuffer,
		LPDWORD lpcbBytesReturned );
67 68 69

void
SCSI_Fix_CMD_LEN( int fd, int cmd, int len );
70
#endif
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

BOOL
SCSI_GetDeviceName(int h, int c, int t, int d, LPSTR devstr, LPDWORD lpcbData);

DWORD
ASPI_GetHCforController( int controller );

/*** This is where we throw some miscellaneous crap ***/

#define ASPI_POSTING(prb) (prb->SRB_Flags & 0x1)

/* WNASPI32/WINASPI defs */
#define HOST_TO_TARGET(prb) (((prb->SRB_Flags>>3) & 0x3) == 0x2)
#define TARGET_TO_HOST(prb) (((prb->SRB_Flags>>3) & 0x3) == 0x1)
#define NO_DATA_TRANSFERED(prb) (((prb->SRB_Flags>>3) & 0x3) == 0x3)


#define INQUIRY_VENDOR          8

#define MUSTEK_SCSI_AREA_AND_WINDOWS 0x04
#define MUSTEK_SCSI_READ_SCANNED_DATA 0x08
#define MUSTEK_SCSI_GET_IMAGE_STATUS 0x0f
#define MUSTEK_SCSI_ADF_AND_BACKTRACE 0x10
#define MUSTEK_SCSI_CCD_DISTANCE 0x11
#define MUSTEK_SCSI_START_STOP 0x1b


#define INQURIY_CMDLEN 6
#define INQURIY_REPLY_LEN 96
#define INQUIRY_VENDOR 8

#define SENSE_BUFFER(prb) (&prb->CDBByte[prb->SRB_CDBLen])

/* Just a container for seeing what devices are open */
struct ASPI_DEVICE_INFO {
    struct ASPI_DEVICE_INFO *   next;
    int                         fd;
    int                         hostId;
    int                         target;
    int                         lun;
};

typedef struct ASPI_DEVICE_INFO ASPI_DEVICE_INFO;

/*** End Miscellaneous crap ***/

#endif /* #ifndef __WINESCSI_H */