VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VSCSI/VSCSISense.cpp@ 27653

Last change on this file since 27653 was 27653, checked in by vboxsync, 15 years ago

VSCSI: New SCSI interpreter component which will replace the old stuff in DrvSCSI

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: VSCSISense.cpp 27653 2010-03-23 23:28:26Z vboxsync $ */
2/** @file
3 * Virtual SCSI driver: Sense handling
4 */
5
6/*
7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21#define LOG_GROUP LOG_GROUP_VSCSI
22#include <VBox/log.h>
23#include <iprt/assert.h>
24#include <iprt/string.h>
25
26#include "VSCSIInternal.h"
27
28int vscsiReqSenseOkSet(PVSCSIREQINT pVScsiReq)
29{
30 if (pVScsiReq->cbSense < 14)
31 return SCSI_STATUS_OK;
32
33 AssertMsgReturn(pVScsiReq->pbSense, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
34 memset(pVScsiReq->pbSense, 0, pVScsiReq->cbSense);
35
36 pVScsiReq->pbSense[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
37 pVScsiReq->pbSense[2] = SCSI_SENSE_NONE;
38 pVScsiReq->pbSense[7] = 10;
39 pVScsiReq->pbSense[12] = SCSI_ASC_NONE;
40 pVScsiReq->pbSense[13] = SCSI_ASC_NONE; /* Should be ASCQ but it has the same value for success. */
41
42 return SCSI_STATUS_OK;
43}
44
45int vscsiReqSenseErrorSet(PVSCSIREQINT pVScsiReq, uint8_t uSCSISenseKey, uint8_t uSCSIASC)
46{
47 AssertMsgReturn(pVScsiReq->cbSense >= 18, ("Sense buffer is not big enough\n"), SCSI_STATUS_OK);
48 AssertMsgReturn(pVScsiReq->pbSense, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
49 memset(pVScsiReq->pbSense, 0, pVScsiReq->cbSense);
50 pVScsiReq->pbSense[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
51 pVScsiReq->pbSense[2] = uSCSISenseKey;
52 pVScsiReq->pbSense[7] = 10;
53 pVScsiReq->pbSense[12] = uSCSIASC;
54 pVScsiReq->pbSense[13] = 0x00; /** @todo: Provide more info. */
55 return SCSI_STATUS_CHECK_CONDITION;
56}
57
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette