Update contrib.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <e32base_private.h>
18 #include "usbmsshared.h"
19 #include "cusbmassstoragescheduler.h"
20 #include "t_cusbmassstoragecontroller.h"
21 #include "cusbmassstorageserver.h"
23 LOCAL_C void RunServerL();
25 GLDEF_C TInt E32Main()
27 * Entry-point for the USB Manager server.
29 * @return The result of UsbMan::Run
34 CTrapCleanup* cleanup = CTrapCleanup::New();
36 TInt ret = KErrNoMemory;
40 TRAP(ret, RunServerL());
49 static void RunServerL()
51 // Perform all server initialisation, in particular creation of the
52 // scheduler and server and then run the scheduler
55 // naming the server thread after the server helps to debug panics
56 User::LeaveIfError(RThread().RenameMe(KUsbMsServerName));
58 // create and install the active scheduler we need
59 CUsbMassStorageScheduler* scheduler = CUsbMassStorageScheduler::NewL();
60 CleanupStack::PushL(scheduler);
61 CUsbMassStorageScheduler::Install(scheduler);
63 // create the server (leave it on the cleanup stack)
64 CUsbMassStorageController* msController = CUsbMassStorageController::NewL();
65 CleanupStack::PushL(msController);
67 CUsbMassStorageServer* server = CUsbMassStorageServer::NewLC(*msController);
68 scheduler->SetServer(*server);
70 // Initialisation complete, now signal the client
71 #ifdef __USBMS_NO_PROCESSES__
72 RThread::Rendezvous(KErrNone);
74 RProcess::Rendezvous(KErrNone);
79 CActiveScheduler::Start();
81 // Cleanup the server, mscontroller and scheduler
82 CleanupStack::PopAndDestroy(3, scheduler);
85 #ifdef __USBMS_NO_PROCESSES__
87 // The server binary is an "EPOCEXE" target type
88 // Thus the server parameter passing and startup code for WINS and EPOC are
89 // significantly different.
91 // In EKA1 WINS, the EPOCEXE target is a DLL with an entry point called WinsMain,
92 // taking no parameters and returning TInt. This is not really valid as a thread
93 // function which takes a TAny* parameter which we need.
95 // So the DLL entry-point WinsMain() is used to return a TInt representing the
96 // real thread function within the DLL. This is good as long as
97 // sizeof(TInt)>=sizeof(TThreadFunction).
100 static TInt ThreadFunction(TAny* /*aPtr*/)
102 // WINS thread entry-point function.
108 IMPORT_C TInt WinsMain();
109 EXPORT_C TInt WinsMain()
111 // WINS DLL entry-point. Just return the real thread function
115 return reinterpret_cast<TInt>(&ThreadFunction);
118 TInt E32Dll(TDllReason)