os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cusbmassstoragecontroller.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // CUsbMassStorageController implementation.
31 #include "drivemanager.h"
33 #include "tscsiserverreq.h"
34 #include "tscsiservercmds.h"
35 #include "mserverprotocol.h"
36 #include "cscsiserverprotocol.h"
37 #include "mdevicetransport.h"
38 #include "cbulkonlytransport.h"
40 #include "cusbmassstorageserver.h"
41 #include "cusbmassstoragecontroller.h"
48 CUsbMassStorageController* CUsbMassStorageController::NewL()
51 CUsbMassStorageController* self = new (ELeave) CUsbMassStorageController();
52 CleanupStack::PushL(self);
59 CUsbMassStorageController::CUsbMassStorageController()
64 void CUsbMassStorageController::ConstructL()
67 // TestParser for modifying client behaviour to create BOT 13 Case device
68 // exceptions conditions
69 __TESTMODEPRINT("Test Mode is active");
70 iTestParser = new (ELeave) TTestParser;
77 CUsbMassStorageController::~CUsbMassStorageController()
87 Creates the drive manager, transport, protocol and server
89 @param aMaxDrives Maximum number of Mass Storage drives supported.
91 void CUsbMassStorageController::CreateL(const TLunToDriveMap& aDriveMapping)
94 //Create and init drive manager
95 iDriveManager = CDriveManager::NewL(aDriveMapping);
97 //Create transport and protocol and initialize them
98 __PRINT(_L("CUsbMassStorageController::CreateL: Creating transport and protocol"));
100 iTransport = CBulkOnlyTransport::NewL(aDriveMapping.Count(), *this, iTestParser);
101 iProtocol = CScsiServerProtocol::NewL(*iDriveManager, iTestParser);
103 iTransport = CBulkOnlyTransport::NewL(aDriveMapping.Count(), *this);
104 iProtocol = CScsiServerProtocol::NewL(*iDriveManager);
106 iTransport->RegisterProtocol(*iProtocol);
107 iProtocol->RegisterTransport(iTransport);
109 //Create and start server
110 __PRINT(_L("CUsbMassStorageController::CreateL: Creating server"));
111 iServer = CUsbMassStorageServer::NewLC(*this);
112 CleanupStack::Pop(iServer);
116 Returns a reference to the drive manager
118 @return A reference to the drive manager
120 CDriveManager& CUsbMassStorageController::DriveManager()
123 return *iDriveManager;
127 Starts the transport and initializes the protocol.
129 @param aConfig Reference to Mass Storage configuration data
131 TInt CUsbMassStorageController::Start(const TMassStorageConfig& aConfig)
134 //Save this value for use in the Reset method.
136 TInt err = KErrNotReady;
137 if (iProtocol && iTransport)
139 __PRINT(_L("CUsbMassStorageController::Start: Starting"));
140 iProtocol->SetParameters(aConfig);
141 err = iTransport->Start();
149 TInt CUsbMassStorageController::Stop()
152 TInt err = KErrNotReady;
155 __PRINT(_L("CUsbMassStorageController::Stop: Stopping"));
156 err = iTransport->Stop();
159 iDriveManager->SetCritical(CDriveManager::KAllLuns, EFalse); //unset critical
164 Delete the transport and protocol and start new ones.
166 void CUsbMassStorageController::Reset()
172 //Create transport and protocol and initialize them
173 __PRINT(_L("CUsbMassStorageController::Reset: Creating protocol"));
176 TRAPD(err,iProtocol = CScsiServerProtocol::NewL(*iDriveManager, iTestParser));
178 TRAPD(err,iProtocol = CScsiServerProtocol::NewL(*iDriveManager));
181 __ASSERT_DEBUG(err==KErrNone, User::Invariant());
182 iTransport->RegisterProtocol(*iProtocol);
183 iProtocol->RegisterTransport(iTransport);
184 iProtocol->SetParameters(iConfig);