os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/controller/include/cusbhostmsdevicethread.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 /**
    18  Implements a thread per device functionality
    19  */
    20 
    21 /** @file
    22 @internalTechnology
    23 */
    24 
    25 #ifndef CUSBMASSSTORAGEDEVICETHREAD_H
    26 #define CUSBMASSSTORAGEDEVICETHREAD_H
    27 
    28 
    29 class TDeviceHandler
    30     {
    31 public:
    32     TDeviceHandler(CUsbHostMsDevice& aDevice);
    33 	void HandleMessageL(const RMessage2& aMessage);
    34 
    35 private:
    36     CUsbHostMsDevice& iDevice;
    37     };
    38 
    39 
    40 class TLogicalUnitHandler
    41     {
    42 public:
    43     TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu);
    44 	void HandleMessageL(const RMessage2& aMessage);
    45 
    46 private:
    47 	CUsbHostMsLogicalUnit& iLu;
    48     };
    49 
    50 class CUsbHostMsSession;
    51 
    52 class CUsbHostMsDeviceThread : public CActive
    53     {
    54 public:
    55     static const TInt KMaxNumMessage = 32;
    56 
    57 	static CUsbHostMsDeviceThread* NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken);
    58 	~CUsbHostMsDeviceThread();
    59 
    60 private:
    61     CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken);
    62 
    63 public:
    64 	static TInt Entry(TAny* aPtr);
    65 	TInt QueueMsg(const RMessage2& aMsg);
    66     void Lock();
    67     void Unlock();
    68 
    69 
    70 private:
    71     void Start();
    72 
    73 	void RunL();
    74 	void DoCancel();
    75     TInt RunError(TInt aError);
    76 
    77 	void HandleMessage(const RMessage2& aMessage);
    78 
    79 	void UnRegisterInterfaceL(const RMessage2& aMessage);
    80 
    81 private:
    82     static void DoStartServerL(TAny* aPtr);
    83 
    84 	void RegisterInterfaceL(const RMessage2& aMessage);
    85 	void InitialiseInterfaceL(const RMessage2& aMessage);
    86 	void GetNumLunL(const RMessage2& aMessage);
    87 	void RegisterLogicalUnitL(const RMessage2& aMessage);
    88 	TInt Shutdown();
    89 
    90 private:
    91     CUsbHostMsSession& iUsbHostMsSession;
    92 
    93 	CUsbHostMsDevice* iUsbHostMsDevice;
    94 
    95 	RMessage2 iRMessage2[KMaxNumMessage];
    96 	RMutex iMutex;
    97 
    98 	TInt iQueueIndex;
    99 	TInt iDequeueIndex;
   100 	TBool iQueueFull;
   101     };
   102 
   103 
   104 inline void CUsbHostMsDeviceThread::Lock()
   105 	{
   106 	iMutex.Wait();
   107 	}
   108 
   109 
   110 inline void CUsbHostMsDeviceThread::Unlock()
   111 	{
   112 	iMutex.Signal();
   113 	}
   114 
   115 
   116 #endif // CUSBMASSSTORAGEDEVICETHREAD_H