0
|
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 |
// USB Mass Storage Application - also used as an improvised boot loader mechanism
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <e32cons.h>
|
|
25 |
#include <hal.h>
|
|
26 |
#include <f32file.h>
|
|
27 |
|
|
28 |
#include "rusbhostmsdevice.h"
|
|
29 |
#include "rusbhostmslogicalunit.h"
|
|
30 |
|
|
31 |
#include <d32usbdi_hubdriver.h>
|
|
32 |
#include "usbtypes.h"
|
|
33 |
#include "rextfilesystem.h"
|
|
34 |
#include "cusbmsmountmanager.h"
|
|
35 |
|
|
36 |
#include "mdrivedisplay.h"
|
|
37 |
#include "cusbhostao.h"
|
|
38 |
#include "cusbhost.h"
|
|
39 |
|
|
40 |
#include "rusbotgsession.h"
|
|
41 |
|
|
42 |
#include "cdisplay.h"
|
|
43 |
#include "husbconsapp.h"
|
|
44 |
#include "tmslog.h"
|
|
45 |
|
|
46 |
|
|
47 |
_LIT(KTxtApp,"HOST USB CONSOLE APP");
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
CHeartBeat* CHeartBeat::NewLC(CDisplay& aDisplay)
|
|
52 |
{
|
|
53 |
CHeartBeat* me = new(ELeave) CHeartBeat(aDisplay);
|
|
54 |
CleanupStack::PushL(me);
|
|
55 |
me->ConstructL();
|
|
56 |
return me;
|
|
57 |
}
|
|
58 |
|
|
59 |
|
|
60 |
CHeartBeat::CHeartBeat(CDisplay& aDisplay)
|
|
61 |
: CActive(0),
|
|
62 |
iDisplay(aDisplay)
|
|
63 |
{}
|
|
64 |
|
|
65 |
|
|
66 |
void CHeartBeat::ConstructL()
|
|
67 |
{
|
|
68 |
CActiveScheduler::Add(this);
|
|
69 |
iTimer.CreateLocal();
|
|
70 |
RunL();
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
CHeartBeat::~CHeartBeat()
|
|
75 |
{
|
|
76 |
Cancel();
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
void CHeartBeat::DoCancel()
|
|
81 |
{
|
|
82 |
iTimer.Cancel();
|
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
void CHeartBeat::RunL()
|
|
87 |
{
|
|
88 |
SetActive();
|
|
89 |
// Print RAM usage & up time
|
|
90 |
iUpTime++;
|
|
91 |
iDisplay.UpTime(iUpTime);
|
|
92 |
|
|
93 |
TInt mem=0;
|
|
94 |
if (HAL::Get(HALData::EMemoryRAMFree, mem)==KErrNone)
|
|
95 |
{
|
|
96 |
iDisplay.MemoryFree(mem);
|
|
97 |
}
|
|
98 |
iTimer.After(iStatus, 1000000);
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
GLDEF_C void RunAppL()
|
|
103 |
{
|
|
104 |
__MSFNSLOG
|
|
105 |
CActiveScheduler* sched = new(ELeave) CActiveScheduler;
|
|
106 |
CleanupStack::PushL(sched);
|
|
107 |
CActiveScheduler::Install(sched);
|
|
108 |
|
|
109 |
RFs fs;
|
|
110 |
User::LeaveIfError(fs.Connect());
|
|
111 |
CleanupClosePushL(fs);
|
|
112 |
|
|
113 |
RUsbOtgSession usbOtgSession;
|
|
114 |
TInt err = usbOtgSession.Connect();
|
|
115 |
User::LeaveIfError(err);
|
|
116 |
|
|
117 |
CConsoleBase* console;
|
|
118 |
console = Console::NewL(KTxtApp, TSize(KConsFullScreen,KConsFullScreen));
|
|
119 |
CleanupStack::PushL(console);
|
|
120 |
|
|
121 |
CDisplay* display = CDisplay::NewLC(fs, *console);
|
|
122 |
CMessageKeyProcessor::NewLC(*display, usbOtgSession);
|
|
123 |
CHeartBeat::NewLC(*display);
|
|
124 |
|
|
125 |
display->Menu();
|
|
126 |
display->DriveListL();
|
|
127 |
|
|
128 |
|
|
129 |
CUsbHostDisp* usbHost = CUsbHostDisp::NewL(*display);
|
|
130 |
CleanupStack::PushL(usbHost);
|
|
131 |
|
|
132 |
usbHost->Start();
|
|
133 |
|
|
134 |
// *************************************************************************
|
|
135 |
// Start Active Scheduler
|
|
136 |
// *************************************************************************
|
|
137 |
CActiveScheduler::Start();
|
|
138 |
|
|
139 |
// 1 sec delay for sessions to stop
|
|
140 |
User::After(1000000);
|
|
141 |
CleanupStack::PopAndDestroy(usbHost);
|
|
142 |
CleanupStack::PopAndDestroy(); // CPeriodUpdate
|
|
143 |
CleanupStack::PopAndDestroy(); // CMessageKeyProcessor
|
|
144 |
CleanupStack::PopAndDestroy(); // CDisplay
|
|
145 |
CleanupStack::PopAndDestroy(console);
|
|
146 |
CleanupStack::PopAndDestroy(); // fs
|
|
147 |
CleanupStack::PopAndDestroy(sched);
|
|
148 |
}
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
GLDEF_C TInt E32Main()
|
|
153 |
{
|
|
154 |
__UHEAP_MARK;
|
|
155 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
156 |
TRAPD(error, RunAppL());
|
|
157 |
__ASSERT_ALWAYS(!error, User::Panic(KTxtApp, error));
|
|
158 |
delete cleanup;
|
|
159 |
__UHEAP_MARKEND;
|
|
160 |
return 0;
|
|
161 |
}
|