DrvSCSI.cpp revision 5b465a7c1237993faf8bb50120d247f3f0319ada
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/* $Id$ */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @file
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * VBox storage drivers: Generic SCSI command parser and execution driver
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * additional information or have any questions.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync//#define DEBUG
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#define LOG_GROUP LOG_GROUP_DRV_SCSI
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <VBox/pdmdrv.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <VBox/pdmifs.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <VBox/pdmthread.h>
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <VBox/scsi.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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include "Builtins.h"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
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;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#if 0 /* these interfaces aren't implemented */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The optional block async port interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMIBLOCKASYNCPORT IPortAsync;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The mount notify interface. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMIMOUNTNOTIFY IMountNotify;
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync#endif
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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Device type. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMBLOCKTYPE enmType;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** BIOS PCHS Geometry. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMMEDIAGEOMETRY PCHSGeometry;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** BIOS LCHS Geometry. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDMMEDIAGEOMETRY LCHSGeometry;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Number of sectors this device has. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint64_t cSectors;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** The dedicated I/O thread for the non async approach. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMTHREAD pAsyncIOThread;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /** Queue for passing the requests to the thread. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PRTREQQUEUE pQueueRequests;
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;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync} DRVSCSI, *PDRVSCSI;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** Converts a pointer to DRVSCSI::ISCSIConnecotr to a PDRVSCSI. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#define PDMISCSICONNECTOR_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) )
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#ifdef DEBUG
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Dumps a SCSI request structure for debugging purposes.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns nothing.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pRequest Pointer to the request to dump.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic void drvscsiDumpScsiRequest(PPDMSCSIREQUEST pRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("Dump for pRequest=%#p Command: %s\n", pRequest, SCSICmdText(pRequest->pbCDB[0])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("cbCDB=%u\n", pRequest->cbCDB));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (uint32_t i = 0; i < pRequest->cbCDB; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("pbCDB[%u]=%#x\n", i, pRequest->pbCDB[i]));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("cbScatterGather=%u\n", pRequest->cbScatterGather));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("cScatterGatherEntries=%u\n", pRequest->cScatterGatherEntries));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Print all scatter gather entries. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (uint32_t i = 0; i < pRequest->cScatterGatherEntries; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("ScatterGatherEntry[%u].cbSeg=%u\n", i, pRequest->paScatterGatherHead[i].cbSeg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("ScatterGatherEntry[%u].pvSeg=%#p\n", i, pRequest->paScatterGatherHead[i].pvSeg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("pvUser=%#p\n", pRequest->pvUser));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Copy the content of a buffer to a scatter gather list only
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * copying only the amount of data which fits into the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * scatter gather list.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pRequest Pointer to the request which contains the S/G list entries.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pvBuf Pointer to the buffer which should be copied.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param cbBuf Size of the buffer.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiScatterGatherListCopyFromBuffer(PPDMSCSIREQUEST pRequest, void *pvBuf, size_t cbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync unsigned cSGEntry = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMDATASEG pSGEntry = &pRequest->paScatterGatherHead[cSGEntry];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t *pu8Buf = (uint8_t *)pvBuf;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync LogFlowFunc(("pRequest=%#p pvBuf=%#p cbBuf=%u\n", pRequest, pvBuf, cbBuf));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#ifdef DEBUG
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (unsigned i = 0; i < cbBuf; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("%s: pvBuf[%u]=%#x\n", __FUNCTION__, i, pu8Buf[i]));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync while (cSGEntry < pRequest->cScatterGatherEntries)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync size_t cbToCopy = (cbBuf < pSGEntry->cbSeg) ? cbBuf : pSGEntry->cbSeg;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memcpy(pSGEntry->pvSeg, pu8Buf, cbToCopy);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cbBuf -= cbToCopy;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* We finished. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!cbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Advance the buffer. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pu8Buf += cbToCopy;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Go to the next entry in the list. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pSGEntry++;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cSGEntry++;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic void drvscsiPadStr(int8_t *pbDst, const char *pbSrc, uint32_t cbSize)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (uint32_t i = 0; i < cbSize; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (*pbSrc)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbDst[i] = *pbSrc++;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbDst[i] = ' ';
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Set the sense and advanced sense key in the buffer for error conditions.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns SCSI status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pRequest Pointer to the request which contains the sense buffer.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param uSCSISenseKey The sense key to set.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param uSCSIASC The advanced sense key to set.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(int) drvscsiCmdError(PPDMSCSIREQUEST pRequest, uint8_t uSCSISenseKey, uint8_t uSCSIASC)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pRequest->cbSenseBuffer >= 18, ("Sense buffer is not big enough\n"), SCSI_STATUS_OK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pRequest->pbSenseBuffer, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(pRequest->pbSenseBuffer, 0, pRequest->cbSenseBuffer);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[2] = uSCSISenseKey;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[7] = 10;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[12] = uSCSIASC;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[13] = 0x00; /** @todo: Provide more info. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return SCSI_STATUS_CHECK_CONDITION;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Sets the sense key for a status good condition.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns SCSI status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pRequest Pointer to the request which contains the sense buffer.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(int) drvscsiCmdOk(PPDMSCSIREQUEST pRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pRequest->cbSenseBuffer >= 18, ("Sense buffer is not big enough\n"), SCSI_STATUS_OK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pRequest->pbSenseBuffer, ("Sense buffer pointer is NULL\n"), SCSI_STATUS_OK);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(pRequest->pbSenseBuffer, 0, pRequest->cbSenseBuffer);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Setting this breaks Linux guests on the BusLogic controller.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * According to the SCSI SPC spec sense data is returned after a
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * CHECK CONDITION status or a REQUEST SENSE command.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Both SCSI controllers have a feature called Auto Sense which
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * fetches the sense data automatically from the device
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * with REQUEST SENSE. So the SCSI subsystem in Linux should
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * find this sense data even if the command finishes successfully
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * but if it finds valid sense data it will let the command fail
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * and it doesn't detect attached disks anymore.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Disabling makes it work again and no other guest shows errors
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * so I will leave it disabled for now.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * On the other hand it is possible that the devices fetch the sense data
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * only after a command failed so the content is really invalid if
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * the command succeeds.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#if 0
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[0] = (1 << 7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED; /* Fixed format */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[2] = SCSI_SENSE_NONE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[7] = 10;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[12] = SCSI_ASC_NONE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pRequest->pbSenseBuffer[13] = SCSI_ASC_NONE; /* Should be ASCQ but it has the same value for success. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return SCSI_STATUS_OK;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(void) drvscsiH2BE_U16(uint8_t *pbBuf, uint16_t val)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[0] = val >> 8;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[1] = val;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(void) drvscsiH2BE_U24(uint8_t *pbBuf, uint32_t val)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[0] = val >> 16;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[1] = val >> 8;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[2] = val;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(void) drvscsiH2BE_U32(uint8_t *pbBuf, uint32_t val)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[0] = val >> 24;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[1] = val >> 16;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[2] = val >> 8;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pbBuf[3] = val;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
93540abbca1a7ac8de705de01b9fc04092294a39vboxsyncDECLINLINE(void) drvscsiH2BE_U64(uint8_t *pbBuf, uint64_t val)
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync{
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[0] = val >> 56;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[1] = val >> 48;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[2] = val >> 40;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[3] = val >> 32;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[4] = val >> 24;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[5] = val >> 16;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[6] = val >> 8;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync pbBuf[7] = val;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(uint16_t) drvscsiBE2H_U16(const uint8_t *pbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return (pbBuf[0] << 8) | pbBuf[1];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(uint32_t) drvscsiBE2H_U24(const uint8_t *pbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return (pbBuf[0] << 16) | (pbBuf[1] << 8) | pbBuf[2];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(uint32_t) drvscsiBE2H_U32(const uint8_t *pbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return (pbBuf[0] << 24) | (pbBuf[1] << 16) | (pbBuf[2] << 8) | pbBuf[3];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncDECLINLINE(uint64_t) drvscsiBE2H_U64(const uint8_t *pbBuf)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return ((uint64_t)pbBuf[0] << 56)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[1] << 48)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[2] << 40)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[3] << 32)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[4] << 24)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[5] << 16)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((uint64_t)pbBuf[6] << 8)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | (uint64_t)pbBuf[7];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Parses the CDB of a request and acts accordingly.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns transfer direction type.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pThis Pointer to the SCSI driver instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pRequest Pointer to the request to process.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param puOffset Where to store the start offset to start data transfer from.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pcbToTransfer Where to store the number of bytes to transfer.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param piTxDir Where to store the data transfer direction.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiProcessCDB(PDRVSCSI pThis, PPDMSCSIREQUEST pRequest, uint64_t *puOffset, uint32_t *pcbToTransfer, int *piTxDir)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int iTxDir = PDMBLOCKTXDIR_NONE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = SCSI_STATUS_OK;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* We check for a command which needs to be handled even for non existant LUNs. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync switch (pRequest->pbCDB[0])
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_INQUIRY:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync SCSIINQUIRYDATA ScsiInquiryReply;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(&ScsiInquiryReply, 0, sizeof(ScsiInquiryReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.cbAdditional = 31;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* We support only one attached device at LUN0 at the moment. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pRequest->uLogicalUnit != 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.u5PeripheralDeviceType = SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_UNKNOWN;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync switch (pThis->enmType)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case PDMBLOCKTYPE_HARD_DISK:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.u5PeripheralDeviceType = SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync default:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Device type %u not supported\n", pThis->enmType));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_CONNECTED;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ScsiInquiryReply.u3AnsiVersion = 0x05; /* SPC-4 compliant */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiPadStr(ScsiInquiryReply.achVendorId, "VBOX", 8);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiPadStr(ScsiInquiryReply.achProductId, "HARDDISK", 16);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiPadStr(ScsiInquiryReply.achProductLevel, "1.0", 4);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, &ScsiInquiryReply, sizeof(SCSIINQUIRYDATA));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_REPORT_LUNS:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * If allocation length is less than 16 bytes SPC compliant devices have
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * to return an error.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (drvscsiBE2H_U32(&pRequest->pbCDB[6]) < 16)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdError(pRequest, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t aReply[16]; /* We report only one LUN. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(aReply, 0, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiH2BE_U32(&aReply[0], 8); /* List length starts at position 0. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_TEST_UNIT_READY:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync default:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Now for commands which are only implemented for existant LUNs. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (RT_LIKELY(pRequest->uLogicalUnit == 0))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync switch(pRequest->pbCDB[0])
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_CAPACITY:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t aReply[8];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(aReply, 0, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * If sector size exceeds the maximum value that is
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * able to be stored in 4 bytes return 0xffffffff in this field
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pThis->cSectors > UINT32_C(0xffffffff))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiH2BE_U32(aReply, UINT32_C(0xffffffff));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiH2BE_U32(aReply, pThis->cSectors - 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiH2BE_U32(&aReply[4], 512);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_MODE_SENSE_6:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t uModePage = pRequest->pbCDB[2] & 0x3f;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t aReply[24];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t *pu8ReplyPos;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(aReply, 0, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[0] = 4; /* Reply length 4. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[1] = 0; /* Default media type. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[2] = RT_BIT(4); /* Caching supported. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[3] = 0; /* Block descriptor length. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pu8ReplyPos = aReply + 4;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if ((uModePage == 0x08) || (uModePage == 0x3f))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(pu8ReplyPos, 0, 20);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pu8ReplyPos++ = 0x08; /* Page code. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pu8ReplyPos++ = 0x12; /* Size of the page. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pu8ReplyPos++ = 0x4; /* Write cache enabled. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_6:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_FROM_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t) pRequest->pbCDB[3]
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | (pRequest->pbCDB[2] << 8)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((pRequest->pbCDB[1] & 0x1f) << 16)) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)pRequest->pbCDB[4]) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_10:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_FROM_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t)drvscsiBE2H_U32(&pRequest->pbCDB[2])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U16(&pRequest->pbCDB[7])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_12:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_FROM_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t)drvscsiBE2H_U32(&pRequest->pbCDB[2])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U32(&pRequest->pbCDB[6])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_16:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_FROM_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = drvscsiBE2H_U64(&pRequest->pbCDB[2]) * 512;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U32(&pRequest->pbCDB[10])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_WRITE_6:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_TO_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t) pRequest->pbCDB[3]
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | (pRequest->pbCDB[2] << 8)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync | ((pRequest->pbCDB[1] & 0x1f) << 16)) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)pRequest->pbCDB[4]) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_WRITE_10:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_TO_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t)drvscsiBE2H_U32(&pRequest->pbCDB[2])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U16(&pRequest->pbCDB[7])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_WRITE_12:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_TO_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = ((uint64_t)drvscsiBE2H_U32(&pRequest->pbCDB[2])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U32(&pRequest->pbCDB[6])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_WRITE_16:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync iTxDir = PDMBLOCKTXDIR_TO_DEVICE;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *puOffset = drvscsiBE2H_U64(&pRequest->pbCDB[2]) * 512;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync *pcbToTransfer = ((uint32_t)drvscsiBE2H_U32(&pRequest->pbCDB[10])) * 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_SYNCHRONIZE_CACHE:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* @todo When async mode implemented we have to move this out here. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc2 = pThis->pDrvBlock->pfnFlush(pThis->pDrvBlock);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgRC(rc2, ("Flushing data failed rc=%Rrc\n", rc2));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_READ_BUFFER:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t uDataMode = pRequest->pbCDB[1] & 0x1f;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync switch (uDataMode)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x00:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x01:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x02:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x03:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x0a:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x0b:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t aReply[4];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* We do not implement an echo buffer. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync memset(aReply, 0, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x1a:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x1c:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync default:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("Invalid data mode\n"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_START_STOP_UNIT:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Nothing to do. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case SCSI_LOG_SENSE:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint16_t cbMax = drvscsiBE2H_U16(&pRequest->pbCDB[7]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t uPageCode = pRequest->pbCDB[2] & 0x3f;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t uSubPageCode = pRequest->pbCDB[3];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync switch (uPageCode)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync case 0x00:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (uSubPageCode == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint8_t aReply[4];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[0] = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[1] = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[2] = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync aReply[3] = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync default:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdError(pRequest, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync case SCSI_SERVICE_ACTION_IN_16:
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync {
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync switch (pRequest->pbCDB[1] & 0x1f)
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync {
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync case SCSI_SVC_ACTION_IN_READ_CAPACITY_16:
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync {
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync uint8_t aReply[32];
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync memset(aReply, 0, sizeof(aReply));
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync drvscsiH2BE_U64(aReply, pThis->cSectors - 1);
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync drvscsiH2BE_U32(&aReply[8], 512);
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync /* Leave the rest 0 */
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync drvscsiScatterGatherListCopyFromBuffer(pRequest, aReply, sizeof(aReply));
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync rc = drvscsiCmdOk(pRequest);
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync break;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync }
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync default:
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync rc = drvscsiCmdError(pRequest, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET); /* Don't know if this is correct */
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync }
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync break;
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync default:
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync //AssertMsgFailed(("Command %#x [%s] not implemented\n", pRequest->pbCDB[0], SCSICmdText(pRequest->pbCDB[0])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdError(pRequest, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Report an error. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = drvscsiCmdError(pRequest, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_LOGICAL_UNIT_DOES_NOT_RESPOND_TO_SELECTION);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync break;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *piTxDir = iTxDir;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic int drvscsiProcessRequestOne(PDRVSCSI pThis, PPDMSCSIREQUEST pRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = VINF_SUCCESS;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int iTxDir;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rcCompletion;
710a6316a22868b04400caf79719f96c18163cd3vboxsync uint64_t uOffset = UINT64_MAX; /* initialized to shut up gcc warnings. */
710a6316a22868b04400caf79719f96c18163cd3vboxsync uint32_t cbToTransfer = UINT32_MAX; /* ditto */
710a6316a22868b04400caf79719f96c18163cd3vboxsync uint32_t cSegmentsLeft = UINT32_MAX; /* ditto */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync LogFlowFunc(("Entered\n"));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#ifdef DEBUG
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiDumpScsiRequest(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rcCompletion = drvscsiProcessCDB(pThis, pRequest, &uOffset, &cbToTransfer, &iTxDir);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if ((rcCompletion == SCSI_STATUS_OK) && (iTxDir != PDMBLOCKTXDIR_NONE))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PPDMDATASEG pSegActual;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pSegActual = &pRequest->paScatterGatherHead[0];
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cSegmentsLeft = pRequest->cScatterGatherEntries;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync while(cbToTransfer && cSegmentsLeft)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uint32_t cbProcess = (cbToTransfer < pSegActual->cbSeg) ? cbToTransfer : (uint32_t)pSegActual->cbSeg;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Log(("%s: uOffset=%llu cbToTransfer=%u\n", __FUNCTION__, uOffset, cbToTransfer));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (iTxDir == PDMBLOCKTXDIR_FROM_DEVICE)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = pThis->pDrvBlock->pfnRead(pThis->pDrvBlock, uOffset,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pSegActual->pvSeg, cbProcess);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed->Actual.s.fReading = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (RT_FAILURE(rc))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("%s: Failed to read data %Rrc\n", __FUNCTION__, rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesRead, cbProcess);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = pThis->pDrvBlock->pfnWrite(pThis->pDrvBlock, uOffset,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pSegActual->pvSeg, cbProcess);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed->Actual.s.fWriting = 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (RT_FAILURE(rc))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgFailed(("%s: Failed to write data %Rrc\n", __FUNCTION__, rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync STAM_REL_COUNTER_ADD(&pThis->StatBytesWritten, cbProcess);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Go to the next entry. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync uOffset += cbProcess;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cbToTransfer -= cbProcess;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pSegActual++;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync cSegmentsLeft--;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsg(!cbToTransfer && !cSegmentsLeft,
93540abbca1a7ac8de705de01b9fc04092294a39vboxsync ("Transfer incomplete cbToTransfer=%u cSegmentsLeft=%u\n", cbToTransfer, cSegmentsLeft));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiCmdOk(pRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Notify device. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = pThis->pDevScsiPort->pfnSCSIRequestCompleted(pThis->pDevScsiPort, pRequest, rcCompletion);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgRC(rc, ("Error while notifying device rc=%Rrc\n", rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return rc;
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 *
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pThis Pointer to the instace 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 *
0c4004948fca34f2db87e7b38013137e9472c306vboxsync * @param pThis Pointer to the instace 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 {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = RTReqProcess(pThis->pQueueRequests, 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;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync RTReqFree(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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pThis->pQueueRequests, ("pQueueRequests 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
0c4004948fca34f2db87e7b38013137e9472c306vboxsync rc = RTReqCall(pThis->pQueueRequests, &pReq, 10000 /* 10 sec. */, (PFNRT)drvscsiAsyncIOLoopWakeupFunc, 1, pThis);
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync if (RT_SUCCESS(rc))
d7125f3a1b435761c393f9ec406e85a73ae2a3e7vboxsync RTReqFree(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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @copydoc PDMISCSICONNECTOR::pfnSCSIRequestSend. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic DECLCALLBACK(int) drvscsiRequestSend(PPDMISCSICONNECTOR pInterface, PPDMSCSIREQUEST pSCSIRequest)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMISCSICONNECTOR_2_DRVSCSI(pInterface);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PRTREQ pReq;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pThis->pQueueRequests, ("pQueueRequests is NULL\n"), VERR_INVALID_STATE);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = RTReqCallEx(pThis->pQueueRequests, &pReq, 0, RTREQFLAGS_NO_WAIT, (PFNRT)drvscsiProcessRequestOne, 2, pThis, pSCSIRequest);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Inserting request into queue failed rc=%Rrc\n", rc), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return VINF_SUCCESS;
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
a39ea3668b7019c23a68936259545f9b71bce1aavboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
0db6a029780d9f9b347500e117320a8d5661efe5vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKPORT, &pThis->IPort);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync return NULL;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
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
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (!pThis->pQueueRequests)
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return;
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, true);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (!RTReqIsBusy(pThis->pQueueRequests))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
0c4004948fca34f2db87e7b38013137e9472c306vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync return;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PRTREQ pReq;
0c4004948fca34f2db87e7b38013137e9472c306vboxsync int rc = RTReqCall(pThis->pQueueRequests, &pReq, 0 /*ms*/, (PFNRT)drvscsiAsyncIOLoopSyncCallback, 1, pThis);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (RT_SUCCESS(rc))
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync {
0c4004948fca34f2db87e7b38013137e9472c306vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync RTReqFree(pReq);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
0c4004948fca34f2db87e7b38013137e9472c306vboxsync
0c4004948fca34f2db87e7b38013137e9472c306vboxsync pThis->pPendingDummyReq = pReq;
d4e9ccea0ea1ed303b5708ff94f6c202755f0dc6vboxsync }
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
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return false;
0c4004948fca34f2db87e7b38013137e9472c306vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync PDMR3ThreadSuspend(pThis->pAsyncIOThread);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return true;
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
0c4004948fca34f2db87e7b38013137e9472c306vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 0 /*ms*/))
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return false;
0c4004948fca34f2db87e7b38013137e9472c306vboxsync ASMAtomicWriteBool(&pThis->fDummySignal, false);
0c4004948fca34f2db87e7b38013137e9472c306vboxsync return true;
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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pThis->pQueueRequests)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync if (!drvscsiAsyncIOLoopNoPendingDummy(pThis, 100 /*ms*/))
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync LogRel(("drvscsiDestruct#%u: previous dummy request is still pending\n", pDrvIns->iInstance));
8cd2f2e64725096acb682f34a5568b7fb816eda7vboxsync
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync int rc = RTReqDestroyQueue(pThis->pQueueRequests);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgRC(rc, ("Failed to destroy queue rc=%Rrc\n", rc));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync}
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/**
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Construct a block driver instance.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync *
cba6719bd64ec749967bbe931230452664109857vboxsync * @copydoc FNPDMDRVCONSTRUCT
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
cba6719bd64ec749967bbe931230452664109857vboxsyncstatic DECLCALLBACK(int) drvscsiConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync{
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync LogFlowFunc(("pDrvIns=%#p pCfgHandle=%#p\n", pDrvIns, pCfgHandle));
e74eef731a813e4e06680c587a6759b9974b29c9vboxsync PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync * Initialize the instance data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync pThis->pDrvIns = pDrvIns;
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsiRequestSend;
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync
a8139954a84d6e9090dd3a8371aa788351d45bc3vboxsync pDrvIns->IBase.pfnQueryInterface = drvscsiQueryInterface;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /*
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Try attach driver below and query it's block interface.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync */
cba6719bd64ec749967bbe931230452664109857vboxsync int 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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Query the SCSI port interface above. */
0db6a029780d9f9b347500e117320a8d5661efe5vboxsync pThis->pDevScsiPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMISCSIPORT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(pThis->pDevScsiPort, ("Missing SCSI port interface above\n"), VERR_PDM_MISSING_INTERFACE);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Query the optional LED interface above. */
0db6a029780d9f9b347500e117320a8d5661efe5vboxsync pThis->pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (pThis->pLedPort != NULL)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync {
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Get The Led. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = pThis->pLedPort->pfnQueryStatusLed(pThis->pLedPort, 0, &pThis->pLed);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (RT_FAILURE(rc))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed = &pThis->Led;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->pLed = &pThis->Led;
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);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (enmType != PDMBLOCKTYPE_HARD_DISK)
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync N_("Only hard disks are currently supported as SCSI devices (enmType=%d)"),
9b789c281103a2489742bf32f6ab500e38b2ecd5vboxsync enmType);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->enmType = enmType;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync pThis->cSectors = pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock) / 512;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Create request queue. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = RTReqCreateQueue(&pThis->pQueueRequests);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create request queue rc=%Rrc\n"), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
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
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Create I/O thread. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync
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 */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ~0,
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};