kerneltest/f32test/shostmassstorage/msman/src/cusbhostao.cpp
changeset 0 a41df078684a
child 87 2f92ad2dc5db
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 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 //
       
    15 
       
    16 //#include <d32usbdi.h>
       
    17 //#include <d32otgdi.h>
       
    18 //#include <d32usbdescriptors.h>
       
    19 //#include <d32usbtransfers.h>
       
    20 
       
    21 
       
    22 //#include "rusbhostmslogicalunit.h"
       
    23 //
       
    24 //
       
    25 //
       
    26 //
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <f32file.h>
       
    30 #include <d32usbdi_hubdriver.h>
       
    31 #include "usbtypes.h"
       
    32 #include "rusbhostmsdevice.h"
       
    33 #include "rextfilesystem.h"
       
    34 
       
    35 #include "cusbmsmountmanager.h"
       
    36 //#include "cusbhost.h"
       
    37 #include "cusbhostao.h"
       
    38 #include "tmslog.h"
       
    39 #include "debug.h"
       
    40 
       
    41 
       
    42 _LIT(KTxtApp,"CUSBHOSTAO");
       
    43 
       
    44 CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver,
       
    45                              RUsbHubDriver::TBusEvent& aEvent,
       
    46                              MUsbHostBusEventObserver& aObserver)
       
    47     {
       
    48     __MSFNSLOG
       
    49     CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver);
       
    50 	r->ConstructL();
       
    51 	return r;
       
    52     }
       
    53 
       
    54 
       
    55 void CUsbHostAo::ConstructL()
       
    56     {
       
    57     __MSFNLOG
       
    58     }
       
    59 
       
    60 
       
    61 CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver,
       
    62                        RUsbHubDriver::TBusEvent& aEvent,
       
    63                        MUsbHostBusEventObserver& aObserver)
       
    64 :   CActive(EPriorityStandard),
       
    65     iHubDriver(aHubDriver),
       
    66     iEvent(aEvent),
       
    67     iObserver(aObserver)
       
    68     {
       
    69     __MSFNLOG
       
    70     CActiveScheduler::Add(this);
       
    71     }
       
    72 
       
    73 
       
    74 CUsbHostAo::~CUsbHostAo()
       
    75     {
       
    76     __MSFNLOG
       
    77 	Cancel();
       
    78 
       
    79     }
       
    80 
       
    81 
       
    82 void CUsbHostAo::Wait()
       
    83     {
       
    84     __MSFNLOG
       
    85 	if (IsActive())
       
    86 		{
       
    87 		__ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1));
       
    88 		return;
       
    89 		}
       
    90 
       
    91     __USBHOSTPRINT(_L("WaitForBusEvent..."));
       
    92 	iHubDriver.WaitForBusEvent(iEvent, iStatus);
       
    93     __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"),
       
    94                     iEvent.iEventType, iStatus.Int());
       
    95 	SetActive();
       
    96     }
       
    97 
       
    98 
       
    99 void CUsbHostAo::DoCancel()
       
   100 	{
       
   101     __MSFNLOG
       
   102     iHubDriver.CancelWaitForBusEvent();
       
   103 	}
       
   104 
       
   105 
       
   106 void CUsbHostAo::RunL()
       
   107 	{
       
   108     __MSFNLOG
       
   109 
       
   110     TInt status = iStatus.Int();
       
   111 	if (status == KErrNotReady)
       
   112 		{
       
   113         const TInt KDelay = 500 * 1000;  // in uSecs
       
   114         User::After(KDelay);
       
   115         Wait();
       
   116 		return;
       
   117 		}
       
   118 
       
   119     // Let RunError handle any other error
       
   120     User::LeaveIfError(status);
       
   121 
       
   122     // Process bus event
       
   123     TRAP(status, iObserver.ProcessBusEventL());
       
   124 	if(status != KErrNone)
       
   125 		{
       
   126         Wait();
       
   127 		return;
       
   128 		}
       
   129 
       
   130     Wait();
       
   131 	}
       
   132 
       
   133 _LIT(KErrLog, "ERROR %d in CActiveUsbHost");
       
   134 
       
   135 TInt CUsbHostAo::RunError(TInt aError)
       
   136 	{
       
   137 	__MSFNLOG
       
   138 	RDebug::Print(KErrLog, aError);
       
   139 	return KErrNone;
       
   140 	}
       
   141 
       
   142 
       
   143