253
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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 |
/**
|
|
17 |
@file
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32base_private.h>
|
|
23 |
#include <e32std.h>
|
|
24 |
#include <e32std_private.h>
|
|
25 |
|
|
26 |
#include "t_otgdi_fdfactor.h"
|
253
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "t_otgdi_fdfactor_mainTraces.h"
|
|
30 |
#endif
|
0
|
31 |
|
|
32 |
LOCAL_C void DoStartL()
|
|
33 |
{
|
|
34 |
_LIT(KDriverLddFileName,"usbhubdriver");
|
|
35 |
TInt err = User::LoadLogicalDevice(KDriverLddFileName);
|
|
36 |
if(err)
|
|
37 |
{
|
253
|
38 |
OstTrace1(TRACE_NORMAL, DOSTARTL_DOSTARTL, "FDFActor failed to load LDD %d",err);
|
0
|
39 |
}
|
|
40 |
|
|
41 |
// Create active scheduler (to run active objects)
|
|
42 |
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
|
|
43 |
CleanupStack::PushL(scheduler);
|
|
44 |
CActiveScheduler::Install(scheduler);
|
|
45 |
|
|
46 |
TUsbBusObserver myBusObserver; // DS TODO Has null implementations of notification functions
|
|
47 |
|
|
48 |
// Object to watch for attachments, suspending devices soon after they are attached
|
|
49 |
CActorFDF* myFdfActor=CActorFDF::NewL(myBusObserver);
|
|
50 |
CleanupStack::PushL(myFdfActor);
|
|
51 |
|
|
52 |
// Object to watch for a rendezvous with the t_otgdi.exe process
|
|
53 |
// (indicating no further need for FDF Actor)
|
|
54 |
// Stops the active scheduler when t_otgdi.exe signals rendezvous
|
|
55 |
CFdfTOtgdiWatcher* myCFdfTOtgdiWatcher = CFdfTOtgdiWatcher::NewL();
|
|
56 |
CleanupStack::PushL(myCFdfTOtgdiWatcher);
|
|
57 |
|
|
58 |
myFdfActor->Monitor();
|
|
59 |
// Signal back to t_otgdi.exe that we're up and running, ready to deal with device attach/detach
|
|
60 |
RProcess::Rendezvous(KErrNone);
|
|
61 |
|
|
62 |
CActiveScheduler::Start();
|
|
63 |
|
|
64 |
// Delete active scheduler
|
|
65 |
CleanupStack::PopAndDestroy(3, scheduler);
|
|
66 |
|
|
67 |
err = User::FreeLogicalDevice(RUsbHubDriver::Name());
|
|
68 |
if(err)
|
|
69 |
{
|
253
|
70 |
OstTrace1(TRACE_NORMAL, DOSTARTL_DOSTARTL_DUP01, "FDFActor failed to unload LDD %d",err);
|
0
|
71 |
}
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
// Global Functions
|
|
76 |
|
|
77 |
GLDEF_C TInt E32Main()
|
|
78 |
{
|
|
79 |
// Create cleanup stack
|
|
80 |
__UHEAP_MARK;
|
|
81 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
82 |
|
|
83 |
TRAPD(mainError,DoStartL());
|
|
84 |
|
|
85 |
|
|
86 |
if (mainError)
|
|
87 |
{
|
253
|
88 |
OstTrace1(TRACE_NORMAL, E32MAIN_E32MAIN, "FDF Actor left with %d", mainError);
|
0
|
89 |
// Also means that we left before we did a Rendezvous(KErrNone) to free up t_otgdi.exe
|
|
90 |
// Rendezvous with KErrAbort to indicate we couldn't start up properly.
|
|
91 |
RProcess::Rendezvous(KErrAbort);
|
|
92 |
}
|
|
93 |
|
|
94 |
delete cleanup;
|
|
95 |
__UHEAP_MARKEND;
|
|
96 |
|
253
|
97 |
OstTrace0(TRACE_NORMAL, E32MAIN_E32MAIN_DUP01, "About to end FDFActor process");
|
0
|
98 |
return KErrNone;
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
|