os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/client/rusbhostmslogicalunit.cpp
Update contrib.
1 // Copyright (c) 2008-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.
23 #include "msgservice.h"
24 #include "rusbhostmsdevice.h"
25 #include "rusbhostmslogicalunit.h"
28 TVersion RUsbHostMsLogicalUnit::Version() const
30 return(TVersion(KUsbHostMsSrvMajorVersionNumber,
31 KUsbHostMsSrvMinorVersionNumber,
32 KUsbHostMsSrvBuildVersionNumber));
35 EXPORT_C RUsbHostMsLogicalUnit::RUsbHostMsLogicalUnit()
37 // Intentionally left blank
41 Send a command to initialise the Mass Storage device.
44 @param aDevHandleIndex
49 EXPORT_C TInt RUsbHostMsLogicalUnit::Initialise(const RMessage2& aMsg,
53 __FNLOG("RUsbHostMsLogicalUnit::Initialise");
54 TInt r = dev.Open(aMsg, aDevHandleIndex);
57 __PRINT1(_L("Session handle can not be opened %d"),r);
61 r = CreateSubSession(dev, EUsbHostMsRegisterLun, TIpcArgs(aLun));
64 __PRINT1(_L("SubSession creation failed %d"),r);
72 Send a command to read the Mass Storage device.
74 @param aPos Position to start reading from
75 @param aLength Number of Bytes
76 @param aTrg Buffer to copy data to
78 @return TInt KErrNone, if the send operation is successful;
79 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
80 KErrNoMemory, if there is insufficient memory available.
82 EXPORT_C TInt RUsbHostMsLogicalUnit::Read(TInt64 aPos, TInt aLength, TDes8& aTrg)
84 __FNLOG("RUsbHostMsLogicalUnit::Read");
90 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen);
92 TPckg<TReadWrite> pckg(data);
93 /* We handle the message asynchronously in the thread modelled MSC */
94 TRequestStatus status;
95 SendReceive(EUsbHostMsRead, TIpcArgs(&pckg, &aTrg), status);
96 User::WaitForRequest(status);
97 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen);
103 Send a command to write to the Mass Storage device.
105 @param aPos Position to start reading from
106 @param aLength Number of Bytes
107 @param aTrg Buffer to copy data from
109 @return TInt KErrNone, if the send operation is successful;
110 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
111 KErrNoMemory, if there is insufficient memory available.
114 EXPORT_C TInt RUsbHostMsLogicalUnit::Write(TInt64 aPos, TInt aLength, const TDesC8& aTrg)
116 __FNLOG("RUsbHostMsLogicalUnit::Write");
122 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen);
124 TPckg<TReadWrite> pckg(data);
125 /* We handle the message asynchronously in the thread modelled MSC */
126 TRequestStatus status;
127 SendReceive(EUsbHostMsWrite, TIpcArgs(&aTrg, &pckg), status);
128 User::WaitForRequest(status);
134 Send a command to erase an area of the Mass Storage device.
136 @param aPos Position to start reading from
137 @param aLength Number of Bytes
139 @return TInt KErrNone, if the send operation is successful;
140 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
141 KErrNoMemory, if there is insufficient memory available.
144 EXPORT_C TInt RUsbHostMsLogicalUnit::Erase(TInt64 aPos, TInt aLength)
146 __FNLOG("RUsbHostMsLogicalUnit::Erase");
152 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen);
154 TPckg<TReadWrite> pckg(data);
155 /* We handle the message asynchronously in the thread modelled MSC */
156 TRequestStatus status;
157 SendReceive(EUsbHostMsErase, TIpcArgs(&pckg), status);
158 User::WaitForRequest(status);
164 Send a command to get the nedia's capacity info.
166 @param aCapsInfo [OUT] A buffer to copy the capacity info to.
168 @return TInt KErrNone, if the send operation is successful;
169 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there
170 are no message slots available; KErrNoMemory, if there is insufficient memory
173 EXPORT_C TInt RUsbHostMsLogicalUnit::Caps(TCapsInfo& aCapsInfo)
175 __FNLOG("RUsbHostMsLogicalUnit::Caps");
177 TPckg<TCapsInfo> data(aCapsInfo);
179 /* We handle the message asynchronously in the thread modelled MSC */
180 TRequestStatus status;
181 SendReceive(EUsbHostMsCapacity, TIpcArgs(&data),status);
182 User::WaitForRequest(status);
187 Request notification of media change to the file server
189 @param aChanged The descriptor pointing to iChanged flag in TDrive to be updated
190 when error occurs during read or write.
191 @param aStatus The request status This is set to KErrNone on completion, or KErrCancel when the logical unit is closed;
192 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available;
193 KErrNoMemory, if there is insufficient memory available.
196 EXPORT_C void RUsbHostMsLogicalUnit::NotifyChange(TDes8& aChanged, TRequestStatus &aStatus)
198 __FNLOG("RUsbHostMsLogicalUnit::NotifyChange");
200 SendReceive(EUsbHostMsNotifyChange, TIpcArgs(&aChanged), aStatus);
204 Request to suspend the logical unit associated with this drive
206 EXPORT_C void RUsbHostMsLogicalUnit::SuspendLun()
208 __FNLOG("RUsbHostMsLogicalUnit::SuspendLun");
210 SendReceive(EUsbHostMsSuspendLun, TIpcArgs(NULL));
214 Close the sub-session.
216 @return TInt KErrNone
218 EXPORT_C TInt RUsbHostMsLogicalUnit::UnInitialise()
220 __FNLOG("RUsbHostMsLogicalUnit::UnInitialise");
222 CloseSubSession(EUsbHostMsUnRegisterLun);
229 Request that the drive is remounted.
231 @param aFlags Flags to be passed to the drive
233 @return EXPORT_C TInt KErrNone, if the send operation is successful;
234 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there
235 are no message slots available; KErrNoMemory, if there is insufficient memory
238 EXPORT_C TInt RUsbHostMsLogicalUnit::ForceRemount(TUint aFlags)
240 __FNLOG("RUsbHostMsLogicalUnit::ForceRemount");
242 __PRINT1(_L("flags = %d"), aFlags);
244 TRequestStatus status;
245 SendReceive(EUsbHostMsForceRemount, TIpcArgs(aFlags), status);
246 User::WaitForRequest(status);
250 EXPORT_C void RUsbHostMsLogicalUnit::NotifyChangeCancel()
252 __FNLOG("RUsbHostMsLogicalUnit::NotifyChangeCancel");
253 SendReceive(EUsbHostMsCancelChangeNotifier, TIpcArgs(NULL));