os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/controller/include/cusbhostmsdevicethread.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/controller/include/cusbhostmsdevicethread.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,116 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +/**
    1.21 + Implements a thread per device functionality
    1.22 + */
    1.23 +
    1.24 +/** @file
    1.25 +@internalTechnology
    1.26 +*/
    1.27 +
    1.28 +#ifndef CUSBMASSSTORAGEDEVICETHREAD_H
    1.29 +#define CUSBMASSSTORAGEDEVICETHREAD_H
    1.30 +
    1.31 +
    1.32 +class TDeviceHandler
    1.33 +    {
    1.34 +public:
    1.35 +    TDeviceHandler(CUsbHostMsDevice& aDevice);
    1.36 +	void HandleMessageL(const RMessage2& aMessage);
    1.37 +
    1.38 +private:
    1.39 +    CUsbHostMsDevice& iDevice;
    1.40 +    };
    1.41 +
    1.42 +
    1.43 +class TLogicalUnitHandler
    1.44 +    {
    1.45 +public:
    1.46 +    TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu);
    1.47 +	void HandleMessageL(const RMessage2& aMessage);
    1.48 +
    1.49 +private:
    1.50 +	CUsbHostMsLogicalUnit& iLu;
    1.51 +    };
    1.52 +
    1.53 +class CUsbHostMsSession;
    1.54 +
    1.55 +class CUsbHostMsDeviceThread : public CActive
    1.56 +    {
    1.57 +public:
    1.58 +    static const TInt KMaxNumMessage = 32;
    1.59 +
    1.60 +	static CUsbHostMsDeviceThread* NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken);
    1.61 +	~CUsbHostMsDeviceThread();
    1.62 +
    1.63 +private:
    1.64 +    CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken);
    1.65 +
    1.66 +public:
    1.67 +	static TInt Entry(TAny* aPtr);
    1.68 +	TInt QueueMsg(const RMessage2& aMsg);
    1.69 +    void Lock();
    1.70 +    void Unlock();
    1.71 +
    1.72 +
    1.73 +private:
    1.74 +    void Start();
    1.75 +
    1.76 +	void RunL();
    1.77 +	void DoCancel();
    1.78 +    TInt RunError(TInt aError);
    1.79 +
    1.80 +	void HandleMessage(const RMessage2& aMessage);
    1.81 +
    1.82 +	void UnRegisterInterfaceL(const RMessage2& aMessage);
    1.83 +
    1.84 +private:
    1.85 +    static void DoStartServerL(TAny* aPtr);
    1.86 +
    1.87 +	void RegisterInterfaceL(const RMessage2& aMessage);
    1.88 +	void InitialiseInterfaceL(const RMessage2& aMessage);
    1.89 +	void GetNumLunL(const RMessage2& aMessage);
    1.90 +	void RegisterLogicalUnitL(const RMessage2& aMessage);
    1.91 +	TInt Shutdown();
    1.92 +
    1.93 +private:
    1.94 +    CUsbHostMsSession& iUsbHostMsSession;
    1.95 +
    1.96 +	CUsbHostMsDevice* iUsbHostMsDevice;
    1.97 +
    1.98 +	RMessage2 iRMessage2[KMaxNumMessage];
    1.99 +	RMutex iMutex;
   1.100 +
   1.101 +	TInt iQueueIndex;
   1.102 +	TInt iDequeueIndex;
   1.103 +	TBool iQueueFull;
   1.104 +    };
   1.105 +
   1.106 +
   1.107 +inline void CUsbHostMsDeviceThread::Lock()
   1.108 +	{
   1.109 +	iMutex.Wait();
   1.110 +	}
   1.111 +
   1.112 +
   1.113 +inline void CUsbHostMsDeviceThread::Unlock()
   1.114 +	{
   1.115 +	iMutex.Signal();
   1.116 +	}
   1.117 +
   1.118 +
   1.119 +#endif // CUSBMASSSTORAGEDEVICETHREAD_H