os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/src/cusbhostao.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/src/cusbhostao.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,143 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +//#include <d32usbdi.h>
    1.20 +//#include <d32otgdi.h>
    1.21 +//#include <d32usbdescriptors.h>
    1.22 +//#include <d32usbtransfers.h>
    1.23 +
    1.24 +
    1.25 +//#include "rusbhostmslogicalunit.h"
    1.26 +//
    1.27 +//
    1.28 +//
    1.29 +//
    1.30 +
    1.31 +#include <e32base.h>
    1.32 +#include <f32file.h>
    1.33 +#include <d32usbdi_hubdriver.h>
    1.34 +#include "usbtypes.h"
    1.35 +#include "rusbhostmsdevice.h"
    1.36 +#include "rextfilesystem.h"
    1.37 +
    1.38 +#include "cusbmsmountmanager.h"
    1.39 +//#include "cusbhost.h"
    1.40 +#include "cusbhostao.h"
    1.41 +#include "tmslog.h"
    1.42 +#include "debug.h"
    1.43 +
    1.44 +
    1.45 +_LIT(KTxtApp,"CUSBHOSTAO");
    1.46 +
    1.47 +CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver,
    1.48 +                             RUsbHubDriver::TBusEvent& aEvent,
    1.49 +                             MUsbHostBusEventObserver& aObserver)
    1.50 +    {
    1.51 +    __MSFNSLOG
    1.52 +    CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver);
    1.53 +	r->ConstructL();
    1.54 +	return r;
    1.55 +    }
    1.56 +
    1.57 +
    1.58 +void CUsbHostAo::ConstructL()
    1.59 +    {
    1.60 +    __MSFNLOG
    1.61 +    }
    1.62 +
    1.63 +
    1.64 +CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver,
    1.65 +                       RUsbHubDriver::TBusEvent& aEvent,
    1.66 +                       MUsbHostBusEventObserver& aObserver)
    1.67 +:   CActive(EPriorityStandard),
    1.68 +    iHubDriver(aHubDriver),
    1.69 +    iEvent(aEvent),
    1.70 +    iObserver(aObserver)
    1.71 +    {
    1.72 +    __MSFNLOG
    1.73 +    CActiveScheduler::Add(this);
    1.74 +    }
    1.75 +
    1.76 +
    1.77 +CUsbHostAo::~CUsbHostAo()
    1.78 +    {
    1.79 +    __MSFNLOG
    1.80 +	Cancel();
    1.81 +
    1.82 +    }
    1.83 +
    1.84 +
    1.85 +void CUsbHostAo::Wait()
    1.86 +    {
    1.87 +    __MSFNLOG
    1.88 +	if (IsActive())
    1.89 +		{
    1.90 +		__ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1));
    1.91 +		return;
    1.92 +		}
    1.93 +
    1.94 +    __USBHOSTPRINT(_L("WaitForBusEvent..."));
    1.95 +	iHubDriver.WaitForBusEvent(iEvent, iStatus);
    1.96 +    __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"),
    1.97 +                    iEvent.iEventType, iStatus.Int());
    1.98 +	SetActive();
    1.99 +    }
   1.100 +
   1.101 +
   1.102 +void CUsbHostAo::DoCancel()
   1.103 +	{
   1.104 +    __MSFNLOG
   1.105 +    iHubDriver.CancelWaitForBusEvent();
   1.106 +	}
   1.107 +
   1.108 +
   1.109 +void CUsbHostAo::RunL()
   1.110 +	{
   1.111 +    __MSFNLOG
   1.112 +
   1.113 +    TInt status = iStatus.Int();
   1.114 +	if (status == KErrNotReady)
   1.115 +		{
   1.116 +        const TInt KDelay = 500 * 1000;  // in uSecs
   1.117 +        User::After(KDelay);
   1.118 +        Wait();
   1.119 +		return;
   1.120 +		}
   1.121 +
   1.122 +    // Let RunError handle any other error
   1.123 +    User::LeaveIfError(status);
   1.124 +
   1.125 +    // Process bus event
   1.126 +    TRAP(status, iObserver.ProcessBusEventL());
   1.127 +	if(status != KErrNone)
   1.128 +		{
   1.129 +        Wait();
   1.130 +		return;
   1.131 +		}
   1.132 +
   1.133 +    Wait();
   1.134 +	}
   1.135 +
   1.136 +_LIT(KErrLog, "ERROR %d in CActiveUsbHost");
   1.137 +
   1.138 +TInt CUsbHostAo::RunError(TInt aError)
   1.139 +	{
   1.140 +	__MSFNLOG
   1.141 +	RDebug::Print(KErrLog, aError);
   1.142 +	return KErrNone;
   1.143 +	}
   1.144 +
   1.145 +
   1.146 +