sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // USB Mass Storage Application - also used as an improvised boot loader mechanism sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "rusbhostmsdevice.h" sl@0: #include "rusbhostmslogicalunit.h" sl@0: sl@0: #include sl@0: #include "usbtypes.h" sl@0: #include "rextfilesystem.h" sl@0: #include "cusbmsmountmanager.h" sl@0: sl@0: #include "mdrivedisplay.h" sl@0: #include "cusbhostao.h" sl@0: #include "cusbhost.h" sl@0: sl@0: #include "rusbotgsession.h" sl@0: sl@0: #include "cdisplay.h" sl@0: #include "husbconsapp.h" sl@0: #include "tmslog.h" sl@0: sl@0: sl@0: _LIT(KTxtApp,"HOST USB CONSOLE APP"); sl@0: sl@0: sl@0: sl@0: CHeartBeat* CHeartBeat::NewLC(CDisplay& aDisplay) sl@0: { sl@0: CHeartBeat* me = new(ELeave) CHeartBeat(aDisplay); sl@0: CleanupStack::PushL(me); sl@0: me->ConstructL(); sl@0: return me; sl@0: } sl@0: sl@0: sl@0: CHeartBeat::CHeartBeat(CDisplay& aDisplay) sl@0: : CActive(0), sl@0: iDisplay(aDisplay) sl@0: {} sl@0: sl@0: sl@0: void CHeartBeat::ConstructL() sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: iTimer.CreateLocal(); sl@0: RunL(); sl@0: } sl@0: sl@0: sl@0: CHeartBeat::~CHeartBeat() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: sl@0: void CHeartBeat::DoCancel() sl@0: { sl@0: iTimer.Cancel(); sl@0: } sl@0: sl@0: sl@0: void CHeartBeat::RunL() sl@0: { sl@0: SetActive(); sl@0: // Print RAM usage & up time sl@0: iUpTime++; sl@0: iDisplay.UpTime(iUpTime); sl@0: sl@0: TInt mem=0; sl@0: if (HAL::Get(HALData::EMemoryRAMFree, mem)==KErrNone) sl@0: { sl@0: iDisplay.MemoryFree(mem); sl@0: } sl@0: iTimer.After(iStatus, 1000000); sl@0: } sl@0: sl@0: sl@0: GLDEF_C void RunAppL() sl@0: { sl@0: __MSFNSLOG sl@0: CActiveScheduler* sched = new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(sched); sl@0: CActiveScheduler::Install(sched); sl@0: sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: RUsbOtgSession usbOtgSession; sl@0: TInt err = usbOtgSession.Connect(); sl@0: User::LeaveIfError(err); sl@0: sl@0: CConsoleBase* console; sl@0: console = Console::NewL(KTxtApp, TSize(KConsFullScreen,KConsFullScreen)); sl@0: CleanupStack::PushL(console); sl@0: sl@0: CDisplay* display = CDisplay::NewLC(fs, *console); sl@0: CMessageKeyProcessor::NewLC(*display, usbOtgSession); sl@0: CHeartBeat::NewLC(*display); sl@0: sl@0: display->Menu(); sl@0: display->DriveListL(); sl@0: sl@0: sl@0: CUsbHostDisp* usbHost = CUsbHostDisp::NewL(*display); sl@0: CleanupStack::PushL(usbHost); sl@0: sl@0: usbHost->Start(); sl@0: sl@0: // ************************************************************************* sl@0: // Start Active Scheduler sl@0: // ************************************************************************* sl@0: CActiveScheduler::Start(); sl@0: sl@0: // 1 sec delay for sessions to stop sl@0: User::After(1000000); sl@0: CleanupStack::PopAndDestroy(usbHost); sl@0: CleanupStack::PopAndDestroy(); // CPeriodUpdate sl@0: CleanupStack::PopAndDestroy(); // CMessageKeyProcessor sl@0: CleanupStack::PopAndDestroy(); // CDisplay sl@0: CleanupStack::PopAndDestroy(console); sl@0: CleanupStack::PopAndDestroy(); // fs sl@0: CleanupStack::PopAndDestroy(sched); sl@0: } sl@0: sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: TRAPD(error, RunAppL()); sl@0: __ASSERT_ALWAYS(!error, User::Panic(KTxtApp, error)); sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: return 0; sl@0: }