userlibandfileserver/fileserver/shostmassstorage/server/protocol/tscsiprimarycmds.cpp
changeset 9 96e5fb8b040d
child 6 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // scsiprimarycmds.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <e32base_private.h>
       
    25 
       
    26 #include "msctypes.h"
       
    27 #include "debug.h"
       
    28 #include "msdebug.h"
       
    29 
       
    30 #include "mtransport.h"
       
    31 #include "mprotocol.h"
       
    32 
       
    33 #include "tscsiclientreq.h"
       
    34 #include "tscsiprimarycmds.h"
       
    35 
       
    36 
       
    37 // **** TEST UNIT READY ****
       
    38 TInt TScsiClientTestUnitReadyReq::EncodeRequestL(TDes8& aBuffer) const
       
    39     {
       
    40 	__MSFNSLOG
       
    41     __SCSIPRINT(_L("<-- SCSI TEST UNIT READY"));
       
    42     TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
       
    43     return length;
       
    44     }
       
    45 
       
    46 
       
    47 // **** REQUEST SENSE ****
       
    48 void TScsiClientRequestSenseResp::DecodeSenseInfo(const TDesC8& aPtr)
       
    49     {
       
    50 	__MSFNSLOG
       
    51     iResponseCode = static_cast<TResponseCode>(aPtr[0]);
       
    52     iSenseInfo.iSenseCode = aPtr[02];
       
    53     iSenseInfo.iAdditional = aPtr[12];
       
    54     iSenseInfo.iQualifier = aPtr[13];
       
    55     }
       
    56 
       
    57 
       
    58 void TScsiClientRequestSenseResp::DecodeL(const TDesC8& aPtr)
       
    59 	{
       
    60 	__MSFNSLOG
       
    61     __SCSIPRINT(_L("--> SCSI REQUEST SENSE"));
       
    62     if (aPtr.Length() < KResponseLength)
       
    63         {
       
    64         // Handle short data.
       
    65         // The data not transferred is assumed to be zero.
       
    66 
       
    67         // Create full size buffer
       
    68         TBuf8<KResponseLength> buffer;
       
    69 
       
    70         // Copy data into buffer
       
    71         buffer = aPtr;
       
    72         // Fill remainder with 0's
       
    73         buffer.AppendFill(0, KResponseLength - aPtr.Length());
       
    74 
       
    75         DecodeSenseInfo(buffer);
       
    76         }
       
    77     else
       
    78         {
       
    79         DecodeSenseInfo(aPtr);
       
    80         }
       
    81 	}
       
    82 
       
    83 
       
    84 // **** INQUIRY ****
       
    85 void TScsiClientInquiryResp::DecodeInquiry(const TDesC8& aPtr)
       
    86     {
       
    87 	__MSFNSLOG
       
    88     __SCSIPRINT(_L("--> SCSI INQUIRY"));
       
    89     iPeripheralInfo.iRemovable = (aPtr[1] & 0x80) ? ETrue : EFalse;
       
    90 
       
    91     iPeripheralInfo.iPeripheralQualifier = aPtr[0] >> 5;
       
    92     iPeripheralInfo.iPeripheralDeviceType = aPtr[0] & 0x1F;
       
    93     iPeripheralInfo.iVersion = aPtr[2];
       
    94     iPeripheralInfo.iResponseDataFormat = aPtr[3] & 0x0F;
       
    95 
       
    96     TPtrC8 vendorId(&aPtr[8], 8);
       
    97     iPeripheralInfo.iIdentification.iVendorId.Copy(vendorId);
       
    98 
       
    99     TPtrC8 productId(&aPtr[16], 16);
       
   100     iPeripheralInfo.iIdentification.iProductId.Copy(productId);
       
   101 
       
   102     TPtrC8 productRev(&aPtr[32], 4);
       
   103     iPeripheralInfo.iIdentification.iProductRev.Copy(productRev);
       
   104     }
       
   105 
       
   106 
       
   107 void TScsiClientInquiryResp::DecodeL(const TDesC8& aPtr)
       
   108 	{
       
   109     __MSFNSLOG
       
   110     __SCSIPRINT(_L("--> SCSI INQUIRY"));
       
   111     if (aPtr.Length() < KResponseLength)
       
   112         {
       
   113         // Handle short data.
       
   114         // The data not transferred is assumed to be zero.
       
   115 
       
   116         // Create zeroed buffer
       
   117         TBuf8<KResponseLength> buffer;
       
   118         buffer.FillZ(KResponseLength);
       
   119 
       
   120         // Copy data into buffer
       
   121         buffer = aPtr;
       
   122         buffer.SetLength(KResponseLength);
       
   123 
       
   124         DecodeInquiry(buffer);
       
   125         }
       
   126     else
       
   127         {
       
   128         DecodeInquiry(aPtr);
       
   129         }
       
   130 	}
       
   131 
       
   132 
       
   133 // ****	PREVENT MEDIA REMOVAL ****
       
   134 TInt TScsiClientPreventMediaRemovalReq::EncodeRequestL(TDes8& aBuffer) const
       
   135     {
       
   136     __MSFNSLOG
       
   137     __SCSIPRINT(_L("<-- SCSI PREVENT MEDIA REMOVAL"));
       
   138     TInt length = TScsiClientReq::EncodeRequestL(aBuffer);
       
   139 	if (iPrevent)
       
   140         aBuffer[4] |= 0x01;
       
   141     return length;
       
   142     }
       
   143