os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/tspcclientinterface.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/tspcclientinterface.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,139 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalTechnology
1.22 +*/
1.23 +
1.24 +#include <e32base.h>
1.25 +#include "debug.h"
1.26 +#include "msdebug.h"
1.27 +
1.28 +#include "msctypes.h"
1.29 +#include "mtransport.h"
1.30 +#include "mprotocol.h"
1.31 +#include "tscsiclientreq.h"
1.32 +#include "tscsiprimarycmds.h"
1.33 +#include "tscsiblockcmds.h"
1.34 +#include "tspcclientinterface.h"
1.35 +
1.36 +
1.37 +/**
1.38 +Constructor.
1.39 +
1.40 +@param aTransport Referance to the transport interface to be used to send the
1.41 +SCSI SPC message
1.42 +*/
1.43 +TSpcClientInterface::TSpcClientInterface(MTransport& aTransport)
1.44 +: iTransport(aTransport)
1.45 + {
1.46 + __MSFNLOG
1.47 + }
1.48 +
1.49 +/**
1.50 +Destructor.
1.51 +*/
1.52 +TSpcClientInterface::~TSpcClientInterface()
1.53 + {
1.54 + __MSFNLOG
1.55 + }
1.56 +
1.57 +/**
1.58 +Create a SCSI INQUIRY command and send the command via the transport layer. The
1.59 +function leaves if the device response is not compliant with the protocol
1.60 +standard.
1.61 +
1.62 +@param aInfo The returned information by the peripheral device
1.63 +
1.64 +@return TInt KErrNone if successful otherwise KErrCommandFailed to indicate a
1.65 +device status error
1.66 +*/
1.67 +TInt TSpcClientInterface::InquiryL(TPeripheralInfo& aInfo)
1.68 + {
1.69 + __MSFNLOG
1.70 + TScsiClientInquiryReq inquiryReq;
1.71 +
1.72 + TScsiClientInquiryResp inquiryResp(aInfo);
1.73 +
1.74 + TInt err = iTransport.SendControlCmdL(&inquiryReq, &inquiryResp);
1.75 + return err;
1.76 + }
1.77 +
1.78 +
1.79 +/**
1.80 +Create a SCSI REQUEST SENSE command and send the command via the transport
1.81 +layer. The function leaves if the device response is not compliant with the
1.82 +protocol standard.
1.83 +
1.84 +@param aSenseInfo The returned SENSE INFO
1.85 +
1.86 +@return TInt TInt KErrNone if successful otherwise KErrCommandFailed to indicate
1.87 +a device status error
1.88 +*/
1.89 +TInt TSpcClientInterface::RequestSenseL(TSenseInfo& aSenseInfo)
1.90 + {
1.91 + __MSFNLOG
1.92 + TScsiClientRequestSenseReq requestSenseReq;
1.93 + TScsiClientRequestSenseResp requestSenseResp;
1.94 +
1.95 + TInt err = iTransport.SendControlCmdL(&requestSenseReq, &requestSenseResp);
1.96 + aSenseInfo = requestSenseResp.iSenseInfo;
1.97 +
1.98 + __SCSIPRINT4(_L("SCSI SENSE INFO Response%08x Code=%08x, Qual=%08x Add=%08x"),
1.99 + requestSenseResp.iResponseCode,
1.100 + aSenseInfo.iSenseCode, aSenseInfo.iQualifier, aSenseInfo.iAdditional);
1.101 + return err;
1.102 + }
1.103 +
1.104 +
1.105 +/**
1.106 +Create a SCSI TEST UNIT READY command and send the command via the transport
1.107 +layer. The function leaves if the device response is not compliant with the
1.108 +protocol standard.
1.109 +
1.110 +@return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a
1.111 +device status error
1.112 +*/
1.113 +TInt TSpcClientInterface::TestUnitReadyL()
1.114 + {
1.115 + __MSFNLOG
1.116 + TScsiClientTestUnitReadyReq testUnitReadyReq;
1.117 +
1.118 + TInt err = iTransport.SendControlCmdL(&testUnitReadyReq);
1.119 + return err;
1.120 + }
1.121 +
1.122 +
1.123 +/**
1.124 +Creates a SCSI PREVENT ALLOW MEDIUM REMOVAL command and sends the command via
1.125 +the transport layer. The function leaves if the device response is not
1.126 +compliant with the protocol standard.
1.127 +
1.128 +@param aPrevent Set the PREVENT flag
1.129 +
1.130 +@return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a
1.131 +device status error
1.132 +*/
1.133 +TInt TSpcClientInterface::PreventAllowMediumRemovalL(TBool aPrevent)
1.134 + {
1.135 + __MSFNLOG
1.136 + TScsiClientPreventMediaRemovalReq preventAllowMediaRemovalReq(aPrevent);
1.137 + TInt err = iTransport.SendControlCmdL(&preventAllowMediaRemovalReq);
1.138 + return err;
1.139 + }
1.140 +
1.141 +
1.142 +