2 Common Libarary for SCSI
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Protocol/ScsiIo.h>
21 // the time unit is 100ns, since the SCSI I/O defines timeout in 100ns unit.
23 #define EFI_SCSI_STALL_1_MICROSECOND 10
24 #define EFI_SCSI_STALL_1_MILLISECOND 10000
25 #define EFI_SCSI_STALL_1_SECOND 10000000
28 // this macro cannot be directly used by the gBS->Stall(),
29 // since the value output by this macro is in 100ns unit,
30 // not 1us unit (1us = 1000ns)
32 #define EfiScsiStallSeconds(a) (a) * EFI_SCSI_STALL_1_SECOND
36 Function test the ready status of the SCSI unit.
38 @param[in] ScsiIo A pointer to SCSI IO protocol.
39 @param[in] Timeout The length of timeout period.
40 @param[out] SenseData A pointer to output sense data.
41 @param[out] SenseDataLength The length of output sense data.
42 @param[out] HostAdapterStatus The status of Host Adapter.
43 @param[out] TargetStatus The status of the target.
45 @retval EFI_SUCCESS The status of the unit is tested successfully.
46 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
47 but the entire DataBuffer could not be transferred.
48 The actual number of bytes transferred is returned
50 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
51 there are too many SCSI Command Packets already
53 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
54 the SCSI Request Packet.
55 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
56 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
57 is not supported by the SCSI initiator(i.e., SCSI
59 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
60 Request Packet to execute.
64 ScsiTestUnitReadyCommand (
65 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
68 OUT UINT8
*SenseDataLength
,
69 OUT UINT8
*HostAdapterStatus
,
70 OUT UINT8
*TargetStatus
75 Function to submit SCSI inquiry command.
77 @param[in] ScsiIo SCSI IO Protocol to use
78 @param[in] Timeout The length of timeout period.
79 @param[out] SenseData A pointer to output sense data.
80 @param[in,out] SenseDataLength The length of output sense data.
81 @param[out] HostAdapterStatus The status of Host Adapter.
82 @param[out] TargetStatus The status of the target.
83 @param[in,out] InquirydataBuffer A pointer to inquiry data buffer.
84 @param[in,out] InquiryDataLength The length of inquiry data buffer.
85 @param[in] EnableVitalProductData Boolean to enable Vital Product Data.
87 @retval EFI_SUCCESS The status of the unit is tested successfully.
88 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
89 but the entire DataBuffer could not be transferred.
90 The actual number of bytes transferred is returned
92 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
93 there are too many SCSI Command Packets already
95 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
96 the SCSI Request Packet.
97 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
98 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
99 is not supported by the SCSI initiator(i.e., SCSI
101 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
102 Request Packet to execute.
107 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
110 IN OUT UINT8
*SenseDataLength
,
111 OUT UINT8
*HostAdapterStatus
,
112 OUT UINT8
*TargetStatus
,
113 IN OUT VOID
*InquiryDataBuffer
,
114 IN OUT UINT32
*InquiryDataLength
,
115 IN BOOLEAN EnableVitalProductData
120 Function to submit SCSI mode sense 10 command.
122 @param[in] ScsiIo A pointer to SCSI IO protocol.
123 @param[in] Timeout The length of timeout period.
124 @param[out] SenseData A pointer to output sense data.
125 @param[in,out] SenseDataLength The length of output sense data.
126 @param[out] HostAdapterStatus The status of Host Adapter.
127 @param[out] TargetStatus The status of the target.
128 @param[in] DataBuffer A pointer to input data buffer.
129 @param[in,out] DataLength The length of input data buffer.
130 @param[in] DBDField The DBD Field (Optional).
131 @param[in] PageControl Page Control.
132 @param[in] PageCode Page code.
134 @retval EFI_SUCCESS The status of the unit is tested successfully.
135 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
136 but the entire DataBuffer could not be transferred.
137 The actual number of bytes transferred is returned
139 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
140 there are too many SCSI Command Packets already
142 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
143 the SCSI Request Packet.
144 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
145 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
146 is not supported by the SCSI initiator(i.e., SCSI
148 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
149 Request Packet to execute.
153 ScsiModeSense10Command (
154 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
157 IN OUT UINT8
*SenseDataLength
,
158 OUT UINT8
*HostAdapterStatus
,
159 OUT UINT8
*TargetStatus
,
161 IN OUT UINT32
*DataLength
,
162 IN UINT8 DBDField
, OPTIONAL
163 IN UINT8 PageControl
,
170 Function to submit SCSI request sense command.
171 ScsiIo - A pointer to SCSI IO protocol.
172 Timeout - The length of timeout period.
173 SenseData - A pointer to output sense data.
174 SenseDataLength - The length of output sense data.
175 HostAdapterStatus - The status of Host Adapter.
176 TargetStatus - The status of the target.
178 @param[in] ScsiIo SCSI IO Protocol to use
179 @param[in] Timeout TODO:
180 @param[out] SenseData TODO:
181 @param[in,out] SenseDataLength TODO:
182 @param[out] HostAdapterStatus TODO:
183 @param[out] TargetStatus TODO:
185 @retval EFI_SUCCESS Valid data returned
186 @retval EFI_SUCCESS The status of the unit is tested successfully.
187 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
188 but the entire DataBuffer could not be transferred.
189 The actual number of bytes transferred is returned
191 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
192 there are too many SCSI Command Packets already
194 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
195 the SCSI Request Packet.
196 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
197 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
198 is not supported by the SCSI initiator(i.e., SCSI
200 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
201 Request Packet to execute.
205 ScsiRequestSenseCommand (
206 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
209 IN OUT UINT8
*SenseDataLength
,
210 OUT UINT8
*HostAdapterStatus
,
211 OUT UINT8
*TargetStatus
216 Function to submit read capacity command.
218 @param[in] ScsiIo A pointer to SCSI IO protocol.
219 @param[in] Timeout The length of timeout period.
220 @param[out] SenseData A pointer to output sense data.
221 @param[in,out] SenseDataLength The length of output sense data.
222 @param[out] HostAdapterStatus The status of Host Adapter.
223 @param[out] TargetStatus The status of the target.
224 @param[out] DataBuffer A pointer to a data buffer.
225 @param[in,out] DataLength The length of data buffer.
226 @param[in] PMI Partial medium indicator.
228 @retval EFI_SUCCESS The status of the unit is tested successfully.
229 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
230 but the entire DataBuffer could not be transferred.
231 The actual number of bytes transferred is returned
233 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
234 there are too many SCSI Command Packets already
236 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
237 the SCSI Request Packet.
238 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
239 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
240 is not supported by the SCSI initiator(i.e., SCSI
242 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
243 Request Packet to execute.
247 ScsiReadCapacityCommand (
248 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
251 IN OUT UINT8
*SenseDataLength
,
252 OUT UINT8
*HostAdapterStatus
,
253 OUT UINT8
*TargetStatus
,
254 OUT VOID
*DataBuffer
,
255 IN OUT UINT32
*DataLength
,
261 Function to submit read 10 command.
263 @param[in] ScsiIo A pointer to SCSI IO protocol.
264 @param[in] Timeout The length of timeout period.
265 @param[out] SenseData A pointer to output sense data.
266 @param[in,out] SenseDataLength The length of output sense data.
267 @param[out] HostAdapterStatus The status of Host Adapter.
268 @param[out] TargetStatus The status of the target.
269 @param[out] DataBuffer Read 10 command data.
270 @param[in,out] DataLength The length of data buffer.
271 @param[in] StartLba The start address of LBA.
272 @param[in] SectorSize The sector size.
274 @retval EFI_SUCCESS The status of the unit is tested successfully.
275 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
276 but the entire DataBuffer could not be transferred.
277 The actual number of bytes transferred is returned
279 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
280 there are too many SCSI Command Packets already
282 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
283 the SCSI Request Packet.
284 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
285 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
286 is not supported by the SCSI initiator(i.e., SCSI
288 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
289 Request Packet to execute.
294 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
297 IN OUT UINT8
*SenseDataLength
,
298 OUT UINT8
*HostAdapterStatus
,
299 OUT UINT8
*TargetStatus
,
300 OUT VOID
*DataBuffer
,
301 IN OUT UINT32
*DataLength
,
308 Function to submit SCSI write 10 command.
310 @param[in] ScsiIo SCSI IO Protocol to use
311 @param[in] Timeout The length of timeout period.
312 @param[out] SenseData A pointer to output sense data.
313 @param[in,out] SenseDataLength The length of output sense data.
314 @param[out] HostAdapterStatus The status of Host Adapter.
315 @param[out] TargetStatus The status of the target.
316 @param[out] DataBuffer A pointer to a data buffer.
317 @param[in,out] DataLength The length of data buffer.
318 @param[in] StartLba The start address of LBA.
319 @param[in] SectorSize The sector size.
321 @retval EFI_SUCCESS The status of the unit is tested successfully.
322 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
323 but the entire DataBuffer could not be transferred.
324 The actual number of bytes transferred is returned
326 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
327 there are too many SCSI Command Packets already
329 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
330 the SCSI Request Packet.
331 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
332 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
333 is not supported by the SCSI initiator(i.e., SCSI
335 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
336 Request Packet to execute.
341 IN EFI_SCSI_IO_PROTOCOL
*ScsiIo
,
344 IN OUT UINT8
*SenseDataLength
,
345 OUT UINT8
*HostAdapterStatus
,
346 OUT UINT8
*TargetStatus
,
347 OUT VOID
*DataBuffer
,
348 IN OUT UINT32
*DataLength
,