DrvSCSI.cpp revision 4eb7f6613b45a75ffafc1f5f0f05f942ad36d727
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* $Id$ */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @file
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * VBox storage drivers: Generic SCSI command parser and execution driver
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2012 Oracle Corporation
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * available from http://www.virtualbox.org. This file is free software;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * General Public License (GPL) as published by the Free Software
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync//#define DEBUG
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#define LOG_GROUP LOG_GROUP_DRV_SCSI
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#include <VBox/vmm/pdmdrv.h>
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#include <VBox/vmm/pdmifs.h>
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#include <VBox/vmm/pdmthread.h>
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync#include <VBox/vscsi.h>
b0db50948c349fa76655abf252f7946b515e8204vboxsync#include <VBox/scsi.h>
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync#include <iprt/asm.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <iprt/assert.h>
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#include <iprt/mem.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <iprt/req.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <iprt/semaphore.h>
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#include <iprt/string.h>
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#include <iprt/uuid.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
f5e53763b0a581b0299e98028c6c52192eb06785vboxsync#include "VBoxDD.h"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync/** The maximum number of release log entries per device. */
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync#define MAX_LOG_REL_ERRORS 1024
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * SCSI driver instance data.
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync *
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMISCSICONNECTOR
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIBLOCKASYNCPORT
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIMOUNTNOTIFY
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsynctypedef struct DRVSCSI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer driver instance. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMDRVINS pDrvIns;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's base interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMIBASE pDrvBase;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's block interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMIBLOCK pDrvBlock;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's async block interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMIBLOCKASYNC pDrvBlockAsync;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's block bios interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMIBLOCKBIOS pDrvBlockBios;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the attached driver's mount interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMIMOUNT pDrvMount;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Pointer to the SCSI port interface of the device above. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMISCSIPORT pDevScsiPort;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** pointer to the Led port interface of the dveice above. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMILEDPORTS pLedPort;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The scsi connector interface .*/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMISCSICONNECTOR ISCSIConnector;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The block port interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMIBLOCKPORT IPort;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The optional block async port interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMIBLOCKASYNCPORT IPortAsync;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The mount notify interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMIMOUNTNOTIFY IMountNotify;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** Fallback status LED state for this drive.
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * This is used in case the device doesn't has a LED interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMLED Led;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** Pointer to the status LED for this drive. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMLED pLed;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** VSCSI device handle. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIDEVICE hVScsiDevice;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** VSCSI LUN handle. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSILUN hVScsiLun;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /** I/O callbacks. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSILUNIOCALLBACKS VScsiIoCallbacks;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The dedicated I/O thread for the non async approach. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMTHREAD pAsyncIOThread;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Queue for passing the requests to the thread. */
36411046d85fccaa66061120a064225fd1b5ae01vboxsync RTREQQUEUE hQueueRequests;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync /** Request that we've left pending on wakeup or reset. */
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync PRTREQ pPendingDummyReq;
0c4004948fca34f2db87e7b38013137e9472c306vboxsync /** Indicates whether PDMDrvHlpAsyncNotificationCompleted should be called by
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * any of the dummy functions. */
0c4004948fca34f2db87e7b38013137e9472c306vboxsync bool volatile fDummySignal;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Release statistics: number of bytes written. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync STAMCOUNTER StatBytesWritten;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Release statistics: number of bytes read. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync STAMCOUNTER StatBytesRead;
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync /** Release statistics: Current I/O depth. */
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync volatile uint32_t StatIoDepth;
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync /** Errors printed in the release log. */
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync unsigned cErrors;
65697a26b524640b83828b715160c798c43a0424vboxsync /** Mark the drive as having a non-rotational medium (i.e. as a SSD). */
65697a26b524640b83828b715160c798c43a0424vboxsync bool fNonRotational;
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync /** Medium is readonly */
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync bool fReadonly;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync} DRVSCSI, *PDRVSCSI;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync/** Converts a pointer to DRVSCSI::ISCSIConnector to a PDRVSCSI. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync#define PDMISCSICONNECTOR_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) )
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync/** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync#define PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync/** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync#define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) )
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync/** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync#define PDMIBLOCKPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
0381007ae929f1a0885e69644b7d586a1dbb3a2avboxsyncstatic bool drvscsiIsRedoPossible(int rc)
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync{
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync if ( rc == VERR_DISK_FULL
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync || rc == VERR_FILE_TOO_BIG
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync || rc == VERR_BROKEN_PIPE
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync || rc == VERR_NET_CONNECTION_REFUSED)
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync return true;
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync return false;
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync}
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsyncstatic int drvscsiProcessRequestOne(PDRVSCSI pThis, VSCSIIOREQ hVScsiIoReq)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync int rc = VINF_SUCCESS;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIIOREQTXDIR enmTxDir;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync switch (enmTxDir)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_FLUSH:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlock->pfnFlush(pThis->pDrvBlock);
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync if ( RT_FAILURE(rc)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: Flush returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance, rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_READ:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_WRITE:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync uint64_t uOffset = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync size_t cbTransfer = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync size_t cbSeg = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync PCRTSGSEG paSeg = NULL;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync unsigned cSeg = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer, &cSeg, &cbSeg,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync &paSeg);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertRC(rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync while (cbTransfer && cSeg)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync size_t cbProcess = (cbTransfer < paSeg->cbSeg) ? cbTransfer : paSeg->cbSeg;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync Log(("%s: uOffset=%llu cbProcess=%u\n", __FUNCTION__, uOffset, cbProcess));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (enmTxDir == VSCSIIOREQTXDIR_READ)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlock->pfnRead(pThis->pDrvBlock, uOffset,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync paSeg->pvSeg, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Actual.s.fReading = 0;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (RT_FAILURE(rc))
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync break;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync else
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlock->pfnWrite(pThis->pDrvBlock, uOffset,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync paSeg->pvSeg, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Actual.s.fWriting = 0;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (RT_FAILURE(rc))
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync break;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbProcess);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
93f91841f87620d1cb6d0238b3d0d5e52cd3b9a4vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* Go to the next entry. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync uOffset += cbProcess;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync cbTransfer -= cbProcess;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync paSeg++;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync cSeg--;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync if ( RT_FAILURE(rc)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync enmTxDir == VSCSIIOREQTXDIR_READ
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync ? "Read"
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync : "Write",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync uOffset,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync cbTransfer, rc));
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync break;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
65697a26b524640b83828b715160c798c43a0424vboxsync case VSCSIIOREQTXDIR_UNMAP:
65697a26b524640b83828b715160c798c43a0424vboxsync {
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync PCRTRANGE paRanges;
65697a26b524640b83828b715160c798c43a0424vboxsync unsigned cRanges;
65697a26b524640b83828b715160c798c43a0424vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync rc = VSCSIIoReqUnmapParamsGet(hVScsiIoReq, &paRanges, &cRanges);
65697a26b524640b83828b715160c798c43a0424vboxsync AssertRC(rc);
65697a26b524640b83828b715160c798c43a0424vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = pThis->pDrvBlock->pfnDiscard(pThis->pDrvBlock, paRanges, cRanges);
65697a26b524640b83828b715160c798c43a0424vboxsync pThis->pLed->Actual.s.fWriting = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync if ( RT_FAILURE(rc)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: Unmap returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance, rc));
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync break;
65697a26b524640b83828b715160c798c43a0424vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync default:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgFailed(("Invalid transfer direction %d\n", enmTxDir));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync if (RT_SUCCESS(rc))
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, false /* fRedoPossible */);
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync else
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiGetSize(VSCSILUN hVScsiLun, void *pvScsiLunUser, uint64_t *pcbSize)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync *pcbSize = pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsyncstatic DECLCALLBACK(int) drvscsiGetSectorSize(VSCSILUN hVScsiLun, void *pvScsiLunUser, uint32_t *pcbSectorSize)
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync{
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync *pcbSectorSize = pThis->pDrvBlock->pfnGetSectorSize(pThis->pDrvBlock);
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync return VINF_SUCCESS;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync}
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsyncstatic DECLCALLBACK(int) drvscsiSetLock(VSCSILUN hVScsiLun, void *pvScsiLunUser, bool fLocked)
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync{
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync if (fLocked)
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync pThis->pDrvMount->pfnLock(pThis->pDrvMount);
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync else
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync pThis->pDrvMount->pfnUnlock(pThis->pDrvMount);
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync return VINF_SUCCESS;
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync}
5761ae063fc6a6dcc410a6b56ddc286ba16855c8vboxsync
f687f34bd232be13744edbc0cc5155fa5d4540edvboxsyncstatic int drvscsiTransferCompleteNotify(PPDMIBLOCKASYNCPORT pInterface, void *pvUser, int rc)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDRVSCSI pThis = PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIIOREQ hVScsiIoReq = (VSCSIIOREQ)pvUser;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIIOREQTXDIR enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync LogFlowFunc(("Request hVScsiIoReq=%#p completed\n", hVScsiIoReq));
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (enmTxDir == VSCSIIOREQTXDIR_READ)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Actual.s.fReading = 0;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync else if ( enmTxDir == VSCSIIOREQTXDIR_WRITE
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync || enmTxDir == VSCSIIOREQTXDIR_UNMAP)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Actual.s.fWriting = 0;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync else
ead016c68c61b5f2e1fe4d237054eebea9327d4bvboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync if (RT_SUCCESS(rc))
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, false /* fRedoPossible */);
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync else
7ccfefe49db4cd93c3701d7b60873ebf404b5b87vboxsync {
7ccfefe49db4cd93c3701d7b60873ebf404b5b87vboxsync pThis->cErrors++;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync if (pThis->cErrors < MAX_LOG_REL_ERRORS)
64f58e4154eaa20c47782b429eeaff09070369bfvboxsync {
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync if (enmTxDir == VSCSIIOREQTXDIR_FLUSH)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: Flush returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance, rc));
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync else if (enmTxDir == VSCSIIOREQTXDIR_UNMAP)
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: Unmap returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance, rc));
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync else
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync {
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync uint64_t uOffset = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync size_t cbTransfer = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync size_t cbSeg = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync PCRTSGSEG paSeg = NULL;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync unsigned cSeg = 0;
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync &cSeg, &cbSeg, &paSeg);
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync pThis->pDrvIns->iInstance,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync enmTxDir == VSCSIIOREQTXDIR_READ
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync ? "Read"
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync : "Write",
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync uOffset,
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync cbTransfer, rc));
eb8371e8297aff06a1982468835ff62e1ab77b30vboxsync }
64f58e4154eaa20c47782b429eeaff09070369bfvboxsync }
7ccfefe49db4cd93c3701d7b60873ebf404b5b87vboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
7ccfefe49db4cd93c3701d7b60873ebf404b5b87vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiReqTransferEnqueue(VSCSILUN hVScsiLun,
65697a26b524640b83828b715160c798c43a0424vboxsync void *pvScsiLunUser,
65697a26b524640b83828b715160c798c43a0424vboxsync VSCSIIOREQ hVScsiIoReq)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync int rc = VINF_SUCCESS;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (pThis->pDrvBlockAsync)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync /* async I/O path. */
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIIOREQTXDIR enmTxDir;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync LogFlowFunc(("Enqueuing hVScsiIoReq=%#p\n", hVScsiIoReq));
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync switch (enmTxDir)
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_FLUSH:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync rc = pThis->pDrvBlockAsync->pfnStartFlush(pThis->pDrvBlockAsync, hVScsiIoReq);
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync if ( RT_FAILURE(rc)
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync && rc != VERR_VD_ASYNC_IO_IN_PROGRESS
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync LogRel(("SCSI#%u: Flush returned rc=%Rrc\n",
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync pThis->pDrvIns->iInstance, rc));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync case VSCSIIOREQTXDIR_UNMAP:
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync {
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync PCRTRANGE paRanges;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync unsigned cRanges;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = VSCSIIoReqUnmapParamsGet(hVScsiIoReq, &paRanges, &cRanges);
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync AssertRC(rc);
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync rc = pThis->pDrvBlockAsync->pfnStartDiscard(pThis->pDrvBlockAsync, paRanges, cRanges, hVScsiIoReq);
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync if ( RT_FAILURE(rc)
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync && rc != VERR_VD_ASYNC_IO_IN_PROGRESS
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync LogRel(("SCSI#%u: Discard returned rc=%Rrc\n",
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync pThis->pDrvIns->iInstance, rc));
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync break;
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_READ:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync case VSCSIIOREQTXDIR_WRITE:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync uint64_t uOffset = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync size_t cbTransfer = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync size_t cbSeg = 0;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync PCRTSGSEG paSeg = NULL;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync unsigned cSeg = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIIoReqParamsGet(hVScsiIoReq, &uOffset, &cbTransfer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync &cSeg, &cbSeg, &paSeg);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertRC(rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (enmTxDir == VSCSIIOREQTXDIR_READ)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlockAsync->pfnStartRead(pThis->pDrvBlockAsync, uOffset,
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync paSeg, cSeg, cbTransfer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync hVScsiIoReq);
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbTransfer);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync else
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = pThis->pDrvBlockAsync->pfnStartWrite(pThis->pDrvBlockAsync, uOffset,
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync paSeg, cSeg, cbTransfer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync hVScsiIoReq);
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbTransfer);
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync }
0dd6dfbebcda0af90da4413aaea5f3b9d1817556vboxsync
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync if ( RT_FAILURE(rc)
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync && rc != VERR_VD_ASYNC_IO_IN_PROGRESS
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync LogRel(("SCSI#%u: %s at offset %llu (%u bytes left) returned rc=%Rrc\n",
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync pThis->pDrvIns->iInstance,
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync enmTxDir == VSCSIIOREQTXDIR_READ
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync ? "Read"
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync : "Write",
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync uOffset,
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync cbTransfer, rc));
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync default:
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgFailed(("Invalid transfer direction %u\n", enmTxDir));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync if (rc == VINF_VD_ASYNC_IO_FINISHED)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync {
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync if (enmTxDir == VSCSIIOREQTXDIR_READ)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync pThis->pLed->Actual.s.fReading = 0;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else if (enmTxDir == VSCSIIOREQTXDIR_WRITE)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync pThis->pLed->Actual.s.fWriting = 0;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, VINF_SUCCESS, false);
c2f2661efd8da5281e2a3af6ddd10e737d333909vboxsync rc = VINF_SUCCESS;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync }
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync rc = VINF_SUCCESS;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else if (RT_FAILURE(rc))
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync {
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync if (enmTxDir == VSCSIIOREQTXDIR_READ)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync pThis->pLed->Actual.s.fReading = 0;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else if (enmTxDir == VSCSIIOREQTXDIR_WRITE)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync pThis->pLed->Actual.s.fWriting = 0;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsg(enmTxDir == VSCSIIOREQTXDIR_FLUSH, ("Invalid transfer direction %u\n", enmTxDir));
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync VSCSIIoReqCompleted(hVScsiIoReq, rc, drvscsiIsRedoPossible(rc));
4569bf0ad094b40d2e177299a00d37e94d28616cvboxsync rc = VINF_SUCCESS;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync }
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync else
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync AssertMsgFailed(("Invalid return code rc=%Rrc\n", rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync else
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync {
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* I/O thread. */
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueCallEx(pThis->hQueueRequests, NULL, 0, RTREQFLAGS_NO_WAIT,
36411046d85fccaa66061120a064225fd1b5ae01vboxsync (PFNRT)drvscsiProcessRequestOne, 2, pThis, hVScsiIoReq);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsyncstatic DECLCALLBACK(int) drvscsiGetFeatureFlags(VSCSILUN hVScsiLun,
65697a26b524640b83828b715160c798c43a0424vboxsync void *pvScsiLunUser,
65697a26b524640b83828b715160c798c43a0424vboxsync uint64_t *pfFeatures)
65697a26b524640b83828b715160c798c43a0424vboxsync{
65697a26b524640b83828b715160c798c43a0424vboxsync int rc = VINF_SUCCESS;
65697a26b524640b83828b715160c798c43a0424vboxsync PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
65697a26b524640b83828b715160c798c43a0424vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync *pfFeatures = 0;
65697a26b524640b83828b715160c798c43a0424vboxsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync if ( pThis->pDrvBlock->pfnDiscard
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync || ( pThis->pDrvBlockAsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync && pThis->pDrvBlockAsync->pfnStartDiscard))
65697a26b524640b83828b715160c798c43a0424vboxsync *pfFeatures |= VSCSI_LUN_FEATURE_UNMAP;
65697a26b524640b83828b715160c798c43a0424vboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync if (pThis->fNonRotational)
65697a26b524640b83828b715160c798c43a0424vboxsync *pfFeatures |= VSCSI_LUN_FEATURE_NON_ROTATIONAL;
65697a26b524640b83828b715160c798c43a0424vboxsync
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync if (pThis->fReadonly)
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync *pfFeatures |= VSCSI_LUN_FEATURE_READONLY;
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync
65697a26b524640b83828b715160c798c43a0424vboxsync return VINF_SUCCESS;
65697a26b524640b83828b715160c798c43a0424vboxsync}
65697a26b524640b83828b715160c798c43a0424vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsyncstatic void drvscsiVScsiReqCompleted(VSCSIDEVICE hVScsiDevice, void *pVScsiDeviceUser,
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync void *pVScsiReqUser, int rcScsiCode, bool fRedoPossible,
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync int rcReq)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDRVSCSI pThis = (PDRVSCSI)pVScsiDeviceUser;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicDecU32(&pThis->StatIoDepth);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->pDevScsiPort->pfnSCSIRequestCompleted(pThis->pDevScsiPort, (PPDMSCSIREQUEST)pVScsiReqUser,
96a7e06717e2d7398642eadb5ebab1bf13fbe2dbvboxsync rcScsiCode, fRedoPossible, rcReq);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (RT_UNLIKELY(pThis->fDummySignal) && !pThis->StatIoDepth)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync/**
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * Dummy request function used by drvscsiReset to wait for all pending requests
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * to complete prior to the device reset.
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param pThis Pointer to the instance data.
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync * @returns VINF_SUCCESS.
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync */
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic int drvscsiAsyncIOLoopSyncCallback(PDRVSCSI pThis)
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (pThis->fDummySignal)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync return VINF_SUCCESS;
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync}
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Request function to wakeup the thread.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @param pThis Pointer to the instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VWRN_STATE_CHANGED.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic int drvscsiAsyncIOLoopWakeupFunc(PDRVSCSI pThis)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (pThis->fDummySignal)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpAsyncNotificationCompleted(pThis->pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VWRN_STATE_CHANGED;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The thread function which processes the requests asynchronously.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns Pointer to the driver instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pThread Pointer to the thread instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiAsyncIOLoop(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync LogFlowFunc(("Entering async IO loop.\n"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync while (pThread->enmState == PDMTHREADSTATE_RUNNING)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueProcess(pThis->hQueueRequests, RT_INDEFINITE_WAIT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsg(rc == VWRN_STATE_CHANGED, ("Left RTReqProcess and error code is not VWRN_STATE_CHANGED rc=%Rrc\n", rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync/**
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * Deals with any pending dummy request
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync *
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @returns true if no pending dummy request, false if still pending.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @param pThis The instance data.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * @param cMillies The number of milliseconds to wait for any
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync * pending request to finish.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync */
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsyncstatic bool drvscsiAsyncIOLoopNoPendingDummy(PDRVSCSI pThis, uint32_t cMillies)
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync{
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync if (!pThis->pPendingDummyReq)
8a339f91959bb7a3315b51a23461b68c7b0cb50evboxsync return true;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync int rc = RTReqWait(pThis->pPendingDummyReq, cMillies);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync if (RT_FAILURE(rc))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return false;
9de47c4ec7b0fc9a384e4b815153de399da7b8devboxsync RTReqRelease(pThis->pPendingDummyReq);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync pThis->pPendingDummyReq = NULL;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return true;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync}
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiAsyncIOLoopWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PRTREQ pReq;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync int rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync AssertMsgReturn(pThis->hQueueRequests != NIL_RTREQQUEUE, ("hQueueRequests is NULL\n"), VERR_INVALID_STATE);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 10000 /* 10 sec */))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync LogRel(("drvscsiAsyncIOLoopWakeup#%u: previous dummy request is still pending\n", pDrvIns->iInstance));
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return VERR_TIMEOUT;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsiAsyncIOLoopWakeupFunc, 1, pThis);
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync if (RT_SUCCESS(rc))
9de47c4ec7b0fc9a384e4b815153de399da7b8devboxsync RTReqRelease(pReq);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync else
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync pThis->pPendingDummyReq = pReq;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync LogRel(("drvscsiAsyncIOLoopWakeup#%u: %Rrc pReq=%p\n", pDrvIns->iInstance, rc, pReq));
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* -=-=-=-=- ISCSIConnector -=-=-=-=- */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
b0db50948c349fa76655abf252f7946b515e8204vboxsync#ifdef DEBUG
b0db50948c349fa76655abf252f7946b515e8204vboxsync/**
b0db50948c349fa76655abf252f7946b515e8204vboxsync * Dumps a SCSI request structure for debugging purposes.
b0db50948c349fa76655abf252f7946b515e8204vboxsync *
b0db50948c349fa76655abf252f7946b515e8204vboxsync * @returns nothing.
b0db50948c349fa76655abf252f7946b515e8204vboxsync * @param pRequest Pointer to the request to dump.
b0db50948c349fa76655abf252f7946b515e8204vboxsync */
b0db50948c349fa76655abf252f7946b515e8204vboxsyncstatic void drvscsiDumpScsiRequest(PPDMSCSIREQUEST pRequest)
b0db50948c349fa76655abf252f7946b515e8204vboxsync{
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("Dump for pRequest=%#p Command: %s\n", pRequest, SCSICmdText(pRequest->pbCDB[0])));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("cbCDB=%u\n", pRequest->cbCDB));
b0db50948c349fa76655abf252f7946b515e8204vboxsync for (uint32_t i = 0; i < pRequest->cbCDB; i++)
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("pbCDB[%u]=%#x\n", i, pRequest->pbCDB[i]));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("cbScatterGather=%u\n", pRequest->cbScatterGather));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("cScatterGatherEntries=%u\n", pRequest->cScatterGatherEntries));
b0db50948c349fa76655abf252f7946b515e8204vboxsync /* Print all scatter gather entries. */
b0db50948c349fa76655abf252f7946b515e8204vboxsync for (uint32_t i = 0; i < pRequest->cScatterGatherEntries; i++)
b0db50948c349fa76655abf252f7946b515e8204vboxsync {
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("ScatterGatherEntry[%u].cbSeg=%u\n", i, pRequest->paScatterGatherHead[i].cbSeg));
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("ScatterGatherEntry[%u].pvSeg=%#p\n", i, pRequest->paScatterGatherHead[i].pvSeg));
b0db50948c349fa76655abf252f7946b515e8204vboxsync }
b0db50948c349fa76655abf252f7946b515e8204vboxsync Log(("pvUser=%#p\n", pRequest->pvUser));
b0db50948c349fa76655abf252f7946b515e8204vboxsync}
b0db50948c349fa76655abf252f7946b515e8204vboxsync#endif
b0db50948c349fa76655abf252f7946b515e8204vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @copydoc PDMISCSICONNECTOR::pfnSCSIRequestSend. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic DECLCALLBACK(int) drvscsiRequestSend(PPDMISCSICONNECTOR pInterface, PPDMSCSIREQUEST pSCSIRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMISCSICONNECTOR_2_DRVSCSI(pInterface);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync VSCSIREQ hVScsiReq;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync
b0db50948c349fa76655abf252f7946b515e8204vboxsync#ifdef DEBUG
b0db50948c349fa76655abf252f7946b515e8204vboxsync drvscsiDumpScsiRequest(pSCSIRequest);
b0db50948c349fa76655abf252f7946b515e8204vboxsync#endif
b0db50948c349fa76655abf252f7946b515e8204vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceReqCreate(pThis->hVScsiDevice, &hVScsiReq,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->uLogicalUnit,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->pbCDB,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->cbCDB,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->cbScatterGather,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->cScatterGatherEntries,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->paScatterGatherHead,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->pbSenseBuffer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest->cbSenseBuffer,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pSCSIRequest);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync if (RT_FAILURE(rc))
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync return rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
faee255cc48bfbf17cb9f72fca70c8b9d3020ec4vboxsync ASMAtomicIncU32(&pThis->StatIoDepth);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceReqEnqueue(pThis->hVScsiDevice, hVScsiReq);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync return rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* -=-=-=-=- IBase -=-=-=-=- */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync/**
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsyncstatic DECLCALLBACK(void *) drvscsiQueryInterface(PPDMIBASE pInterface, const char *pszIID)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount);
4eb7f6613b45a75ffafc1f5f0f05f942ad36d727vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->pDrvBlockBios);
a39ea3668b7019c23a68936259545f9b71bce1aavboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
0db6a029780d9f9b347500e117320a8d5661efe5vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKPORT, &pThis->IPort);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKASYNCPORT, &pThis->IPortAsync);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync return NULL;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
cab115cfa31c584def7069312a1e23c3fc88533bvboxsyncstatic DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIBLOCKPORT pInterface, const char **ppcszController,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync uint32_t *piInstance, uint32_t *piLUN)
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync{
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync PDRVSCSI pThis = PDMIBLOCKPORT_2_DRVSCSI(pInterface);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync piInstance, piLUN);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync}
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync/**
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * Called when media is mounted.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync *
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * @param pInterface Pointer to the interface structure containing the called function pointer.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync */
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsyncstatic DECLCALLBACK(void) drvscsiMountNotify(PPDMIMOUNTNOTIFY pInterface)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync{
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync LogFlowFunc(("mounting LUN#%p\n", pThis->hVScsiLun));
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync /* Ignore the call if we're called while being attached. */
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync if (!pThis->pDrvBlock)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync return;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync /* Let the LUN know that a medium was mounted. */
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync VSCSILunMountNotify(pThis->hVScsiLun);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync}
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync/**
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsync * Called when media is unmounted
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsync *
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync * @param pInterface Pointer to the interface structure containing the called function pointer.
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync */
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsyncstatic DECLCALLBACK(void) drvscsiUnmountNotify(PPDMIMOUNTNOTIFY pInterface)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync{
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync LogFlowFunc(("unmounting LUN#%p\n", pThis->hVScsiLun));
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync /* Let the LUN know that the medium was unmounted. */
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync VSCSILunUnmountNotify(pThis->hVScsiLun);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync}
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync/**
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * Worker for drvscsiReset, drvscsiSuspend and drvscsiPowerOff.
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync *
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pfnAsyncNotify The async callback.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync */
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic void drvscsiR3ResetOrSuspendOrPowerOff(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!pThis->pDrvBlockAsync)
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
36411046d85fccaa66061120a064225fd1b5ae01vboxsync if (pThis->hQueueRequests != NIL_RTREQQUEUE)
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, true);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
36411046d85fccaa66061120a064225fd1b5ae01vboxsync if (!RTReqQueueIsBusy(pThis->hQueueRequests))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync PRTREQ pReq;
36411046d85fccaa66061120a064225fd1b5ae01vboxsync int rc = RTReqQueueCall(pThis->hQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (RT_SUCCESS(rc))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
9de47c4ec7b0fc9a384e4b815153de399da7b8devboxsync RTReqRelease(pReq);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync pThis->pPendingDummyReq = pReq;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync else
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (pThis->StatIoDepth > 0)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, true);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMDrvHlpSetAsyncNotification(pDrvIns, pfnAsyncNotify);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync}
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync/**
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * Callback employed by drvscsiSuspend and drvscsiPowerOff.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync *
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @returns true if we've quiesced, false if we're still working.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync */
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic DECLCALLBACK(bool) drvscsiIsAsyncSuspendOrPowerOffDone(PPDMDRVINS pDrvIns)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (pThis->pDrvBlockAsync)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (pThis->StatIoDepth > 0)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync else
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync else
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync PDMR3ThreadSuspend(pThis->pAsyncIOThread);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync}
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync/**
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVPOWEROFF
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiPowerOff(PPDMDRVINS pDrvIns)
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncSuspendOrPowerOffDone);
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync}
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync/**
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVSUSPEND
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiSuspend(PPDMDRVINS pDrvIns)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncSuspendOrPowerOffDone);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync}
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync/**
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * Callback employed by drvscsiReset.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync *
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @returns true if we've quiesced, false if we're still working.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pDrvIns The driver instance.
0c4004948fca34f2db87e7b38013137e9472c306vboxsync */
0c4004948fca34f2db87e7b38013137e9472c306vboxsyncstatic DECLCALLBACK(bool) drvscsiIsAsyncResetDone(PPDMDRVINS pDrvIns)
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync{
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (pThis->pDrvBlockAsync)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (pThis->StatIoDepth > 0)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync else
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync else
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return false;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync return true;
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync}
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync/**
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync * @copydoc FNPDMDRVRESET
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsyncstatic DECLCALLBACK(void) drvscsiReset(PPDMDRVINS pDrvIns)
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync{
0c4004948fca34f2db87e7b38013137e9472c306vboxsync drvscsiR3ResetOrSuspendOrPowerOff(pDrvIns, drvscsiIsAsyncResetDone);
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync}
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Destruct a driver instance.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Most VM resources are freed by the VM. This callback is provided so that any non-VM
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * resources can be freed correctly.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pDrvIns The driver instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic DECLCALLBACK(void) drvscsiDestruct(PPDMDRVINS pDrvIns)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync if (pThis->hQueueRequests != NIL_RTREQQUEUE)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 100 /*ms*/))
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync LogRel(("drvscsiDestruct#%u: previous dummy request is still pending\n", pDrvIns->iInstance));
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync int rc = RTReqQueueDestroy(pThis->hQueueRequests);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgRC(rc, ("Failed to destroy queue rc=%Rrc\n", rc));
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pThis->hQueueRequests = NIL_RTREQQUEUE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
26947320577c481b4afefdb0afbb855181e5b2e8vboxsync
26947320577c481b4afefdb0afbb855181e5b2e8vboxsync /* Free the VSCSI device and LUN handle. */
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync if (pThis->hVScsiDevice)
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync {
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync VSCSILUN hVScsiLun;
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync int rc = VSCSIDeviceLunDetach(pThis->hVScsiDevice, 0, &hVScsiLun);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync AssertRC(rc);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync Assert(hVScsiLun == pThis->hVScsiLun);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync rc = VSCSILunDestroy(hVScsiLun);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync AssertRC(rc);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync rc = VSCSIDeviceDestroy(pThis->hVScsiDevice);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync AssertRC(rc);
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync pThis->hVScsiDevice = NULL;
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync pThis->hVScsiLun = NULL;
1e1273b11e17928ec3c3a8fff45121aa7a169413vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Construct a block driver instance.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
cba6719bd64ec749967bbe931230452664109857vboxsync * @copydoc FNPDMDRVCONSTRUCT
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsyncstatic DECLCALLBACK(int) drvscsiConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync int rc = VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
c28fa006ba669ad8f26ae31d00a338379c04ea1bvboxsync LogFlowFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg));
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync * Initialize the instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pThis->pDrvIns = pDrvIns;
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend;
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync pThis->IMountNotify.pfnMountNotify = drvscsiMountNotify;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync pThis->IMountNotify.pfnUnmountNotify = drvscsiUnmountNotify;
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync pThis->IPort.pfnQueryDeviceLocation = drvscsiQueryDeviceLocation;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;
36411046d85fccaa66061120a064225fd1b5ae01vboxsync pThis->hQueueRequests = NIL_RTREQQUEUE;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Query the SCSI port interface above. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above\n"), VERR_PDM_MISSING_INTERFACE);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Query the optional LED interface above. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync if (pThis->pLedPort != NULL)
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync {
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync /* Get The Led. */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync if (RT_FAILURE(rc))
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pLed = &pThis->Led;
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync }
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync else
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync pThis->pLed = &pThis->Led;
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync /*
36411046d85fccaa66061120a064225fd1b5ae01vboxsync * Validate and read configuration.
36411046d85fccaa66061120a064225fd1b5ae01vboxsync */
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync if (!CFGMR3AreValuesValid(pCfg, "NonRotationalMedium\0Readonly\0"))
36411046d85fccaa66061120a064225fd1b5ae01vboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
36411046d85fccaa66061120a064225fd1b5ae01vboxsync N_("SCSI configuration error: unknown option specified"));
36411046d85fccaa66061120a064225fd1b5ae01vboxsync
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);
36411046d85fccaa66061120a064225fd1b5ae01vboxsync if (RT_FAILURE(rc))
36411046d85fccaa66061120a064225fd1b5ae01vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc,
36411046d85fccaa66061120a064225fd1b5ae01vboxsync N_("SCSI configuration error: failed to read \"NonRotationalMedium\" as boolean"));
36411046d85fccaa66061120a064225fd1b5ae01vboxsync
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync rc = CFGMR3QueryBoolDef(pCfg, "Readonly", &pThis->fReadonly, false);
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync if (RT_FAILURE(rc))
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync return PDMDRV_SET_ERROR(pDrvIns, rc,
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync N_("SCSI configuration error: failed to read \"Readonly\" as boolean"));
6f76f373e9274aa29ec1485be3bfebafb670af0evboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Try attach driver below and query it's block interface.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
4c42ef40805493bd6d76103b90f71bcd6dbc0f00vboxsync rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pThis->pDrvBase);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Attaching driver below failed rc=%Rrc\n", rc), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Query the block and blockbios interfaces.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlock = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!pThis->pDrvBlock)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Configuration error: No block interface!\n"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VERR_PDM_MISSING_INTERFACE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!pThis->pDrvBlockBios)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Configuration error: No block BIOS interface!\n"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VERR_PDM_MISSING_INTERFACE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Try to get the optional async block interface. */
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvBlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
cba6719bd64ec749967bbe931230452664109857vboxsync PDMBLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync VSCSILUNTYPE enmLunType;
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsync switch (enmType)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync {
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync case PDMBLOCKTYPE_HARD_DISK:
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync enmLunType = VSCSILUNTYPE_SBC;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync break;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync case PDMBLOCKTYPE_CDROM:
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync case PDMBLOCKTYPE_DVD:
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync enmLunType = VSCSILUNTYPE_MMC;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync break;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync default:
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync N_("Only hard disks and CD/DVD-ROMs are currently supported as SCSI devices (enmType=%d)"),
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync enmType);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync }
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync if ( ( enmType == PDMBLOCKTYPE_DVD
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync || enmType == PDMBLOCKTYPE_CDROM)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync && !pThis->pDrvMount)
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync {
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync AssertMsgFailed(("Internal error: cdrom without a mountable interface\n"));
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync return VERR_INTERNAL_ERROR;
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync }
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync /* Create VSCSI device and LUN. */
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumGetSize = drvscsiGetSize;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumGetSectorSize = drvscsiGetSectorSize;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunReqTransferEnqueue = drvscsiReqTransferEnqueue;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunGetFeatureFlags = drvscsiGetFeatureFlags;
e18d16f31765f000e2a4a111a3df6d211cd825f1vboxsync pThis->VScsiIoCallbacks.pfnVScsiLunMediumSetLock = drvscsiSetLock;
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, drvscsiVScsiReqCompleted, pThis);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI device rc=%Rrc\n"), rc);
0a3cfc177eb2cca0805ca23cf5f98b0080b2ec21vboxsync rc = VSCSILunCreate(&pThis->hVScsiLun, enmLunType, &pThis->VScsiIoCallbacks,
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync pThis);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI LUN rc=%Rrc\n"), rc);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync rc = VSCSIDeviceLunAttach(pThis->hVScsiDevice, pThis->hVScsiLun, 0);
ea779b55cc87f3e3fadddca4672c6697c82606edvboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to attached the LUN to the SCSI device\n"), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync //@todo: This is a very hacky way of telling the LUN whether a medium was mounted.
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync // The mount/unmount interface doesn't work in a very sensible manner!
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync if (pThis->pDrvMount)
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync {
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync if (pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock))
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync {
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync rc = VINF_SUCCESS; VSCSILunMountNotify(pThis->hVScsiLun);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to notify the LUN of media being mounted\n"), rc);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync }
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync else
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync {
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync rc = VINF_SUCCESS; VSCSILunUnmountNotify(pThis->hVScsiLun);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to notify the LUN of media being unmounted\n"), rc);
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync }
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync }
5cece736b63cc917f3781c8c7e46fd3ea98c4e20vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Register statistics counter. */
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync /** @todo aeichner: Find a way to put the instance number of the attached
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync * controller device when we support more than one controller of the same type.
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync * At the moment we have the 0 hardcoded. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
c91345f92b829d3fba05ce7a97206d83c5183ce0vboxsync "Amount of data read.", "/Devices/SCSI0/%d/ReadBytes", pDrvIns->iInstance);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
c91345f92b829d3fba05ce7a97206d83c5183ce0vboxsync "Amount of data written.", "/Devices/SCSI0/%d/WrittenBytes", pDrvIns->iInstance);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync pThis->StatIoDepth = 0;
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->StatIoDepth, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync "Number of active tasks.", "/Devices/SCSI0/%d/IoDepth", pDrvIns->iInstance);
44a2ecaf2d0fc196ab76cab13b3f909299e386d1vboxsync
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync if (!pThis->pDrvBlockAsync)
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync {
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync /* Create request queue. */
36411046d85fccaa66061120a064225fd1b5ae01vboxsync rc = RTReqQueueCreate(&pThis->hQueueRequests);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc);
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync /* Create I/O thread. */
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
b0db50948c349fa76655abf252f7946b515e8204vboxsync
b0db50948c349fa76655abf252f7946b515e8204vboxsync LogRel(("SCSI#%d: using normal I/O\n", pDrvIns->iInstance));
71f6a34b72f9cc873da208630959de49df1a28a5vboxsync }
b0db50948c349fa76655abf252f7946b515e8204vboxsync else
b0db50948c349fa76655abf252f7946b515e8204vboxsync LogRel(("SCSI#%d: using async I/O\n", pDrvIns->iInstance));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync if ( pThis->pDrvBlock->pfnDiscard
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync || ( pThis->pDrvBlockAsync
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync && pThis->pDrvBlockAsync->pfnStartDiscard))
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync LogRel(("SCSI#%d: Enabled UNMAP support\n"));
f4aad55f8addd816ef005845842a2418bbdc3ea2vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * SCSI driver registration record.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncconst PDMDRVREG g_DrvSCSI =
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* u32Version */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDM_DRVREG_VERSION,
5b465a7c1237993faf8bb50120d247f3f0319adavboxsync /* szName */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "SCSI",
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szRCMod */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync "",
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szR0Mod */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync "",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pszDescription */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "Generic SCSI driver.",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* fFlags */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* fClass. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDM_DRVREG_CLASS_SCSI,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* cMaxInstances */
ad48e47654d22f79b025dc4b21cb162cb123801avboxsync ~0U,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* cbInstance */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync sizeof(DRVSCSI),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnConstruct */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiConstruct,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnDestruct */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiDestruct,
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* pfnRelocate */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync NULL,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnIOCtl */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NULL,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnPowerOn */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NULL,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnReset */
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync drvscsiReset,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnSuspend */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync drvscsiSuspend,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnResume */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NULL,
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnAttach */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync NULL,
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnDetach */
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync NULL,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* pfnPowerOff */
8f0fc87a72dee210b62acc9dd859a4bebf8bfb33vboxsync drvscsiPowerOff,
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnSoftReset */
cba6719bd64ec749967bbe931230452664109857vboxsync NULL,
cba6719bd64ec749967bbe931230452664109857vboxsync /* u32EndVersion */
cba6719bd64ec749967bbe931230452664109857vboxsync PDM_DRVREG_VERSION
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync};