mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-18 03:57:50 -05:00
Move Seagate-specific CDB out of scsiapi
This commit is contained in:
@@ -39,7 +39,7 @@ void SeagateController::SetLED
|
||||
| Create buffer to hold RGB control data |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char data[14] = {0};
|
||||
data[0] = 0x0E; // size of data packet
|
||||
data[0] = 0x0E; /* size of data packet */
|
||||
data[1] = 0x00;
|
||||
data[2] = 0x01;
|
||||
data[3] = 0x09;
|
||||
@@ -49,7 +49,8 @@ void SeagateController::SetLED
|
||||
data[7] = 0x01;
|
||||
if(save)
|
||||
{
|
||||
data[8] = 0x03; // 0x00 for no save, 0x03 for save
|
||||
data[8] = 0x03; /* 0x00 for no save, 0x03 for */
|
||||
/* save */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -61,5 +62,27 @@ void SeagateController::SetLED
|
||||
data[12] = 0xFF;
|
||||
data[13] = 0xFF;
|
||||
|
||||
scsi_write(dev, data, 14);
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold CDB |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char cdb[12] = {0};
|
||||
cdb[0] = 0xD2;
|
||||
cdb[1] = 0x53; /* S */
|
||||
cdb[2] = 0x65; /* e */
|
||||
cdb[3] = 0x74; /* t */
|
||||
cdb[4] = 0x4C; /* L */
|
||||
cdb[5] = 0x65; /* e */
|
||||
cdb[6] = 0x64; /* d */
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x00;
|
||||
cdb[9] = 0x30;
|
||||
cdb[10] = 14; /* length of data packet */
|
||||
cdb[11] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| Create buffer to hold sense data |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
unsigned char sense[32] = {0};
|
||||
|
||||
scsi_write(dev, data, 14, cdb, 12, sense, 32);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void scsi_free_enumeration(struct scsi_device_info * devs);
|
||||
|
||||
struct scsi_device * scsi_open_path(const char *path);
|
||||
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t length);
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t data_length, const unsigned char * cdb, size_t cdb_length, unsigned char * sense, size_t sense_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -192,13 +192,11 @@ struct scsi_device * scsi_open_path(const char *path)
|
||||
return(device);
|
||||
}
|
||||
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t length)
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t data_length, const unsigned char * cdb, size_t cdb_length, unsigned char * sense, size_t sense_length)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create buffers to hold header, cdb, and sense |
|
||||
| Create buffer to hold header |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char cdb[12];
|
||||
unsigned char sense[32];
|
||||
struct sg_io_hdr header;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -206,34 +204,22 @@ int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t leng
|
||||
\*-----------------------------------------------------*/
|
||||
header.interface_id = 'S';
|
||||
header.dxfer_direction = SG_DXFER_TO_DEV;
|
||||
header.cmd_len = sizeof(cdb);
|
||||
header.mx_sb_len = sizeof(sense);
|
||||
header.cmd_len = cdb_length;
|
||||
header.mx_sb_len = sense_length;
|
||||
header.iovec_count = 0;
|
||||
header.dxfer_len = length;
|
||||
header.dxfer_len = data_length;
|
||||
header.dxferp = data;
|
||||
header.cmdp = cdb;
|
||||
header.sbp = sense;
|
||||
header.timeout = 20000;
|
||||
header.flags = 0;
|
||||
|
||||
cdb[0] = 0xD2;
|
||||
cdb[1] = 0x53;
|
||||
cdb[2] = 0x65;
|
||||
cdb[3] = 0x74;
|
||||
cdb[4] = 0x4C;
|
||||
cdb[5] = 0x65;
|
||||
cdb[6] = 0x64;
|
||||
cdb[7] = 0x00;
|
||||
cdb[8] = 0x00;
|
||||
cdb[9] = 0x30;
|
||||
cdb[10] = length;
|
||||
cdb[11] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send pass through command |
|
||||
\*-----------------------------------------------------*/
|
||||
ioctl(dev->fd, SG_IO, &header);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,7 +58,7 @@ struct scsi_device * scsi_open_path(const char *path)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t length)
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t data_length, const unsigned char * cdb, size_t cdb_length, unsigned char * sense, size_t sense_length)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ extern "C" {
|
||||
|
||||
void scsi_close(struct scsi_device * dev)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct scsi_device_info * scsi_enumerate(const char * vendor, const char * product)
|
||||
{
|
||||
struct scsi_device_info * ret_ptr = NULL;
|
||||
struct scsi_device_info * last_ptr = NULL;
|
||||
|
||||
|
||||
char buff[DEVBUFSIZE] = "";
|
||||
int char_count;
|
||||
|
||||
@@ -178,15 +178,20 @@ struct scsi_device * scsi_open_path(const char *path)
|
||||
return(device);
|
||||
}
|
||||
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t length)
|
||||
int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t data_length, const unsigned char * cdb, size_t cdb_length, unsigned char * sense, size_t sense_length)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create buffer to hold SCSI_PASS_THROUGH_DIRECT |
|
||||
| Size must be enough for the SCSI_PASS_THROUGH_DIRECT |
|
||||
| struct plus the sense data. Size of 80 bytes taken |
|
||||
| from captured data |
|
||||
| struct plus the sense data. |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char buffer[sizeof(SCSI_PASS_THROUGH_DIRECT) + 32] = {0};
|
||||
int buffer_length = (sizeof(SCSI_PASS_THROUGH_DIRECT) + sense_length);
|
||||
unsigned char * buffer = malloc(buffer_length);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out the buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buffer, 0, buffer_length);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create PSCSI_PASS_THROUGH_DIRECT pointer and point it |
|
||||
@@ -202,31 +207,34 @@ int scsi_write(struct scsi_device * dev, const unsigned char * data, size_t leng
|
||||
command->PathId = 0x00;
|
||||
command->TargetId = 0x00;
|
||||
command->Lun = 0x00;
|
||||
command->CdbLength = 0x0C;
|
||||
command->SenseInfoLength = 0x20;
|
||||
command->CdbLength = cdb_length;
|
||||
command->SenseInfoLength = sense_length;
|
||||
command->DataIn = SCSI_IOCTL_DATA_OUT;
|
||||
command->DataTransferLength = length;
|
||||
command->DataTransferLength = data_length;
|
||||
command->TimeOutValue = 0x00000014;
|
||||
command->DataBuffer = data;
|
||||
command->SenseInfoOffset = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||
|
||||
command->Cdb[0] = 0xD2;
|
||||
command->Cdb[1] = 0x53;
|
||||
command->Cdb[2] = 0x65;
|
||||
command->Cdb[3] = 0x74;
|
||||
command->Cdb[4] = 0x4C;
|
||||
command->Cdb[5] = 0x65;
|
||||
command->Cdb[6] = 0x64;
|
||||
command->Cdb[7] = 0x00;
|
||||
command->Cdb[8] = 0x00;
|
||||
command->Cdb[9] = 0x30;
|
||||
command->Cdb[10] = length;
|
||||
command->Cdb[11] = 0x00;
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy CDB and sense data into buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(command->Cdb, cdb, cdb_length);
|
||||
memcpy(&buffer[sizeof(SCSI_PASS_THROUGH_DIRECT)], sense, sense_length);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send pass through command |
|
||||
\*-----------------------------------------------------*/
|
||||
DeviceIoControl(dev->fd, IOCTL_SCSI_PASS_THROUGH_DIRECT, command, sizeof(buffer), command, sizeof(buffer), NULL, NULL);
|
||||
DeviceIoControl(dev->fd, IOCTL_SCSI_PASS_THROUGH_DIRECT, command, buffer_length, command, buffer_length, NULL, NULL);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy sense data out of buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(sense, &buffer[sizeof(SCSI_PASS_THROUGH_DIRECT)], sense_length);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Free the buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
free(buffer);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user