os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/tspcclientinterface.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @internalTechnology
sl@0
    19
*/
sl@0
    20
sl@0
    21
#include <e32base.h>
sl@0
    22
#include "debug.h"
sl@0
    23
#include "msdebug.h"
sl@0
    24
sl@0
    25
#include "msctypes.h"
sl@0
    26
#include "mtransport.h"
sl@0
    27
#include "mprotocol.h"
sl@0
    28
#include "tscsiclientreq.h"
sl@0
    29
#include "tscsiprimarycmds.h"
sl@0
    30
#include "tscsiblockcmds.h"
sl@0
    31
#include "tspcclientinterface.h"
sl@0
    32
sl@0
    33
sl@0
    34
/**
sl@0
    35
Constructor.
sl@0
    36
sl@0
    37
@param aTransport Referance to the transport interface to be used to send the
sl@0
    38
SCSI SPC message
sl@0
    39
*/
sl@0
    40
TSpcClientInterface::TSpcClientInterface(MTransport& aTransport)
sl@0
    41
:   iTransport(aTransport)
sl@0
    42
    {
sl@0
    43
	__MSFNLOG
sl@0
    44
    }
sl@0
    45
sl@0
    46
/**
sl@0
    47
Destructor.
sl@0
    48
*/
sl@0
    49
TSpcClientInterface::~TSpcClientInterface()
sl@0
    50
    {
sl@0
    51
	__MSFNLOG
sl@0
    52
    }
sl@0
    53
sl@0
    54
/**
sl@0
    55
Create a SCSI INQUIRY command and send the command via the transport layer. The
sl@0
    56
function leaves if the device response is not compliant with the protocol
sl@0
    57
standard.
sl@0
    58
sl@0
    59
@param aInfo The returned information by the peripheral device
sl@0
    60
sl@0
    61
@return TInt KErrNone if successful otherwise KErrCommandFailed to indicate a
sl@0
    62
device status error
sl@0
    63
*/
sl@0
    64
TInt TSpcClientInterface::InquiryL(TPeripheralInfo& aInfo)
sl@0
    65
    {
sl@0
    66
	__MSFNLOG
sl@0
    67
    TScsiClientInquiryReq inquiryReq;
sl@0
    68
sl@0
    69
    TScsiClientInquiryResp inquiryResp(aInfo);
sl@0
    70
sl@0
    71
    TInt err = iTransport.SendControlCmdL(&inquiryReq, &inquiryResp);
sl@0
    72
	return err;
sl@0
    73
    }
sl@0
    74
sl@0
    75
sl@0
    76
/**
sl@0
    77
Create a SCSI REQUEST SENSE command and send the command via the transport
sl@0
    78
layer. The function leaves if the device response is not compliant with the
sl@0
    79
protocol standard.
sl@0
    80
sl@0
    81
@param aSenseInfo The returned SENSE INFO
sl@0
    82
sl@0
    83
@return TInt TInt KErrNone if successful otherwise KErrCommandFailed to indicate
sl@0
    84
a device status error
sl@0
    85
*/
sl@0
    86
TInt TSpcClientInterface::RequestSenseL(TSenseInfo& aSenseInfo)
sl@0
    87
    {
sl@0
    88
	__MSFNLOG
sl@0
    89
    TScsiClientRequestSenseReq requestSenseReq;
sl@0
    90
    TScsiClientRequestSenseResp requestSenseResp;
sl@0
    91
sl@0
    92
    TInt err = iTransport.SendControlCmdL(&requestSenseReq, &requestSenseResp);
sl@0
    93
    aSenseInfo = requestSenseResp.iSenseInfo;
sl@0
    94
sl@0
    95
    __SCSIPRINT4(_L("SCSI SENSE INFO Response%08x Code=%08x, Qual=%08x Add=%08x"),
sl@0
    96
                 requestSenseResp.iResponseCode,
sl@0
    97
                 aSenseInfo.iSenseCode, aSenseInfo.iQualifier, aSenseInfo.iAdditional);
sl@0
    98
	return err;
sl@0
    99
    }
sl@0
   100
sl@0
   101
sl@0
   102
/**
sl@0
   103
Create a SCSI TEST UNIT READY command and send the command via the transport
sl@0
   104
layer. The function leaves if the device response is not compliant with the
sl@0
   105
protocol standard.
sl@0
   106
sl@0
   107
@return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a
sl@0
   108
device status error
sl@0
   109
*/
sl@0
   110
TInt TSpcClientInterface::TestUnitReadyL()
sl@0
   111
    {
sl@0
   112
	__MSFNLOG
sl@0
   113
    TScsiClientTestUnitReadyReq testUnitReadyReq;
sl@0
   114
sl@0
   115
    TInt err = iTransport.SendControlCmdL(&testUnitReadyReq);
sl@0
   116
	return err;
sl@0
   117
    }
sl@0
   118
sl@0
   119
sl@0
   120
/**
sl@0
   121
Creates a SCSI PREVENT ALLOW MEDIUM REMOVAL command and sends the command via
sl@0
   122
the transport layer. The function leaves if the device response is not
sl@0
   123
compliant with the protocol standard.
sl@0
   124
sl@0
   125
@param aPrevent Set the PREVENT flag
sl@0
   126
sl@0
   127
@return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a
sl@0
   128
device status error
sl@0
   129
*/
sl@0
   130
TInt TSpcClientInterface::PreventAllowMediumRemovalL(TBool aPrevent)
sl@0
   131
    {
sl@0
   132
	__MSFNLOG
sl@0
   133
    TScsiClientPreventMediaRemovalReq preventAllowMediaRemovalReq(aPrevent);
sl@0
   134
    TInt err = iTransport.SendControlCmdL(&preventAllowMediaRemovalReq);
sl@0
   135
	return err;
sl@0
   136
    }
sl@0
   137
sl@0
   138
sl@0
   139