userlibandfileserver/fileserver/shostmassstorage/server/transport/include/botmsctypes.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 // BOT Protocol layer for USB Mass Storage Class
       
    15 //
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #ifndef BOTMSCTYPES_H
       
    24 #define BOTMSCTYPES_H
       
    25 
       
    26 /**
       
    27 Represents Endpoint0 request Setup packet.
       
    28 USB Mass Storage Class Bulk-Only Transport 3.1, 3.2
       
    29 */
       
    30 class TBotFunctionReqCb
       
    31 	{
       
    32 public:
       
    33     /** length of request setup packet, USB 2.0 9.3 */
       
    34     static const TUint KRequestHdrSize = 8;
       
    35 
       
    36     /** Bulk Only class specific request values */
       
    37 	enum TEp0Request
       
    38 		{
       
    39 		EReqGetMaxLun = 0xFE,
       
    40 		EReqReset = 0xFF
       
    41 		};
       
    42 
       
    43 public:
       
    44     /** bmRequestType field */
       
    45 	TUint8 iRequestType;
       
    46     /** bRequest field   */
       
    47 	TEp0Request iRequest;
       
    48     /** wValue field */
       
    49 	TUint16 iValue;
       
    50     /** wIndex field */
       
    51 	TUint16 iIndex;
       
    52     /** wLength field */
       
    53 	TUint16 iLength;
       
    54 	};
       
    55 
       
    56 
       
    57 class MClientCommandServiceReq;
       
    58 
       
    59 /**
       
    60 Represents the Bulk Only Transport Command Block Wrapper (CBW), USB Mass Storage
       
    61 Class Bulk-Only Transport 5.1
       
    62 */
       
    63 class TBotCbw
       
    64     {
       
    65 public:
       
    66     /** Data direction */
       
    67     enum TCbwDirection
       
    68         {
       
    69         EDataOut = 0,
       
    70         EDataIn = 1
       
    71         };
       
    72 
       
    73 public:
       
    74     void SetDataTransferLength(TUint32 aLen);
       
    75     void SetTag(TUint32 aTag);
       
    76 	void SetDataTransferDirection(TBotCbw::TCbwDirection aDirection);
       
    77 	void SetLun(TUint8 aLunId);
       
    78     void EncodeL(TPtr8 &aBuffer, const MClientCommandServiceReq* aRequest) const;
       
    79 
       
    80 
       
    81 private:
       
    82     /** Signature offset */
       
    83     const static TInt KCbwSignatureOffset = 0;
       
    84     /** Tag offset */
       
    85     const static TInt KCbwTagOffset = 4;
       
    86     /** Transfer Length offset */
       
    87     const static TInt KCbwDataTransferLengthOffset = 8;
       
    88     /** Flags offset */
       
    89     const static TInt KCbwFlagOffset = 12;
       
    90     /** LUN offset */
       
    91     const static TInt KCbwLunOffset = 13;
       
    92     /** CB Length offset */
       
    93     const static TInt KCbwCbLengthOffset = 14;
       
    94     /** Start of Command Block */
       
    95     const static TInt KCbwCbOffset = 15;
       
    96     /** Length of Command Block */
       
    97     const static TInt KCbwcbLength = 15;
       
    98     /** Length of wrapper and command block */
       
    99     const static TInt KCbwLength = 31;
       
   100 
       
   101 public:
       
   102     /** dCBWTag */
       
   103     TUint32 iTag;
       
   104     /** dCBWDataTransferLength */
       
   105     TUint32 iDataTransferLength;
       
   106     /** CBWFlags */
       
   107     TCbwDirection iDirection;
       
   108     /** bCBWLUN */
       
   109     TUint8 iLun;
       
   110     };
       
   111 
       
   112 /**
       
   113 
       
   114 
       
   115  */
       
   116 
       
   117 /**
       
   118 Represents the Bulk Only Transport Command Status Word (CSW)
       
   119 USB Mass Storage Class Bulk-Only Transport 5.2
       
   120 */
       
   121 class TBotCsw
       
   122     {
       
   123 public:
       
   124     /** Status values */
       
   125     enum TCswStatus
       
   126         {
       
   127         ECommandPassed	= 0,
       
   128         ECommandFailed	= 1,
       
   129         EPhaseError		= 2
       
   130         };
       
   131 
       
   132     TInt Decode(const TDesC8& aPtr);
       
   133     TBool IsValidCsw(TUint32 aTag) const;
       
   134     TBool IsMeaningfulCsw(TUint32 aTransferLength) const;
       
   135 
       
   136 private:
       
   137     /** Signature offset */
       
   138     const static TInt KCswSignatureOffset = 0;
       
   139     /** Tag offset */
       
   140     const static TInt KCswTagOffset = 4;
       
   141     /** Residue offset */
       
   142     const static TInt KCswDataResidueOffset = 8;
       
   143     /** Status offset */
       
   144     const static TInt KCswStatusOffset = 12;
       
   145 
       
   146     /** Length of CSW */
       
   147     const static TInt KCswLength = 13;
       
   148 
       
   149 public:
       
   150     /** dCSWTag */
       
   151     TUint32 iTag;
       
   152     /** dCSWDataResidue */
       
   153     TUint32 iDataResidue;
       
   154     /**  bCSWStatus */
       
   155     TCswStatus iStatus;
       
   156     /** dCSWSignature */
       
   157     TUint32 iSignature;
       
   158     };
       
   159 
       
   160 
       
   161 /**
       
   162 Set Transfer Length field.
       
   163 
       
   164 @param aLen The length
       
   165 */
       
   166 inline void TBotCbw::SetDataTransferLength(TUint32 aLen)
       
   167     {
       
   168     iDataTransferLength = aLen;
       
   169     }
       
   170 
       
   171 
       
   172 /**
       
   173 Set Transfer Direction field.
       
   174 
       
   175 @param aDirection The direction
       
   176 */
       
   177 inline void TBotCbw::SetDataTransferDirection(TBotCbw::TCbwDirection aDirection)
       
   178     {
       
   179     iDirection = aDirection;
       
   180     }
       
   181 
       
   182 
       
   183 /**
       
   184 Set LUN field.
       
   185 
       
   186 @param aLun The LUN
       
   187 */
       
   188 inline void TBotCbw::SetLun(TUint8 aLun)
       
   189     {
       
   190     iLun = aLun;
       
   191     }
       
   192 
       
   193 /**
       
   194 Set Tag field.
       
   195 
       
   196 @param aTag The tag
       
   197 */
       
   198 inline void TBotCbw::SetTag(TUint32 aTag)
       
   199     {
       
   200     iTag = aTag;
       
   201     }
       
   202 
       
   203 #endif // BOTMSCTYPES_H
       
   204