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