46 |
51 |
47 @return TInt |
52 @return TInt |
48 */ |
53 */ |
49 EXPORT_C TInt RUsbHostMsLogicalUnit::Initialise(const RMessage2& aMsg, |
54 EXPORT_C TInt RUsbHostMsLogicalUnit::Initialise(const RMessage2& aMsg, |
50 TInt aDevHandleIndex, |
55 TInt aDevHandleIndex, |
51 TUint32 aLun) |
56 TUint32 aLun) |
52 { |
57 { |
53 __FNLOG("RUsbHostMsLogicalUnit::Initialise"); |
58 TInt r = dev.Open(aMsg, aDevHandleIndex); |
54 TInt r = dev.Open(aMsg, aDevHandleIndex); |
59 if (r != KErrNone) |
55 if (r != KErrNone) |
60 { |
56 { |
61 OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_11, |
57 __PRINT1(_L("Session handle can not be opened %d"),r); |
62 "Session handle can not be opened %d", r); |
58 return r; |
63 return r; |
59 } |
64 } |
60 |
65 |
61 r = CreateSubSession(dev, EUsbHostMsRegisterLun, TIpcArgs(aLun)); |
66 r = CreateSubSession(dev, EUsbHostMsRegisterLun, TIpcArgs(aLun)); |
62 if (r != KErrNone) |
67 if (r != KErrNone) |
63 { |
68 { |
64 __PRINT1(_L("SubSession creation failed %d"),r); |
69 OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_12, |
65 return r; |
70 "SubSession creation failed %d", r); |
66 } |
71 return r; |
67 return r; |
72 } |
68 } |
73 return r; |
|
74 } |
69 |
75 |
70 |
76 |
71 /** |
77 /** |
72 Send a command to read the Mass Storage device. |
78 Send a command to read the Mass Storage device. |
73 |
79 |
74 @param aPos Position to start reading from |
80 @param aPos Position to start reading from |
75 @param aLength Number of Bytes |
81 @param aLength Number of Bytes |
76 @param aTrg Buffer to copy data to |
82 @param aTrg Buffer to copy data to |
77 |
83 |
78 @return TInt KErrNone, if the send operation is successful; |
84 @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; |
85 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available; |
80 KErrNoMemory, if there is insufficient memory available. |
86 KErrNoMemory, if there is insufficient memory available. |
81 */ |
87 */ |
82 EXPORT_C TInt RUsbHostMsLogicalUnit::Read(TInt64 aPos, TInt aLength, TDes8& aTrg) |
88 EXPORT_C TInt RUsbHostMsLogicalUnit::Read(TInt64 aPos, TInt aLength, TDes8& aTrg) |
83 { |
89 { |
84 __FNLOG("RUsbHostMsLogicalUnit::Read"); |
90 TReadWrite data; |
85 |
91 data.iPos = aPos; |
86 TReadWrite data; |
92 data.iLen = aLength; |
87 data.iPos = aPos; |
93 |
88 data.iLen = aLength; |
94 OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_21, |
89 |
95 "pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen); |
90 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen); |
96 |
91 |
97 TPckg<TReadWrite> pckg(data); |
92 TPckg<TReadWrite> pckg(data); |
98 /* We handle the message asynchronously in the thread modelled MSC */ |
93 /* We handle the message asynchronously in the thread modelled MSC */ |
99 TRequestStatus status; |
94 TRequestStatus status; |
100 SendReceive(EUsbHostMsRead, TIpcArgs(&pckg, &aTrg), status); |
95 SendReceive(EUsbHostMsRead, TIpcArgs(&pckg, &aTrg), status); |
101 User::WaitForRequest(status); |
96 User::WaitForRequest(status); |
102 OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_22, |
97 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen); |
103 "pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen); |
98 return status.Int(); |
104 return status.Int(); |
99 } |
105 } |
100 |
106 |
101 |
107 |
102 /** |
108 /** |
103 Send a command to write to the Mass Storage device. |
109 Send a command to write to the Mass Storage device. |
104 |
110 |
105 @param aPos Position to start reading from |
111 @param aPos Position to start reading from |
106 @param aLength Number of Bytes |
112 @param aLength Number of Bytes |
107 @param aTrg Buffer to copy data from |
113 @param aTrg Buffer to copy data from |
108 |
114 |
109 @return TInt KErrNone, if the send operation is successful; |
115 @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; |
116 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available; |
111 KErrNoMemory, if there is insufficient memory available. |
117 KErrNoMemory, if there is insufficient memory available. |
112 available. |
118 available. |
113 */ |
119 */ |
114 EXPORT_C TInt RUsbHostMsLogicalUnit::Write(TInt64 aPos, TInt aLength, const TDesC8& aTrg) |
120 EXPORT_C TInt RUsbHostMsLogicalUnit::Write(TInt64 aPos, TInt aLength, const TDesC8& aTrg) |
115 { |
121 { |
116 __FNLOG("RUsbHostMsLogicalUnit::Write"); |
122 TReadWrite data; |
117 |
123 data.iPos = aPos; |
118 TReadWrite data; |
124 data.iLen = aLength; |
119 data.iPos = aPos; |
125 |
120 data.iLen = aLength; |
126 OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_23, |
121 |
127 "pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen); |
122 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen); |
128 |
123 |
129 |
124 TPckg<TReadWrite> pckg(data); |
130 TPckg<TReadWrite> pckg(data); |
125 /* We handle the message asynchronously in the thread modelled MSC */ |
131 /* We handle the message asynchronously in the thread modelled MSC */ |
126 TRequestStatus status; |
132 TRequestStatus status; |
127 SendReceive(EUsbHostMsWrite, TIpcArgs(&aTrg, &pckg), status); |
133 SendReceive(EUsbHostMsWrite, TIpcArgs(&aTrg, &pckg), status); |
128 User::WaitForRequest(status); |
134 User::WaitForRequest(status); |
129 return status.Int(); |
135 return status.Int(); |
130 } |
136 } |
131 |
137 |
132 |
138 |
133 /** |
139 /** |
134 Send a command to erase an area of the Mass Storage device. |
140 Send a command to erase an area of the Mass Storage device. |
135 |
141 |
136 @param aPos Position to start reading from |
142 @param aPos Position to start reading from |
137 @param aLength Number of Bytes |
143 @param aLength Number of Bytes |
138 |
144 |
139 @return TInt KErrNone, if the send operation is successful; |
145 @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; |
146 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available; |
141 KErrNoMemory, if there is insufficient memory available. |
147 KErrNoMemory, if there is insufficient memory available. |
142 available. |
148 available. |
143 */ |
149 */ |
144 EXPORT_C TInt RUsbHostMsLogicalUnit::Erase(TInt64 aPos, TInt aLength) |
150 EXPORT_C TInt RUsbHostMsLogicalUnit::Erase(TInt64 aPos, TInt aLength) |
145 { |
151 { |
146 __FNLOG("RUsbHostMsLogicalUnit::Erase"); |
152 TReadWrite data; |
147 |
153 data.iPos = aPos; |
148 TReadWrite data; |
154 data.iLen = aLength; |
149 data.iPos = aPos; |
155 |
150 data.iLen = aLength; |
156 OstTraceExt3(TRACE_SHOSTMASSSTORAGE_HOST, RUSBHOSTMSLOGICALUNIT_24, |
151 |
157 "pos = 0x%x %x, len = x%x", I64HIGH(data.iPos), I64LOW(data.iPos), data.iLen); |
152 __PRINT2(_L("pos = 0x%lx, len = x%x"), data.iPos, data.iLen); |
158 |
153 |
159 TPckg<TReadWrite> pckg(data); |
154 TPckg<TReadWrite> pckg(data); |
160 /* We handle the message asynchronously in the thread modelled MSC */ |
155 /* We handle the message asynchronously in the thread modelled MSC */ |
161 TRequestStatus status; |
156 TRequestStatus status; |
162 SendReceive(EUsbHostMsErase, TIpcArgs(&pckg), status); |
157 SendReceive(EUsbHostMsErase, TIpcArgs(&pckg), status); |
163 User::WaitForRequest(status); |
158 User::WaitForRequest(status); |
164 return status.Int(); |
159 return status.Int(); |
165 } |
160 } |
|
161 |
166 |
162 |
167 |
163 /** |
168 /** |
164 Send a command to get the nedia's capacity info. |
169 Send a command to get the nedia's capacity info. |
165 |
170 |
169 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there |
174 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there |
170 are no message slots available; KErrNoMemory, if there is insufficient memory |
175 are no message slots available; KErrNoMemory, if there is insufficient memory |
171 available. |
176 available. |
172 */ |
177 */ |
173 EXPORT_C TInt RUsbHostMsLogicalUnit::Caps(TCapsInfo& aCapsInfo) |
178 EXPORT_C TInt RUsbHostMsLogicalUnit::Caps(TCapsInfo& aCapsInfo) |
174 { |
179 { |
175 __FNLOG("RUsbHostMsLogicalUnit::Caps"); |
|
176 |
|
177 TPckg<TCapsInfo> data(aCapsInfo); |
180 TPckg<TCapsInfo> data(aCapsInfo); |
178 |
181 |
179 /* We handle the message asynchronously in the thread modelled MSC */ |
182 /* We handle the message asynchronously in the thread modelled MSC */ |
180 TRequestStatus status; |
183 TRequestStatus status; |
181 SendReceive(EUsbHostMsCapacity, TIpcArgs(&data),status); |
184 SendReceive(EUsbHostMsCapacity, TIpcArgs(&data),status); |
182 User::WaitForRequest(status); |
185 User::WaitForRequest(status); |
183 return status.Int(); |
186 return status.Int(); |
184 } |
187 } |
185 |
188 |
186 /** |
189 /** |
187 Request notification of media change to the file server |
190 Request notification of media change to the file server |
188 |
191 |
189 @param aChanged The descriptor pointing to iChanged flag in TDrive to be updated |
192 @param aChanged The descriptor pointing to iChanged flag in TDrive to be updated |
190 when error occurs during read or write. |
193 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; |
194 @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; |
195 KErrServerTerminated, if the server no longer present; KErrServerBusy, if there are no message slots available; |
193 KErrNoMemory, if there is insufficient memory available. |
196 KErrNoMemory, if there is insufficient memory available. |
194 @return None |
197 @return None |
195 */ |
198 */ |
196 EXPORT_C void RUsbHostMsLogicalUnit::NotifyChange(TDes8& aChanged, TRequestStatus &aStatus) |
199 EXPORT_C void RUsbHostMsLogicalUnit::NotifyChange(TDes8& aChanged, TRequestStatus &aStatus) |
197 { |
200 { |
198 __FNLOG("RUsbHostMsLogicalUnit::NotifyChange"); |
201 SendReceive(EUsbHostMsNotifyChange, TIpcArgs(&aChanged), aStatus); |
199 |
202 } |
200 SendReceive(EUsbHostMsNotifyChange, TIpcArgs(&aChanged), aStatus); |
|
201 } |
|
202 |
203 |
203 /** |
204 /** |
204 Request to suspend the logical unit associated with this drive |
205 Request to suspend the logical unit associated with this drive |
205 */ |
206 */ |
206 EXPORT_C void RUsbHostMsLogicalUnit::SuspendLun() |
207 EXPORT_C void RUsbHostMsLogicalUnit::SuspendLun() |
207 { |
208 { |
208 __FNLOG("RUsbHostMsLogicalUnit::SuspendLun"); |
209 SendReceive(EUsbHostMsSuspendLun, TIpcArgs(NULL)); |
209 |
210 } |
210 SendReceive(EUsbHostMsSuspendLun, TIpcArgs(NULL)); |
|
211 } |
|
212 |
211 |
213 /** |
212 /** |
214 Close the sub-session. |
213 Close the sub-session. |
215 |
214 |
216 @return TInt KErrNone |
215 @return TInt KErrNone |
217 */ |
216 */ |
218 EXPORT_C TInt RUsbHostMsLogicalUnit::UnInitialise() |
217 EXPORT_C TInt RUsbHostMsLogicalUnit::UnInitialise() |
219 { |
218 { |
220 __FNLOG("RUsbHostMsLogicalUnit::UnInitialise"); |
219 CloseSubSession(EUsbHostMsUnRegisterLun); |
221 |
220 dev.Close(); |
222 CloseSubSession(EUsbHostMsUnRegisterLun); |
221 return KErrNone; |
223 dev.Close(); |
222 } |
224 return KErrNone; |
|
225 } |
|
226 |
223 |
227 |
224 |
228 /** |
225 /** |
229 Request that the drive is remounted. |
226 Request that the drive is remounted. |
230 |
227 |