Start to request sense data in DeviceIOControl of MS Windows. gnu_linux.c: small changes.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32_ioctl.c,v 1.30 2008/04/21 18:30:21 karl Exp $
|
$Id: win32_ioctl.c,v 1.30 2008/04/21 18:30:21 karl Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
|
Copyright (C) 2004, 2005, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -88,11 +88,11 @@ typedef struct _CDROM_TOC_FULL {
|
|||||||
} CDROM_TOC_FULL, *PCDROM_TOC_FULL;
|
} CDROM_TOC_FULL, *PCDROM_TOC_FULL;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SCSI_PASS_THROUGH Spt;
|
SCSI_PASS_THROUGH_DIRECT sptd;
|
||||||
ULONG Filler;
|
ULONG Filler;
|
||||||
UCHAR SenseBuf[32];
|
UCHAR ucSenseBuf[32];
|
||||||
UCHAR DataBuf[512];
|
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
|
||||||
} SCSI_PASS_THROUGH_WITH_BUFFERS;
|
|
||||||
|
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
|
||||||
@@ -434,32 +434,40 @@ run_mmc_cmd_win32ioctl( void *p_user_data,
|
|||||||
cdio_mmc_direction_t e_direction,
|
cdio_mmc_direction_t e_direction,
|
||||||
unsigned int i_buf, /*in/out*/ void *p_buf )
|
unsigned int i_buf, /*in/out*/ void *p_buf )
|
||||||
{
|
{
|
||||||
const _img_private_t *p_env = p_user_data;
|
_img_private_t *p_env = p_user_data;
|
||||||
SCSI_PASS_THROUGH_DIRECT sptd;
|
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
|
||||||
|
|
||||||
bool b_success;
|
bool b_success;
|
||||||
DWORD dw_bytes_returned;
|
DWORD dw_bytes_returned;
|
||||||
|
|
||||||
sptd.Length = sizeof(sptd);
|
|
||||||
sptd.PathId = 0; /* SCSI card ID will be filled in automatically */
|
|
||||||
sptd.TargetId= 0; /* SCSI target ID will also be filled in */
|
|
||||||
sptd.Lun=0; /* SCSI lun ID will also be filled in */
|
|
||||||
sptd.CdbLength = i_cdb;
|
|
||||||
sptd.SenseInfoLength = 0; /* Don't return any sense data */
|
|
||||||
sptd.DataIn = SCSI_MMC_DATA_READ == e_direction ?
|
|
||||||
SCSI_IOCTL_DATA_IN : SCSI_IOCTL_DATA_OUT;
|
|
||||||
sptd.DataTransferLength= i_buf;
|
|
||||||
sptd.TimeOutValue = msecs2secs(i_timeout_ms);
|
|
||||||
sptd.DataBuffer = (void *) p_buf;
|
|
||||||
sptd.SenseInfoOffset = 0;
|
|
||||||
|
|
||||||
memcpy(sptd.Cdb, p_cdb, i_cdb);
|
memset(&sptdwb, 0, sizeof(sptdwb));
|
||||||
|
|
||||||
|
sptdwb.sptd.Length = sizeof(sptdwb.sptd);
|
||||||
|
sptdwb.sptd.PathId = 0; /* SCSI card ID will be filled in
|
||||||
|
automatically */
|
||||||
|
sptdwb.sptd.TargetId= 0; /* SCSI target ID will also be filled in */
|
||||||
|
sptdwb.sptd.Lun = 0; /* SCSI lun ID will also be filled in */
|
||||||
|
sptdwb.sptd.CdbLength = i_cdb;
|
||||||
|
sptdwb.sptd.SenseInfoLength = sizeof(sptdwb.ucSenseBuf);
|
||||||
|
sptdwb.sptd.DataIn =
|
||||||
|
(SCSI_MMC_DATA_READ == e_direction) ? SCSI_IOCTL_DATA_IN :
|
||||||
|
(SCSI_MMC_DATA_WRITE == e_direction) ? SCSI_IOCTL_DATA_OUT :
|
||||||
|
SCSI_IOCTL_DATA_UNSPECIFIED;
|
||||||
|
sptdwb.sptd.DataTransferLength= i_buf;
|
||||||
|
sptdwb.sptd.TimeOutValue = msecs2secs(i_timeout_ms);
|
||||||
|
sptdwb.sptd.DataBuffer = (void *) p_buf;
|
||||||
|
sptdwb.sptd.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,
|
||||||
|
ucSenseBuf);
|
||||||
|
|
||||||
|
memcpy(sptdwb.sptd.Cdb, p_cdb, i_cdb);
|
||||||
|
|
||||||
/* Send the command to drive */
|
/* Send the command to drive */
|
||||||
b_success = DeviceIoControl(p_env->h_device_handle,
|
b_success = DeviceIoControl(p_env->h_device_handle,
|
||||||
IOCTL_SCSI_PASS_THROUGH_DIRECT,
|
IOCTL_SCSI_PASS_THROUGH_DIRECT,
|
||||||
(void *)&sptd,
|
(void *)&sptdwb,
|
||||||
(DWORD)sizeof(SCSI_PASS_THROUGH_DIRECT),
|
(DWORD)sizeof(sptdwb),
|
||||||
NULL, 0,
|
&sptdwb,
|
||||||
|
(DWORD)sizeof(sptdwb),
|
||||||
&dw_bytes_returned,
|
&dw_bytes_returned,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
@@ -474,6 +482,19 @@ run_mmc_cmd_win32ioctl( void *p_user_data,
|
|||||||
LocalFree(psz_msg);
|
LocalFree(psz_msg);
|
||||||
return DRIVER_OP_ERROR;
|
return DRIVER_OP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Record SCSI sense reply for API call mmc_last_cmd_sense().
|
||||||
|
*/
|
||||||
|
if (sptdwb.ucSenseBuf[7]) {
|
||||||
|
int sense_size = sptdwb.ucSenseBuf[7] + 8; /* SPC 4.5.3, Table 26:
|
||||||
|
252 bytes legal, 263 bytes
|
||||||
|
possible */
|
||||||
|
if (sense_size > sizeof(sptdwb.ucSenseBuf))
|
||||||
|
sense_size = sizeof(sptdwb.ucSenseBuf);
|
||||||
|
memcpy((void *) p_env->gen.scsi_mmc_sense, &sptdwb.ucSenseBuf, sense_size);
|
||||||
|
p_env->gen.scsi_mmc_sense_valid = sense_size;
|
||||||
|
}
|
||||||
|
|
||||||
return DRIVER_OP_SUCCESS;
|
return DRIVER_OP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1239,19 +1239,15 @@ run_mmc_cmd_linux(void *p_user_data,
|
|||||||
struct cdrom_generic_command cgc;
|
struct cdrom_generic_command cgc;
|
||||||
struct request_sense sense;
|
struct request_sense sense;
|
||||||
unsigned char *u_sense = (unsigned char *) &sense;
|
unsigned char *u_sense = (unsigned char *) &sense;
|
||||||
int sense_size;
|
|
||||||
|
|
||||||
p_env->gen.scsi_mmc_sense_valid = 0;
|
p_env->gen.scsi_mmc_sense_valid = 0;
|
||||||
memset (&cgc, 0, sizeof (struct cdrom_generic_command));
|
memset (&cgc, 0, sizeof (struct cdrom_generic_command));
|
||||||
memcpy(&cgc.cmd, p_cdb, i_cdb);
|
memcpy(&cgc.cmd, p_cdb, i_cdb);
|
||||||
cgc.buflen = i_buf;
|
cgc.buflen = i_buf;
|
||||||
cgc.buffer = p_buf;
|
cgc.buffer = p_buf;
|
||||||
|
cgc.sense = &sense;
|
||||||
|
|
||||||
cgc.sense = &sense;
|
cgc.data_direction = (SCSI_MMC_DATA_READ == e_direction) ? CGC_DATA_READ :
|
||||||
|
|
||||||
if (SCSI_MMC_DATA_NONE == e_direction)
|
|
||||||
i_buf = 0;
|
|
||||||
cgc.data_direction = (SCSI_MMC_DATA_READ == e_direction) ? CGC_DATA_READ :
|
|
||||||
(SCSI_MMC_DATA_WRITE == e_direction) ? CGC_DATA_WRITE :
|
(SCSI_MMC_DATA_WRITE == e_direction) ? CGC_DATA_WRITE :
|
||||||
CGC_DATA_NONE;
|
CGC_DATA_NONE;
|
||||||
|
|
||||||
@@ -1266,8 +1262,9 @@ run_mmc_cmd_linux(void *p_user_data,
|
|||||||
/* Record SCSI sense reply for API call mmc_last_cmd_sense().
|
/* Record SCSI sense reply for API call mmc_last_cmd_sense().
|
||||||
*/
|
*/
|
||||||
if (u_sense[7]) {
|
if (u_sense[7]) {
|
||||||
sense_size = u_sense[7] + 8; /* SPC 4.5.3, Table 26:
|
int sense_size = u_sense[7] + 8; /* SPC 4.5.3, Table 26:
|
||||||
252 bytes legal, 263 bytes possible */
|
252 bytes legal, 263 bytes
|
||||||
|
possible */
|
||||||
if (sense_size > sizeof(sense))
|
if (sense_size > sizeof(sense))
|
||||||
sense_size = sizeof(sense);
|
sense_size = sizeof(sense);
|
||||||
memcpy((void *) p_env->gen.scsi_mmc_sense, &sense, sense_size);
|
memcpy((void *) p_env->gen.scsi_mmc_sense, &sense, sense_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user