1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1222 /** |
1226 /** |
1223 Command Parser for the MODE SENSE(06) command (0x1A) |
1227 Command Parser for the MODE SENSE(06) command (0x1A) |
1224 |
1228 |
1225 @return ETrue if successful. |
1229 @return ETrue if successful. |
1226 */ |
1230 */ |
1227 TBool CScsiProtocol::HandleModeSense(TPtrC8& aData, TUint aLun) |
1231 TBool CScsiProtocol::HandleModeSense6(TPtrC8& aData, TUint aLun) |
1228 { |
1232 { |
1229 __FNLOG("CScsiProtocol::HandleModeSense"); |
1233 __FNLOG("CScsiProtocol::HandleModeSense6"); |
1230 |
1234 |
1231 TInt pageCode = aData[3] & 0x3F; |
1235 TInt pageCode = aData[3] & 0x3F; |
1232 TUint8 pageControl= static_cast<TUint8>(aData[3] >>6); |
1236 TUint8 pageControl= static_cast<TUint8>(aData[3] >>6); |
1233 |
1237 |
1234 // reserve 4 bytes for Length, Media type, Device-specific parameter and Block descriptor length |
|
1235 |
|
1236 if (pageCode != KAllPages || pageControl == KChangeableValues) |
1238 if (pageCode != KAllPages || pageControl == KChangeableValues) |
1237 { |
1239 { |
1238 __PRINT(_L("TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb")); |
1240 __PRINT(_L("TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb")); |
1239 iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb); |
1241 iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb); |
1240 return EFalse; |
1242 return EFalse; |
1241 } |
1243 } |
1242 |
1244 |
|
1245 // reserve 4 bytes for Length, Media type, Device-specific parameter and Block descriptor length |
1243 TPtr8 writeBuf(NULL, 0); |
1246 TPtr8 writeBuf(NULL, 0); |
1244 iTransport->GetCommandBufPtr(writeBuf, KModeSenseCommandLength); |
1247 iTransport->GetCommandBufPtr(writeBuf, KModeSense6CommandLength); |
1245 writeBuf.FillZ(KModeSenseCommandLength); |
1248 writeBuf.FillZ(KModeSense6CommandLength); |
1246 |
1249 |
1247 if (pageControl != KDefaultValues) |
1250 if (pageControl != KDefaultValues) |
1248 { |
1251 { |
1249 //check if drive write protected |
1252 //check if drive write protected |
1250 CMassStorageDrive* drive=GetCheckDrive(aLun); |
1253 CMassStorageDrive* drive=GetCheckDrive(aLun); |
1277 |
1280 |
1278 return (iSenseInfo.SenseOk()); |
1281 return (iSenseInfo.SenseOk()); |
1279 } |
1282 } |
1280 |
1283 |
1281 |
1284 |
|
1285 /** |
|
1286 Command Parser for the MODE SENSE(10) command (0x5A) |
|
1287 |
|
1288 @return ETrue if successful. |
|
1289 */ |
|
1290 TBool CScsiProtocol::HandleModeSense10(TPtrC8& aData, TUint aLun) |
|
1291 { |
|
1292 __FNLOG("CScsiProtocol::HandleModeSense10"); |
|
1293 |
|
1294 TInt pageCode = aData[3] & 0x3F; |
|
1295 TUint8 pageControl= static_cast<TUint8>(aData[3] >>6); |
|
1296 |
|
1297 if (pageCode != KAllPages || pageControl == KChangeableValues) |
|
1298 { |
|
1299 __PRINT(_L("TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb")); |
|
1300 iSenseInfo.SetSense(TSenseInfo::EIllegalRequest,TSenseInfo::EInvalidFieldInCdb); |
|
1301 return EFalse; |
|
1302 } |
|
1303 |
|
1304 // reserve 8 bytes for Length, Media type, Device-specific parameter and Block descriptor length |
|
1305 TPtr8 writeBuf(NULL, 0); |
|
1306 iTransport->GetCommandBufPtr(writeBuf, KModeSense10CommandLength); |
|
1307 writeBuf.FillZ(KModeSense10CommandLength); |
|
1308 |
|
1309 if (pageControl != KDefaultValues) |
|
1310 { |
|
1311 //check if drive write protected |
|
1312 CMassStorageDrive* drive=GetCheckDrive(aLun); |
|
1313 if (drive == NULL) |
|
1314 { |
|
1315 __PRINT(_L("drive == null")); |
|
1316 return EFalse; |
|
1317 } |
|
1318 |
|
1319 TLocalDriveCapsV4 driveInfo; |
|
1320 TInt err = drive->Caps(driveInfo); |
|
1321 if (err != KErrNone) |
|
1322 { |
|
1323 __PRINT(_L("TSenseInfo::ENotReady")); |
|
1324 iSenseInfo.SetSense(TSenseInfo::ENotReady, TSenseInfo::EMediaNotPresent); |
|
1325 return EFalse ; |
|
1326 } |
|
1327 |
|
1328 if (driveInfo.iMediaAtt & KMediaAttWriteProtected) |
|
1329 { |
|
1330 writeBuf[3] = 1<<7; // set SWP bit at the Device Specific parameters |
|
1331 } |
|
1332 } |
|
1333 |
|
1334 writeBuf[1]=6; //Sending only Mode parameter header |
|
1335 |
|
1336 TPtrC8 writeBuf1 = writeBuf; |
|
1337 |
|
1338 iTransport->SetupWriteData(writeBuf1); |
|
1339 |
|
1340 return (iSenseInfo.SenseOk()); |
|
1341 } |
|
1342 |
|
1343 |
|
1344 |