os/kernelhwsrv/kerneltest/f32test/smassstorage/inc/scsicmdbuilder.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 // Provides utilities to build SCSI commands
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @internalTechnology
    21 */
    22 
    23 #ifndef __SCSICMDBUILDER_H__
    24 #define __SCSICMDBUILDER_H__
    25 
    26 #include <e32std.h>
    27 #include <f32file.h>
    28 
    29 const TInt KScsiCmdMaxLen 	= 10;
    30 const TInt KCbwLength       = 31;
    31 const TInt KCswLength       = 13;
    32 const TInt KKiloBytes		= 1024;
    33 
    34 GLREF_D TBuf8<KScsiCmdMaxLen> scsiCmdBuf;
    35 
    36 /**
    37  builds read/write SCSI command
    38  */
    39 GLREF_C void BuildReadWrite(TInt aFlag, TInt aLogicalBlkAddr, TInt aTotalBlks);
    40 
    41 /**
    42  Builds prevent/allow medium removal SCSI command
    43  
    44  @param aFlag: indicating if the command is to allow or prevent medium removal
    45  */ 
    46 GLREF_C void BuildMediumRemoval(TInt aFlag);
    47 
    48 /**
    49  Builds a test unit ready SCSI command
    50  */
    51 GLREF_C void BuildTestUnitReady();
    52 
    53 /**
    54  Builds a start/stop unit command
    55  
    56  @param aFlag: indicating if the command is to start or stop unit
    57  */ 
    58 GLREF_C void BuildStartStopUnit(TInt aFlag);
    59 
    60 /**
    61  Copy an int. Little endian
    62  
    63  @param dest the destination
    64  @param source the source
    65  */
    66 GLREF_C void fillInt(TUint8* dest, TInt source);
    67 
    68 /**
    69  Extracts an integer from a buffer. Assume little endian 
    70  */
    71 GLREF_C TInt extractInt(const TUint8* aBuf);
    72 
    73 /**
    74  Builds a CBW message
    75  
    76  @param aCbw:            stores CBW
    77  @param aDCBWTag:        a command block tag sent by the host. Used to associates a CSW
    78          				 with corresponding CBW
    79  @param aDataTranferLen: the number of bytes the host expects to transfer
    80  @param aInOutFlag:      value for bmCBWFlags field, indicating the direction of transfer
    81  @param aCBWCB:			 the actual command to be wrapped
    82  @param aTestLun:	 	 local unit number
    83  */
    84 GLREF_C void createCBW(TDes8& aCbw, TInt aDCBWTag, TInt aDataTransferLen, TUint8 aInOutFlag, TDes8& aCBWCB, TUint8 aTestLun);
    85 
    86 #endif // __SCSICMDBUILDER_H__
    87