95 lines
2.8 KiB
C++
95 lines
2.8 KiB
C++
#ifndef __FREEBSDSCSI_H__
|
|
#define __FREEBSDSCSI_H__
|
|
|
|
|
|
#include <iostream>
|
|
#include <pthread.h>
|
|
#include <sys/signal.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/time.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h> /* File control definitions */
|
|
#include <errno.h> /* Error number definitions */
|
|
#include <unistd.h> /* fork() */
|
|
#include <netinet/in.h>
|
|
#include <netdb.h>
|
|
#include <stdarg.h>
|
|
#include <sys/ioctl.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <err.h>
|
|
|
|
#include <cam/cam.h>
|
|
#include <cam/cam_debug.h>
|
|
#include <cam/cam_ccb.h>
|
|
#include <cam/scsi/scsi_all.h>
|
|
#include <cam/scsi/scsi_da.h>
|
|
#include <cam/scsi/scsi_pass.h>
|
|
#include <cam/scsi/scsi_message.h>
|
|
#include <camlib.h>
|
|
|
|
|
|
#include "commdef.h"
|
|
#include "interface.h"
|
|
#include "arclib.h"
|
|
|
|
#define SCSI_INQUIRY 0x12
|
|
#define SCSI_WRITE_BUF 0x3B
|
|
#define SCSI_READ_BUF 0x3C
|
|
#define SENSE_LEN 14
|
|
#define CDB_SIZE 10
|
|
#define BUF_SIZE 2048
|
|
|
|
|
|
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
|
|
} sSENSE_DATA_FMT, *pSENSE_DATA_FMT;
|
|
|
|
class FreeBSDSCSIInterface : public ArcInterface
|
|
{
|
|
public:
|
|
FreeBSDSCSIInterface();
|
|
~FreeBSDSCSIInterface();
|
|
bool init(const int nScsiPort);
|
|
int send(sIF_CMD_BLOCK *ifData);
|
|
int recv(sIF_CMD_BLOCK *ifData);
|
|
int syncSend(sIF_CMD_BLOCK *ifData);
|
|
int syncSend(const char *outBuf, int outLen, char *inBuf, int inLen, void *extdata = 0);
|
|
void requirelock();
|
|
void releaselock();
|
|
int getMTU();
|
|
void *getDeviceHandle();
|
|
|
|
private:
|
|
HANDLE m_hScsi;
|
|
cam_device *arc_device;
|
|
int fd;
|
|
pthread_mutex_t mut;
|
|
};
|
|
|
|
#endif
|