22
22
#include "VSCSIInternal.h"
24
int vscsiReqSenseOkSet(PVSCSIREQINT pVScsiReq)
26
if (pVScsiReq->cbSense < 14)
27
return SCSI_STATUS_OK;
29
AssertMsgReturn(pVScsiReq->pbSense, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
30
memset(pVScsiReq->pbSense, 0, pVScsiReq->cbSense);
32
pVScsiReq->pbSense[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
33
pVScsiReq->pbSense[2] = SCSI_SENSE_NONE;
34
pVScsiReq->pbSense[7] = 10;
35
pVScsiReq->pbSense[12] = SCSI_ASC_NONE;
36
pVScsiReq->pbSense[13] = SCSI_ASC_NONE; /* Should be ASCQ but it has the same value for success. */
24
void vscsiSenseInit(PVSCSISENSE pVScsiSense)
26
memset(pVScsiSense->abSenseBuf, 0, sizeof(pVScsiSense->abSenseBuf));
29
int vscsiReqSenseOkSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq)
31
memset(pVScsiSense->abSenseBuf, 0, sizeof(pVScsiSense->abSenseBuf));
33
pVScsiSense->abSenseBuf[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
34
pVScsiSense->abSenseBuf[2] = SCSI_SENSE_NONE;
35
pVScsiSense->abSenseBuf[7] = 10;
36
pVScsiSense->abSenseBuf[12] = SCSI_ASC_NONE;
37
pVScsiSense->abSenseBuf[13] = SCSI_ASC_NONE; /* Should be ASCQ but it has the same value for success. */
39
if (pVScsiReq->pbSense && pVScsiReq->cbSense)
40
memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense));
38
42
return SCSI_STATUS_OK;
41
int vscsiReqSenseErrorSet(PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC)
45
int vscsiReqSenseErrorSet(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC, uint8_t uSCSIASCQ)
43
AssertMsgReturn(pVScsiReq->cbSense >= 18, ("Sense buffer is not big enough\n"), SCSI_STATUS_OK);
44
AssertMsgReturn(pVScsiReq->pbSense, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
45
memset(pVScsiReq->pbSense, 0, pVScsiReq->cbSense);
46
pVScsiReq->pbSense[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
47
pVScsiReq->pbSense[2] = uSCSISenseKey;
48
pVScsiReq->pbSense[7] = 10;
49
pVScsiReq->pbSense[12] = uSCSIASC;
50
pVScsiReq->pbSense[13] = 0x00; /** @todo: Provide more info. */
47
memset(pVScsiSense->abSenseBuf, 0, sizeof(pVScsiSense->abSenseBuf));
48
pVScsiSense->abSenseBuf[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
49
pVScsiSense->abSenseBuf[2] = uSCSISenseKey;
50
pVScsiSense->abSenseBuf[7] = 10;
51
pVScsiSense->abSenseBuf[12] = uSCSIASC;
52
pVScsiSense->abSenseBuf[13] = uSCSIASCQ;
54
if (pVScsiReq->pbSense && pVScsiReq->cbSense)
55
memcpy(pVScsiReq->pbSense, pVScsiSense->abSenseBuf, RT_MIN(sizeof(pVScsiSense->abSenseBuf), pVScsiReq->cbSense));
51
57
return SCSI_STATUS_CHECK_CONDITION;
60
int vscsiReqSenseCmd(PVSCSISENSE pVScsiSense, PVSCSIREQINT pVScsiReq)
62
/* Copy the current sense data to the buffer. */
63
RTSgBufCopyFromBuf(&pVScsiReq->SgBuf, pVScsiSense->abSenseBuf, sizeof(pVScsiSense->abSenseBuf));
64
return vscsiReqSenseOkSet(pVScsiSense, pVScsiReq);