]>
Commit | Line | Data |
---|---|---|
842f5579 A |
1 | /** @file\r |
2 | Common Libarary for SCSI\r | |
fb3df220 | 3 | \r |
842f5579 A |
4 | Copyright (c) 2006 - 2007, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
fb3df220 | 9 | \r |
842f5579 A |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
fb3df220 | 12 | \r |
842f5579 | 13 | **/\r |
fb3df220 | 14 | \r |
42eedea9 | 15 | #ifndef _SCSI_LIB_H_\r |
16 | #define _SCSI_LIB_H_\r | |
fb3df220 | 17 | \r |
c7d265a9 | 18 | #include <Protocol/ScsiIo.h>\r |
19 | \r | |
fb3df220 | 20 | //\r |
21 | // the time unit is 100ns, since the SCSI I/O defines timeout in 100ns unit.\r | |
22 | //\r | |
23 | #define EFI_SCSI_STALL_1_MICROSECOND 10\r | |
24 | #define EFI_SCSI_STALL_1_MILLISECOND 10000\r | |
25 | #define EFI_SCSI_STALL_1_SECOND 10000000\r | |
26 | \r | |
fc30687f | 27 | ///\r |
28 | /// this macro cannot be directly used by the gBS->Stall(),\r | |
29 | /// since the value output by this macro is in 100ns unit,\r | |
30 | /// not 1us unit (1us = 1000ns)\r | |
31 | ///\r | |
42eedea9 | 32 | #define EfiScsiStallSeconds(a) ((a) * EFI_SCSI_STALL_1_SECOND)\r |
fb3df220 | 33 | \r |
bf231ea6 | 34 | \r |
fc30687f | 35 | /**\r |
bf231ea6 | 36 | Function test the ready status of the SCSI unit.\r |
fc30687f | 37 | \r |
b91d5eca | 38 | Submit SCSI test unit ready command with SCSI request packet specified by this scsi command, TimeOut\r |
39 | and SenseData, then get the status of the target Scsi unit.\r | |
40 | \r | |
41 | If SenseDataLength is NULL, then ASSERT().\r | |
42 | \r | |
43 | If HostAdapterStatus is NULL, then ASSERT().\r | |
44 | \r | |
45 | If TargetStatus is NULL, then ASSERT().\r | |
46 | \r | |
fc30687f | 47 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r |
48 | @param[in] Timeout The length of timeout period.\r | |
956a6dca | 49 | @param[in] SenseData A pointer to output sense data.\r |
fc30687f | 50 | @param[out] SenseDataLength The length of output sense data.\r |
51 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
52 | @param[out] TargetStatus The status of the target.\r | |
53 | \r | |
bf231ea6 A |
54 | @retval EFI_SUCCESS The status of the unit is tested successfully.\r |
55 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r | |
56 | but the entire DataBuffer could not be transferred.\r | |
57 | The actual number of bytes transferred is returned\r | |
58 | in InTransferLength.\r | |
59 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r | |
60 | there are too many SCSI Command Packets already \r | |
61 | queued.\r | |
62 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r | |
63 | the SCSI Request Packet.\r | |
b91d5eca | 64 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r |
bf231ea6 A |
65 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r |
66 | is not supported by the SCSI initiator(i.e., SCSI \r | |
67 | Host Controller).\r | |
68 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r | |
69 | Request Packet to execute.\r | |
fc30687f | 70 | \r |
bf231ea6 | 71 | **/\r |
fb3df220 | 72 | EFI_STATUS\r |
373b5cf9 | 73 | EFIAPI\r |
d35be2a4 | 74 | ScsiTestUnitReadyCommand (\r |
fb3df220 | 75 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
76 | IN UINT64 Timeout,\r | |
956a6dca | 77 | IN VOID *SenseData,\r |
fb3df220 | 78 | OUT UINT8 *SenseDataLength,\r |
79 | OUT UINT8 *HostAdapterStatus,\r | |
80 | OUT UINT8 *TargetStatus\r | |
bf231ea6 A |
81 | );\r |
82 | \r | |
83 | \r | |
fc30687f | 84 | /**\r |
bf231ea6 | 85 | Function to submit SCSI inquiry command.\r |
fc30687f | 86 | \r |
b91d5eca | 87 | Submit SCSI inquiry command with the SCSI request packet specified by this SCSI command and input\r |
88 | parameters, then return the status of Scsi unit execution.\r | |
89 | \r | |
90 | If SenseDataLength is NULL, then ASSERT().\r | |
91 | \r | |
92 | If HostAdapterStatus is NULL, then ASSERT().\r | |
93 | \r | |
94 | If TargetStatus is NULL, then ASSERT().\r | |
95 | \r | |
96 | If InquiryDataLength is NULL, then ASSERT().\r | |
97 | \r | |
fc30687f | 98 | @param[in] ScsiIo SCSI IO Protocol to use\r |
99 | @param[in] Timeout The length of timeout period.\r | |
100 | @param[in] SenseData A pointer to output sense data.\r | |
101 | @param[in out] SenseDataLength The length of output sense data.\r | |
102 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
103 | @param[out] TargetStatus The status of the target.\r | |
104 | @param[in out] InquirydataBuffer A pointer to inquiry data buffer.\r | |
105 | @param[in out] InquiryDataLength The length of inquiry data buffer.\r | |
106 | @param[in] EnableVitalProductData Boolean to enable Vital Product Data.\r | |
107 | \r | |
b91d5eca | 108 | @retval EFI_SUCCESS Command is executed successfully.\r |
109 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r | |
110 | but the entire DataBuffer could not be transferred.\r | |
111 | The actual number of bytes transferred is returned\r | |
112 | in TransferLength.\r | |
113 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r | |
114 | there are too many SCSI Command Packets already \r | |
115 | queued.\r | |
116 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r | |
117 | the SCSI Request Packet.\r | |
118 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
119 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r | |
120 | is not supported by the SCSI initiator(i.e., SCSI \r | |
121 | Host Controller).\r | |
122 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r | |
123 | Request Packet to execute.\r | |
fc30687f | 124 | \r |
bf231ea6 | 125 | **/\r |
fb3df220 | 126 | EFI_STATUS\r |
373b5cf9 | 127 | EFIAPI\r |
d35be2a4 | 128 | ScsiInquiryCommand (\r |
fb3df220 | 129 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
130 | IN UINT64 Timeout,\r | |
131 | IN VOID *SenseData,\r | |
132 | IN OUT UINT8 *SenseDataLength,\r | |
133 | OUT UINT8 *HostAdapterStatus,\r | |
134 | OUT UINT8 *TargetStatus,\r | |
135 | IN OUT VOID *InquiryDataBuffer,\r | |
136 | IN OUT UINT32 *InquiryDataLength,\r | |
137 | IN BOOLEAN EnableVitalProductData\r | |
bf231ea6 A |
138 | );\r |
139 | \r | |
140 | \r | |
fc30687f | 141 | /**\r |
bf231ea6 | 142 | Function to submit SCSI mode sense 10 command.\r |
fc30687f | 143 | \r |
b91d5eca | 144 | Submit SCSI Mode Sense (10) command with the SCSI request packet specified by this SCSI command and\r |
145 | the input parameters, then return the status of Scsi unit execution.\r | |
146 | \r | |
147 | If SenseDataLength is NULL, then ASSERT().\r | |
148 | \r | |
149 | If HostAdapterStatus is NULL, then ASSERT().\r | |
150 | \r | |
151 | If TargetStatus is NULL, then ASSERT().\r | |
152 | \r | |
153 | If DataLength is NULL, then ASSERT().\r | |
154 | \r | |
fc30687f | 155 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r |
156 | @param[in] Timeout The length of timeout period.\r | |
b91d5eca | 157 | @param[in] SenseData A pointer to output sense data.\r |
fc30687f | 158 | @param[in out] SenseDataLength The length of output sense data.\r |
159 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
160 | @param[out] TargetStatus The status of the target.\r | |
161 | @param[in] DataBuffer A pointer to input data buffer.\r | |
162 | @param[in out] DataLength The length of input data buffer.\r | |
163 | @param[in] DBDField The DBD Field (Optional).\r | |
164 | @param[in] PageControl Page Control.\r | |
165 | @param[in] PageCode Page code.\r | |
166 | \r | |
bf231ea6 | 167 | @retval EFI_SUCCESS The status of the unit is tested successfully.\r |
c7a54f25 | 168 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r |
bf231ea6 A |
169 | but the entire DataBuffer could not be transferred.\r |
170 | The actual number of bytes transferred is returned\r | |
171 | in TransferLength.\r | |
172 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r | |
173 | there are too many SCSI Command Packets already \r | |
174 | queued.\r | |
175 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r | |
176 | the SCSI Request Packet.\r | |
b91d5eca | 177 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL. \r |
bf231ea6 A |
178 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r |
179 | is not supported by the SCSI initiator(i.e., SCSI \r | |
180 | Host Controller).\r | |
181 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r | |
182 | Request Packet to execute.\r | |
fc30687f | 183 | \r |
bf231ea6 | 184 | **/\r |
fb3df220 | 185 | EFI_STATUS\r |
373b5cf9 | 186 | EFIAPI\r |
d35be2a4 | 187 | ScsiModeSense10Command (\r |
fb3df220 | 188 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
189 | IN UINT64 Timeout,\r | |
190 | IN VOID *SenseData,\r | |
191 | IN OUT UINT8 *SenseDataLength,\r | |
192 | OUT UINT8 *HostAdapterStatus,\r | |
193 | OUT UINT8 *TargetStatus,\r | |
194 | IN VOID *DataBuffer,\r | |
195 | IN OUT UINT32 *DataLength,\r | |
196 | IN UINT8 DBDField, OPTIONAL\r | |
197 | IN UINT8 PageControl,\r | |
198 | IN UINT8 PageCode\r | |
bf231ea6 A |
199 | );\r |
200 | \r | |
201 | \r | |
202 | \r | |
fc30687f | 203 | /**\r |
bf231ea6 | 204 | Function to submit SCSI request sense command.\r |
fc30687f | 205 | \r |
b91d5eca | 206 | Submit SCSI request sense command with the SCSI requested packet specified by this\r |
207 | SCSI command, TimeOut and SenseData, and then return the status of scsi unit execution.\r | |
208 | \r | |
209 | If SenseDataLength is NULL, then ASSERT().\r | |
210 | \r | |
211 | If HostAdapterStatus is NULL, then ASSERT().\r | |
212 | \r | |
213 | If TargetStatus is NULL, then ASSERT().\r | |
214 | \r | |
215 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r | |
216 | @param[in] Timeout The length of timeout period.\r | |
217 | @param[in] SenseData A pointer to output sense data.\r | |
218 | @param[in out] SenseDataLength The length of output sense data.\r | |
219 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
220 | @param[out] TargetStatus The status of the target.\r | |
221 | \r | |
222 | @retval EFI_SUCCESS Command is executed successfully.\r | |
223 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are\r | |
224 | too many SCSI Command Packets already queued.\r | |
225 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r | |
226 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by\r | |
227 | the SCSI initiator(i.e., SCSI Host Controller)\r | |
228 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
229 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
fc30687f | 230 | \r |
bf231ea6 | 231 | **/\r |
fb3df220 | 232 | EFI_STATUS\r |
373b5cf9 | 233 | EFIAPI\r |
d35be2a4 | 234 | ScsiRequestSenseCommand (\r |
fb3df220 | 235 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
236 | IN UINT64 Timeout,\r | |
237 | IN VOID *SenseData,\r | |
238 | IN OUT UINT8 *SenseDataLength,\r | |
239 | OUT UINT8 *HostAdapterStatus,\r | |
240 | OUT UINT8 *TargetStatus\r | |
bf231ea6 A |
241 | );\r |
242 | \r | |
243 | \r | |
fc30687f | 244 | /**\r |
bf231ea6 A |
245 | Function to submit read capacity command.\r |
246 | \r | |
b91d5eca | 247 | Submit SCSI read capacity command with the SCSI request packet specified by this SCSI \r |
248 | command and the input parameters, and then return the status of Scsi unit execution.\r | |
249 | \r | |
250 | If SenseDataLength is NULL, then ASSERT().\r | |
251 | \r | |
252 | If HostAdapterStatus is NULL, then ASSERT().\r | |
253 | \r | |
254 | If TargetStatus is NULL, then ASSERT().\r | |
255 | \r | |
256 | If DataLength is NULL, then ASSERT().\r | |
257 | \r | |
258 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r | |
259 | @param[in] Timeout The length of timeout period.\r | |
260 | @param[in] SenseData A pointer to output sense data.\r | |
261 | @param[in out] SenseDataLength The length of output sense data.\r | |
262 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
263 | @param[out] TargetStatus The status of the target.\r | |
264 | @param[out] DataBuffer A pointer to a data buffer.\r | |
265 | @param[in out] DataLength The length of data buffer.\r | |
266 | @param[in] PMI Partial medium indicator.\r | |
267 | \r | |
268 | @retval EFI_SUCCESS Command is executed successfully.\r | |
269 | @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could\r | |
270 | not be transferred. The actual number of bytes transferred is returned in DataLength.\r | |
271 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many \r | |
272 | SCSI Command Packets already queued.\r | |
273 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r | |
274 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by \r | |
275 | the SCSI initiator(i.e., SCSI Host Controller)\r | |
276 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
277 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
fc30687f | 278 | \r |
bf231ea6 | 279 | **/\r |
fb3df220 | 280 | EFI_STATUS\r |
9199040c | 281 | EFIAPI\r |
d35be2a4 | 282 | ScsiReadCapacityCommand (\r |
fb3df220 | 283 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
284 | IN UINT64 Timeout,\r | |
285 | IN VOID *SenseData,\r | |
286 | IN OUT UINT8 *SenseDataLength,\r | |
287 | OUT UINT8 *HostAdapterStatus,\r | |
288 | OUT UINT8 *TargetStatus,\r | |
289 | OUT VOID *DataBuffer,\r | |
290 | IN OUT UINT32 *DataLength,\r | |
291 | IN BOOLEAN PMI\r | |
bf231ea6 A |
292 | );\r |
293 | \r | |
294 | \r | |
fc30687f | 295 | /**\r |
bf231ea6 | 296 | Function to submit read 10 command.\r |
fc30687f | 297 | \r |
b91d5eca | 298 | Submit SCSI read (10) command with the SCSI request packet specified by this SCSI command \r |
299 | and the input parameters, and then return the status of Scsi unit execution.\r | |
fc30687f | 300 | \r |
b91d5eca | 301 | If SenseDataLength is NULL, then ASSERT().\r |
302 | \r | |
303 | If HostAdapterStatus is NULL, then ASSERT().\r | |
304 | \r | |
305 | If TargetStatus is NULL, then ASSERT().\r | |
306 | \r | |
307 | If DataLength is NULL, then ASSERT().\r | |
308 | \r | |
309 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r | |
310 | @param[in] Timeout The length of timeout period.\r | |
311 | @param[in] SenseData A pointer to output sense data.\r | |
312 | @param[in out] SenseDataLength The length of output sense data.\r | |
313 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
314 | @param[out] TargetStatus The status of the target.\r | |
315 | @param[out] DataBuffer Read 10 command data.\r | |
316 | @param[in out] DataLength The length of data buffer.\r | |
317 | @param[in] StartLba The start address of LBA.\r | |
318 | @param[in] SectorSize The sector size.\r | |
319 | \r | |
320 | @retval EFI_SUCCESS Command is executed successfully.\r | |
321 | @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could\r | |
322 | not be transferred. The actual number of bytes transferred is returned in DataLength.\r | |
323 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many \r | |
324 | SCSI Command Packets already queued.\r | |
325 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r | |
326 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by \r | |
327 | the SCSI initiator(i.e., SCSI Host Controller)\r | |
328 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
329 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
fc30687f | 330 | \r |
bf231ea6 | 331 | **/\r |
fb3df220 | 332 | EFI_STATUS\r |
373b5cf9 | 333 | EFIAPI\r |
d35be2a4 | 334 | ScsiRead10Command (\r |
fb3df220 | 335 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
336 | IN UINT64 Timeout,\r | |
337 | IN VOID *SenseData,\r | |
338 | IN OUT UINT8 *SenseDataLength,\r | |
339 | OUT UINT8 *HostAdapterStatus,\r | |
340 | OUT UINT8 *TargetStatus,\r | |
341 | OUT VOID *DataBuffer,\r | |
342 | IN OUT UINT32 *DataLength,\r | |
343 | IN UINT32 StartLba,\r | |
344 | IN UINT32 SectorSize\r | |
bf231ea6 A |
345 | );\r |
346 | \r | |
347 | \r | |
fc30687f | 348 | /**\r |
bf231ea6 | 349 | Function to submit SCSI write 10 command.\r |
fc30687f | 350 | \r |
b91d5eca | 351 | Submit SCSI write (10) command with the SCSI request packet specified by this SCSI command and the\r |
352 | input parameters, and then return the status of Scsi unit execution.\r | |
353 | \r | |
354 | If SenseDataLength is NULL, then ASSERT().\r | |
355 | \r | |
356 | If HostAdapterStatus is NULL, then ASSERT().\r | |
357 | \r | |
358 | If TargetStatus is NULL, then ASSERT().\r | |
359 | \r | |
360 | If DataLength is NULL, then ASSERT().\r | |
361 | \r | |
362 | @param[in] ScsiIo SCSI IO Protocol to use\r | |
363 | @param[in] Timeout The length of timeout period.\r | |
364 | @param[in] SenseData A pointer to output sense data.\r | |
365 | @param[in out] SenseDataLength The length of output sense data.\r | |
366 | @param[out] HostAdapterStatus The status of Host Adapter.\r | |
367 | @param[out] TargetStatus The status of the target.\r | |
368 | @param[out] DataBuffer A pointer to a data buffer.\r | |
369 | @param[in out] DataLength The length of data buffer.\r | |
370 | @param[in] StartLba The start address of LBA.\r | |
371 | @param[in] SectorSize The sector size.\r | |
372 | \r | |
373 | @retval EFI_SUCCESS Command is executed successfully.\r | |
374 | @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could\r | |
375 | not be transferred. The actual number of bytes transferred is returned in DataLength.\r | |
376 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many \r | |
377 | SCSI Command Packets already queued.\r | |
378 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r | |
379 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by \r | |
380 | the SCSI initiator(i.e., SCSI Host Controller)\r | |
381 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
382 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
fc30687f | 383 | \r |
bf231ea6 | 384 | **/\r |
fb3df220 | 385 | EFI_STATUS\r |
373b5cf9 | 386 | EFIAPI\r |
d35be2a4 | 387 | ScsiWrite10Command (\r |
fb3df220 | 388 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r |
389 | IN UINT64 Timeout,\r | |
390 | IN VOID *SenseData,\r | |
391 | IN OUT UINT8 *SenseDataLength,\r | |
392 | OUT UINT8 *HostAdapterStatus,\r | |
393 | OUT UINT8 *TargetStatus,\r | |
394 | OUT VOID *DataBuffer,\r | |
395 | IN OUT UINT32 *DataLength,\r | |
396 | IN UINT32 StartLba,\r | |
397 | IN UINT32 SectorSize\r | |
bf231ea6 | 398 | );\r |
fb3df220 | 399 | \r |
fb3df220 | 400 | \r |
401 | #endif\r |