os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/tscsiprimarycmds.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
// scsiprimarycmds.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @internalTechnology
sl@0
    21
*/
sl@0
    22
sl@0
    23
#include <e32base.h>
sl@0
    24
sl@0
    25
#include "msctypes.h"
sl@0
    26
#include "debug.h"
sl@0
    27
#include "msdebug.h"
sl@0
    28
sl@0
    29
#include "mtransport.h"
sl@0
    30
#include "mprotocol.h"
sl@0
    31
sl@0
    32
#include "tscsiclientreq.h"
sl@0
    33
#include "tscsiprimarycmds.h"
sl@0
    34
sl@0
    35
sl@0
    36
// **** TEST UNIT READY ****
sl@0
    37
TInt TScsiClientTestUnitReadyReq::EncodeRequestL(TDes8& aBuffer) const
sl@0
    38
    {
sl@0
    39
	__MSFNSLOG
sl@0
    40
    __SCSIPRINT(_L("<-- SCSI TEST UNIT READY"));
sl@0
    41
    TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
sl@0
    42
    return length;
sl@0
    43
    }
sl@0
    44
sl@0
    45
sl@0
    46
// **** REQUEST SENSE ****
sl@0
    47
void TScsiClientRequestSenseResp::DecodeSenseInfo(const TDesC8& aPtr)
sl@0
    48
    {
sl@0
    49
	__MSFNSLOG
sl@0
    50
    iResponseCode = static_cast<TResponseCode>(aPtr[0]);
sl@0
    51
    iSenseInfo.iSenseCode = aPtr[02];
sl@0
    52
    iSenseInfo.iAdditional = aPtr[12];
sl@0
    53
    iSenseInfo.iQualifier = aPtr[13];
sl@0
    54
    }
sl@0
    55
sl@0
    56
sl@0
    57
void TScsiClientRequestSenseResp::DecodeL(const TDesC8& aPtr)
sl@0
    58
	{
sl@0
    59
	__MSFNSLOG
sl@0
    60
    __SCSIPRINT(_L("--> SCSI REQUEST SENSE"));
sl@0
    61
    if (aPtr.Length() < KResponseLength)
sl@0
    62
        {
sl@0
    63
        // Handle short data.
sl@0
    64
        // The data not transferred is assumed to be zero.
sl@0
    65
sl@0
    66
        // Create full size buffer
sl@0
    67
        TBuf8<KResponseLength> buffer;
sl@0
    68
sl@0
    69
        // Copy data into buffer
sl@0
    70
        buffer = aPtr;
sl@0
    71
        // Fill remainder with 0's
sl@0
    72
        buffer.AppendFill(0, KResponseLength - aPtr.Length());
sl@0
    73
sl@0
    74
        DecodeSenseInfo(buffer);
sl@0
    75
        }
sl@0
    76
    else
sl@0
    77
        {
sl@0
    78
        DecodeSenseInfo(aPtr);
sl@0
    79
        }
sl@0
    80
	}
sl@0
    81
sl@0
    82
sl@0
    83
// **** INQUIRY ****
sl@0
    84
void TScsiClientInquiryResp::DecodeInquiry(const TDesC8& aPtr)
sl@0
    85
    {
sl@0
    86
	__MSFNSLOG
sl@0
    87
    __SCSIPRINT(_L("--> SCSI INQUIRY"));
sl@0
    88
    iPeripheralInfo.iRemovable = (aPtr[1] & 0x80) ? ETrue : EFalse;
sl@0
    89
sl@0
    90
    iPeripheralInfo.iPeripheralQualifier = aPtr[0] >> 5;
sl@0
    91
    iPeripheralInfo.iPeripheralDeviceType = aPtr[0] & 0x1F;
sl@0
    92
    iPeripheralInfo.iVersion = aPtr[2];
sl@0
    93
    iPeripheralInfo.iResponseDataFormat = aPtr[3] & 0x0F;
sl@0
    94
sl@0
    95
    TPtrC8 vendorId(&aPtr[8], 8);
sl@0
    96
    iPeripheralInfo.iIdentification.iVendorId.Copy(vendorId);
sl@0
    97
sl@0
    98
    TPtrC8 productId(&aPtr[16], 16);
sl@0
    99
    iPeripheralInfo.iIdentification.iProductId.Copy(productId);
sl@0
   100
sl@0
   101
    TPtrC8 productRev(&aPtr[32], 4);
sl@0
   102
    iPeripheralInfo.iIdentification.iProductRev.Copy(productRev);
sl@0
   103
    }
sl@0
   104
sl@0
   105
sl@0
   106
void TScsiClientInquiryResp::DecodeL(const TDesC8& aPtr)
sl@0
   107
	{
sl@0
   108
    __MSFNSLOG
sl@0
   109
    __SCSIPRINT(_L("--> SCSI INQUIRY"));
sl@0
   110
    if (aPtr.Length() < KResponseLength)
sl@0
   111
        {
sl@0
   112
        // Handle short data.
sl@0
   113
        // The data not transferred is assumed to be zero.
sl@0
   114
sl@0
   115
        // Create zeroed buffer
sl@0
   116
        TBuf8<KResponseLength> buffer;
sl@0
   117
        buffer.FillZ(KResponseLength);
sl@0
   118
sl@0
   119
        // Copy data into buffer
sl@0
   120
        buffer = aPtr;
sl@0
   121
        buffer.SetLength(KResponseLength);
sl@0
   122
sl@0
   123
        DecodeInquiry(buffer);
sl@0
   124
        }
sl@0
   125
    else
sl@0
   126
        {
sl@0
   127
        DecodeInquiry(aPtr);
sl@0
   128
        }
sl@0
   129
	}
sl@0
   130
sl@0
   131
sl@0
   132
// ****	PREVENT MEDIA REMOVAL ****
sl@0
   133
TInt TScsiClientPreventMediaRemovalReq::EncodeRequestL(TDes8& aBuffer) const
sl@0
   134
    {
sl@0
   135
    __MSFNSLOG
sl@0
   136
    __SCSIPRINT(_L("<-- SCSI PREVENT MEDIA REMOVAL"));
sl@0
   137
    TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
sl@0
   138
	if (iPrevent)
sl@0
   139
        aBuffer[4] |= 0x01;
sl@0
   140
    return length;
sl@0
   141
    }
sl@0
   142