|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32base_private.h> |
|
23 #include "debug.h" |
|
24 #include "msdebug.h" |
|
25 |
|
26 #include "msctypes.h" |
|
27 #include "mtransport.h" |
|
28 #include "mprotocol.h" |
|
29 #include "tscsiclientreq.h" |
|
30 #include "tscsiprimarycmds.h" |
|
31 #include "tscsiblockcmds.h" |
|
32 #include "tspcclientinterface.h" |
|
33 |
|
34 |
|
35 /** |
|
36 Constructor. |
|
37 |
|
38 @param aTransport Referance to the transport interface to be used to send the |
|
39 SCSI SPC message |
|
40 */ |
|
41 TSpcClientInterface::TSpcClientInterface(MTransport& aTransport) |
|
42 : iTransport(aTransport) |
|
43 { |
|
44 __MSFNLOG |
|
45 } |
|
46 |
|
47 /** |
|
48 Destructor. |
|
49 */ |
|
50 TSpcClientInterface::~TSpcClientInterface() |
|
51 { |
|
52 __MSFNLOG |
|
53 } |
|
54 |
|
55 /** |
|
56 Create a SCSI INQUIRY command and send the command via the transport layer. The |
|
57 function leaves if the device response is not compliant with the protocol |
|
58 standard. |
|
59 |
|
60 @param aInfo The returned information by the peripheral device |
|
61 |
|
62 @return TInt KErrNone if successful otherwise KErrCommandFailed to indicate a |
|
63 device status error |
|
64 */ |
|
65 TInt TSpcClientInterface::InquiryL(TPeripheralInfo& aInfo) |
|
66 { |
|
67 __MSFNLOG |
|
68 TScsiClientInquiryReq inquiryReq; |
|
69 |
|
70 TScsiClientInquiryResp inquiryResp(aInfo); |
|
71 |
|
72 TInt err = iTransport.SendControlCmdL(&inquiryReq, &inquiryResp); |
|
73 return err; |
|
74 } |
|
75 |
|
76 |
|
77 /** |
|
78 Create a SCSI REQUEST SENSE command and send the command via the transport |
|
79 layer. The function leaves if the device response is not compliant with the |
|
80 protocol standard. |
|
81 |
|
82 @param aSenseInfo The returned SENSE INFO |
|
83 |
|
84 @return TInt TInt KErrNone if successful otherwise KErrCommandFailed to indicate |
|
85 a device status error |
|
86 */ |
|
87 TInt TSpcClientInterface::RequestSenseL(TSenseInfo& aSenseInfo) |
|
88 { |
|
89 __MSFNLOG |
|
90 TScsiClientRequestSenseReq requestSenseReq; |
|
91 TScsiClientRequestSenseResp requestSenseResp; |
|
92 |
|
93 TInt err = iTransport.SendControlCmdL(&requestSenseReq, &requestSenseResp); |
|
94 aSenseInfo = requestSenseResp.iSenseInfo; |
|
95 |
|
96 __SCSIPRINT4(_L("SCSI SENSE INFO Response%08x Code=%08x, Qual=%08x Add=%08x"), |
|
97 requestSenseResp.iResponseCode, |
|
98 aSenseInfo.iSenseCode, aSenseInfo.iQualifier, aSenseInfo.iAdditional); |
|
99 return err; |
|
100 } |
|
101 |
|
102 |
|
103 /** |
|
104 Create a SCSI TEST UNIT READY command and send the command via the transport |
|
105 layer. The function leaves if the device response is not compliant with the |
|
106 protocol standard. |
|
107 |
|
108 @return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a |
|
109 device status error |
|
110 */ |
|
111 TInt TSpcClientInterface::TestUnitReadyL() |
|
112 { |
|
113 __MSFNLOG |
|
114 TScsiClientTestUnitReadyReq testUnitReadyReq; |
|
115 |
|
116 TInt err = iTransport.SendControlCmdL(&testUnitReadyReq); |
|
117 return err; |
|
118 } |
|
119 |
|
120 |
|
121 /** |
|
122 Creates a SCSI PREVENT ALLOW MEDIUM REMOVAL command and sends the command via |
|
123 the transport layer. The function leaves if the device response is not |
|
124 compliant with the protocol standard. |
|
125 |
|
126 @param aPrevent Set the PREVENT flag |
|
127 |
|
128 @return TInt KErrNone if successful or otherwise KErrCommandFailed to indicate a |
|
129 device status error |
|
130 */ |
|
131 TInt TSpcClientInterface::PreventAllowMediumRemovalL(TBool aPrevent) |
|
132 { |
|
133 __MSFNLOG |
|
134 TScsiClientPreventMediaRemovalReq preventAllowMediaRemovalReq(aPrevent); |
|
135 TInt err = iTransport.SendControlCmdL(&preventAllowMediaRemovalReq); |
|
136 return err; |
|
137 } |
|
138 |
|
139 |
|
140 |