os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/src/cusbhostao.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
//#include <d32usbdi.h>
sl@0
    17
//#include <d32otgdi.h>
sl@0
    18
//#include <d32usbdescriptors.h>
sl@0
    19
//#include <d32usbtransfers.h>
sl@0
    20
sl@0
    21
sl@0
    22
//#include "rusbhostmslogicalunit.h"
sl@0
    23
//
sl@0
    24
//
sl@0
    25
//
sl@0
    26
//
sl@0
    27
sl@0
    28
#include <e32base.h>
sl@0
    29
#include <f32file.h>
sl@0
    30
#include <d32usbdi_hubdriver.h>
sl@0
    31
#include "usbtypes.h"
sl@0
    32
#include "rusbhostmsdevice.h"
sl@0
    33
#include "rextfilesystem.h"
sl@0
    34
sl@0
    35
#include "cusbmsmountmanager.h"
sl@0
    36
//#include "cusbhost.h"
sl@0
    37
#include "cusbhostao.h"
sl@0
    38
#include "tmslog.h"
sl@0
    39
#include "debug.h"
sl@0
    40
sl@0
    41
sl@0
    42
_LIT(KTxtApp,"CUSBHOSTAO");
sl@0
    43
sl@0
    44
CUsbHostAo* CUsbHostAo::NewL(RUsbHubDriver& aHubDriver,
sl@0
    45
                             RUsbHubDriver::TBusEvent& aEvent,
sl@0
    46
                             MUsbHostBusEventObserver& aObserver)
sl@0
    47
    {
sl@0
    48
    __MSFNSLOG
sl@0
    49
    CUsbHostAo* r = new (ELeave) CUsbHostAo(aHubDriver, aEvent, aObserver);
sl@0
    50
	r->ConstructL();
sl@0
    51
	return r;
sl@0
    52
    }
sl@0
    53
sl@0
    54
sl@0
    55
void CUsbHostAo::ConstructL()
sl@0
    56
    {
sl@0
    57
    __MSFNLOG
sl@0
    58
    }
sl@0
    59
sl@0
    60
sl@0
    61
CUsbHostAo::CUsbHostAo(RUsbHubDriver& aHubDriver,
sl@0
    62
                       RUsbHubDriver::TBusEvent& aEvent,
sl@0
    63
                       MUsbHostBusEventObserver& aObserver)
sl@0
    64
:   CActive(EPriorityStandard),
sl@0
    65
    iHubDriver(aHubDriver),
sl@0
    66
    iEvent(aEvent),
sl@0
    67
    iObserver(aObserver)
sl@0
    68
    {
sl@0
    69
    __MSFNLOG
sl@0
    70
    CActiveScheduler::Add(this);
sl@0
    71
    }
sl@0
    72
sl@0
    73
sl@0
    74
CUsbHostAo::~CUsbHostAo()
sl@0
    75
    {
sl@0
    76
    __MSFNLOG
sl@0
    77
	Cancel();
sl@0
    78
sl@0
    79
    }
sl@0
    80
sl@0
    81
sl@0
    82
void CUsbHostAo::Wait()
sl@0
    83
    {
sl@0
    84
    __MSFNLOG
sl@0
    85
	if (IsActive())
sl@0
    86
		{
sl@0
    87
		__ASSERT_ALWAYS(EFalse, User::Panic(KTxtApp, -1));
sl@0
    88
		return;
sl@0
    89
		}
sl@0
    90
sl@0
    91
    __USBHOSTPRINT(_L("WaitForBusEvent..."));
sl@0
    92
	iHubDriver.WaitForBusEvent(iEvent, iStatus);
sl@0
    93
    __USBHOSTPRINT2(_L("WaitForBusEvent done. Event=%d Status=%d"),
sl@0
    94
                    iEvent.iEventType, iStatus.Int());
sl@0
    95
	SetActive();
sl@0
    96
    }
sl@0
    97
sl@0
    98
sl@0
    99
void CUsbHostAo::DoCancel()
sl@0
   100
	{
sl@0
   101
    __MSFNLOG
sl@0
   102
    iHubDriver.CancelWaitForBusEvent();
sl@0
   103
	}
sl@0
   104
sl@0
   105
sl@0
   106
void CUsbHostAo::RunL()
sl@0
   107
	{
sl@0
   108
    __MSFNLOG
sl@0
   109
sl@0
   110
    TInt status = iStatus.Int();
sl@0
   111
	if (status == KErrNotReady)
sl@0
   112
		{
sl@0
   113
        const TInt KDelay = 500 * 1000;  // in uSecs
sl@0
   114
        User::After(KDelay);
sl@0
   115
        Wait();
sl@0
   116
		return;
sl@0
   117
		}
sl@0
   118
sl@0
   119
    // Let RunError handle any other error
sl@0
   120
    User::LeaveIfError(status);
sl@0
   121
sl@0
   122
    // Process bus event
sl@0
   123
    TRAP(status, iObserver.ProcessBusEventL());
sl@0
   124
	if(status != KErrNone)
sl@0
   125
		{
sl@0
   126
        Wait();
sl@0
   127
		return;
sl@0
   128
		}
sl@0
   129
sl@0
   130
    Wait();
sl@0
   131
	}
sl@0
   132
sl@0
   133
_LIT(KErrLog, "ERROR %d in CActiveUsbHost");
sl@0
   134
sl@0
   135
TInt CUsbHostAo::RunError(TInt aError)
sl@0
   136
	{
sl@0
   137
	__MSFNLOG
sl@0
   138
	RDebug::Print(KErrLog, aError);
sl@0
   139
	return KErrNone;
sl@0
   140
	}
sl@0
   141
sl@0
   142
sl@0
   143