]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiScsiLib/UefiScsiLib.c
Add missing parameter check ASSERTs in ScsiReadCapacity16Command() of UefiScsiLib.
[mirror_edk2.git] / MdePkg / Library / UefiScsiLib / UefiScsiLib.c
... / ...
CommitLineData
1/** @file\r
2 UEFI SCSI Library implementation\r
3\r
4 Copyright (c) 2006 - 2008, Intel Corporation.<BR>\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
9\r
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
12\r
13**/\r
14\r
15\r
16#include <Uefi.h>\r
17#include <Library/BaseLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/UefiScsiLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21 \r
22#include <IndustryStandard/Scsi.h>\r
23 \r
24 \r
25 //\r
26 // Max bytes needed to represent ID of a SCSI device\r
27 //\r
28#define EFI_SCSI_TARGET_MAX_BYTES (0x10)\r
29 \r
30 //\r
31 // bit5..7 are for Logical unit number\r
32 // 11100000b (0xe0)\r
33 //\r
34#define EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK 0xe0\r
35 \r
36 //\r
37 // Scsi Command Length six or ten\r
38 //\r
39#define EFI_SCSI_OP_LENGTH_SIX 0x6\r
40#define EFI_SCSI_OP_LENGTH_TEN 0xa\r
41\r
42\r
43\r
44/**\r
45 Execute Test Unit Ready SCSI command on a specific SCSI target.\r
46\r
47 Executes the Test Unit Ready command on the SCSI target specified by ScsiIo.\r
48 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
49 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.\r
50 If ScsiIo is NULL, then ASSERT().\r
51 If SenseDataLength is NULL, then ASSERT().\r
52 If HostAdapterStatus is NULL, then ASSERT().\r
53 If TargetStatus is NULL, then ASSERT().\r
54\r
55\r
56 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance\r
57 for the specific SCSI target.\r
58 @param[in] Timeout The timeout in 100 ns units to use for the execution\r
59 of this SCSI Request Packet. A Timeout value of\r
60 zero means that this function will wait indefinitely\r
61 for the SCSI Request Packet to execute. If Timeout\r
62 is greater than zero, then this function will return\r
63 EFI_TIMEOUT if the time required to execute the SCSI\r
64 Request Packet is greater than Timeout.\r
65 @param[in, out] SenseData A pointer to sense data that was generated by\r
66 the execution of the SCSI Request Packet. This\r
67 buffer must be allocated by the caller.\r
68 If SenseDataLength is 0, then this parameter is\r
69 optional and may be NULL.\r
70 @param[in, out] SenseDataLength On input, a pointer to the length in bytes of\r
71 the SenseData buffer. On output, a pointer to\r
72 the number of bytes written to the SenseData buffer. \r
73 @param[out] HostAdapterStatus The status of the SCSI Host Controller that produces\r
74 the SCSI bus containing the SCSI target specified by\r
75 ScsiIo when the SCSI Request Packet was executed.\r
76 See the EFI SCSI I/O Protocol in the UEFI Specification\r
77 for details on the possible return values.\r
78 @param[out] TargetStatus The status returned by the SCSI target specified\r
79 by ScsiIo when the SCSI Request Packet was executed\r
80 on the SCSI Host Controller. See the EFI SCSI I/O\r
81 Protocol in the UEFI Specification for details on\r
82 the possible return values. \r
83\r
84 @retval EFI_SUCCESS The command was executed successfully.\r
85 See HostAdapterStatus, TargetStatus, SenseDataLength,\r
86 and SenseData in that order for additional status\r
87 information.\r
88 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
89 there are too many SCSI Command Packets already\r
90 queued. The SCSI Request Packet was not sent, so\r
91 no additional status information is available.\r
92 The caller may retry again later.\r
93 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
94 SCSI Request Packet. See HostAdapterStatus,\r
95 TargetStatus, SenseDataLength, and SenseData in that\r
96 order for additional status information.\r
97 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
98 is not supported by the SCSI initiator(i.e., SCSI\r
99 Host Controller). The SCSI Request Packet was not\r
100 sent, so no additional status information is available.\r
101 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request\r
102 Packet to execute. See HostAdapterStatus, TargetStatus,\r
103 SenseDataLength, and SenseData in that order for\r
104 additional status information.\r
105\r
106**/\r
107EFI_STATUS\r
108EFIAPI\r
109ScsiTestUnitReadyCommand (\r
110 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
111 IN UINT64 Timeout,\r
112 IN OUT VOID *SenseData, OPTIONAL\r
113 IN OUT UINT8 *SenseDataLength,\r
114 OUT UINT8 *HostAdapterStatus,\r
115 OUT UINT8 *TargetStatus\r
116 )\r
117{\r
118 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
119 UINT64 Lun;\r
120 UINT8 *Target;\r
121 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
122 EFI_STATUS Status;\r
123 UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];\r
124\r
125 ASSERT (SenseDataLength != NULL);\r
126 ASSERT (HostAdapterStatus != NULL);\r
127 ASSERT (TargetStatus != NULL);\r
128 ASSERT (ScsiIo != NULL);\r
129\r
130 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
131 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_SIX);\r
132\r
133 CommandPacket.Timeout = Timeout;\r
134 CommandPacket.InDataBuffer = NULL;\r
135 CommandPacket.InTransferLength= 0;\r
136 CommandPacket.OutDataBuffer = NULL;\r
137 CommandPacket.OutTransferLength= 0;\r
138 CommandPacket.SenseData = SenseData;\r
139 CommandPacket.Cdb = Cdb;\r
140 //\r
141 // Fill Cdb for Test Unit Ready Command\r
142 //\r
143 Target = &TargetArray[0];\r
144 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
145\r
146 Cdb[0] = EFI_SCSI_OP_TEST_UNIT_READY;\r
147 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
148 CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;\r
149 CommandPacket.SenseDataLength = *SenseDataLength;\r
150\r
151 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
152\r
153 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
154 *TargetStatus = CommandPacket.TargetStatus;\r
155 *SenseDataLength = CommandPacket.SenseDataLength;\r
156\r
157 return Status;\r
158}\r
159\r
160\r
161/**\r
162 Execute Inquiry SCSI command on a specific SCSI target.\r
163\r
164 Executes the Inquiry command on the SCSI target specified by ScsiIo.\r
165 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
166 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.\r
167 If ScsiIo is NULL, then ASSERT().\r
168 If SenseDataLength is NULL, then ASSERT().\r
169 If HostAdapterStatus is NULL, then ASSERT().\r
170 If TargetStatus is NULL, then ASSERT().\r
171 If InquiryDataLength is NULL, then ASSERT().\r
172\r
173 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance\r
174 for the specific SCSI target.\r
175 @param[in] Timeout The timeout in 100 ns units to use for the\r
176 execution of this SCSI Request Packet. A Timeout\r
177 value of zero means that this function will wait\r
178 indefinitely for the SCSI Request Packet to execute.\r
179 If Timeout is greater than zero, then this function\r
180 will return EFI_TIMEOUT if the time required to\r
181 execute the SCSI Request Packet is greater than Timeout.\r
182 @param[in, out] SenseData A pointer to sense data that was generated\r
183 by the execution of the SCSI Request Packet.\r
184 This buffer must be allocated by the caller.\r
185 If SenseDataLength is 0, then this parameter\r
186 is optional and may be NULL.\r
187 @param[in, out] SenseDataLength On input, the length in bytes of the SenseData buffer.\r
188 On output, the number of bytes written to the SenseData buffer. \r
189 @param[out] HostAdapterStatus The status of the SCSI Host Controller that\r
190 produces the SCSI bus containing the SCSI\r
191 target specified by ScsiIo when the SCSI\r
192 Request Packet was executed. See the EFI\r
193 SCSI I/O Protocol in the UEFI Specification\r
194 for details on the possible return values.\r
195 @param[out] TargetStatus The status returned by the SCSI target specified\r
196 by ScsiIo when the SCSI Request Packet was\r
197 executed on the SCSI Host Controller.\r
198 See the EFI SCSI I/O Protocol in the UEFI\r
199 Specification for details on the possible\r
200 return values. \r
201 @param[in, out] InquiryDataBuffer A pointer to inquiry data that was generated\r
202 by the execution of the SCSI Request Packet.\r
203 This buffer must be allocated by the caller.\r
204 If InquiryDataLength is 0, then this parameter\r
205 is optional and may be NULL. \r
206 @param[in, out] InquiryDataLength On input, a pointer to the length in bytes\r
207 of the InquiryDataBuffer buffer.\r
208 On output, a pointer to the number of bytes\r
209 written to the InquiryDataBuffer buffer.\r
210 @param[in] EnableVitalProductData If TRUE, then the supported vital product\r
211 data is returned in InquiryDataBuffer.\r
212 If FALSE, then the standard inquiry data is\r
213 returned in InquiryDataBuffer. \r
214\r
215 @retval EFI_SUCCESS The command was executed successfully. See HostAdapterStatus,\r
216 TargetStatus, SenseDataLength, and SenseData in that order\r
217 for additional status information.\r
218 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire\r
219 InquiryDataBuffer could not be transferred. The actual\r
220 number of bytes transferred is returned in InquiryDataLength.\r
221 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there\r
222 are too many SCSI Command Packets already queued.\r
223 The SCSI Request Packet was not sent, so no additional\r
224 status information is available. The caller may retry again later.\r
225 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI\r
226 Request Packet. See HostAdapterStatus, TargetStatus,\r
227 SenseDataLength, and SenseData in that order for additional\r
228 status information.\r
229 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not\r
230 supported by the SCSI initiator(i.e., SCSI Host Controller).\r
231 The SCSI Request Packet was not sent, so no additional\r
232 status information is available.\r
233 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request\r
234 Packet to execute. See HostAdapterStatus, TargetStatus,\r
235 SenseDataLength, and SenseData in that order for\r
236 additional status information.\r
237\r
238**/\r
239EFI_STATUS\r
240EFIAPI\r
241ScsiInquiryCommand (\r
242 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
243 IN UINT64 Timeout,\r
244 IN OUT VOID *SenseData, OPTIONAL\r
245 IN OUT UINT8 *SenseDataLength,\r
246 OUT UINT8 *HostAdapterStatus,\r
247 OUT UINT8 *TargetStatus,\r
248 IN OUT VOID *InquiryDataBuffer, OPTIONAL\r
249 IN OUT UINT32 *InquiryDataLength,\r
250 IN BOOLEAN EnableVitalProductData\r
251 )\r
252{\r
253 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
254 UINT64 Lun;\r
255 UINT8 *Target;\r
256 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
257 EFI_STATUS Status;\r
258 UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];\r
259\r
260 ASSERT (SenseDataLength != NULL);\r
261 ASSERT (HostAdapterStatus != NULL);\r
262 ASSERT (TargetStatus != NULL);\r
263 ASSERT (InquiryDataLength != NULL);\r
264 ASSERT (ScsiIo != NULL);\r
265\r
266 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
267 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_SIX);\r
268\r
269 CommandPacket.Timeout = Timeout;\r
270 CommandPacket.InDataBuffer = InquiryDataBuffer;\r
271 CommandPacket.InTransferLength= *InquiryDataLength;\r
272 CommandPacket.SenseData = SenseData;\r
273 CommandPacket.SenseDataLength = *SenseDataLength;\r
274 CommandPacket.Cdb = Cdb;\r
275\r
276 Target = &TargetArray[0];\r
277 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
278\r
279 Cdb[0] = EFI_SCSI_OP_INQUIRY;\r
280 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
281 if (EnableVitalProductData) {\r
282 Cdb[1] |= 0x01;\r
283 }\r
284\r
285 if (*InquiryDataLength > 0xff) {\r
286 *InquiryDataLength = 0xff;\r
287 }\r
288\r
289 Cdb[4] = (UINT8) (*InquiryDataLength);\r
290 CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;\r
291 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
292\r
293 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
294\r
295 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
296 *TargetStatus = CommandPacket.TargetStatus;\r
297 *SenseDataLength = CommandPacket.SenseDataLength;\r
298 *InquiryDataLength = CommandPacket.InTransferLength;\r
299\r
300 return Status;\r
301}\r
302\r
303\r
304/**\r
305 Execute Mode Sense(10) SCSI command on a specific SCSI target.\r
306\r
307 Executes the SCSI Mode Sense(10) command on the SCSI target specified by ScsiIo.\r
308 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
309 If Timeout is greater than zero, then the command is executed and will timeout\r
310 after Timeout 100 ns units. The DBDField, PageControl, and PageCode parameters\r
311 are used to construct the CDB for this SCSI command.\r
312 If ScsiIo is NULL, then ASSERT().\r
313 If SenseDataLength is NULL, then ASSERT().\r
314 If HostAdapterStatus is NULL, then ASSERT().\r
315 If TargetStatus is NULL, then ASSERT().\r
316 If DataLength is NULL, then ASSERT().\r
317\r
318\r
319 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance\r
320 for the specific SCSI target.\r
321 @param[in] Timeout The timeout in 100 ns units to use for the\r
322 execution of this SCSI Request Packet. A Timeout\r
323 value of zero means that this function will wait\r
324 indefinitely for the SCSI Request Packet to execute.\r
325 If Timeout is greater than zero, then this function\r
326 will return EFI_TIMEOUT if the time required to\r
327 execute the SCSI Request Packet is greater than Timeout.\r
328 @param[in, out] SenseData A pointer to sense data that was generated\r
329 by the execution of the SCSI Request Packet.\r
330 This buffer must be allocated by the caller.\r
331 If SenseDataLength is 0, then this parameter\r
332 is optional and may be NULL.\r
333 @param[in, out] SenseDataLength On input, the length in bytes of the SenseData buffer.\r
334 On output, the number of bytes written to the SenseData buffer. \r
335 @param[out] HostAdapterStatus The status of the SCSI Host Controller that\r
336 produces the SCSI bus containing the SCSI target\r
337 specified by ScsiIo when the SCSI Request Packet\r
338 was executed. See the EFI SCSI I/O Protocol in the\r
339 UEFI Specification for details on the possible\r
340 return values.\r
341 @param[out] TargetStatus The status returned by the SCSI target specified\r
342 by ScsiIo when the SCSI Request Packet was executed\r
343 on the SCSI Host Controller. See the EFI SCSI\r
344 I/O Protocol in the UEFI Specification for details\r
345 on the possible return values.\r
346 @param[in, out] DataBuffer A pointer to data that was generated by the\r
347 execution of the SCSI Request Packet. This\r
348 buffer must be allocated by the caller. If\r
349 DataLength is 0, then this parameter is optional\r
350 and may be NULL. \r
351 @param[in, out] DataLength On input, a pointer to the length in bytes of\r
352 the DataBuffer buffer. On output, a pointer\r
353 to the number of bytes written to the DataBuffer\r
354 buffer. \r
355 @param[in] DBDField Specifies the DBD field of the CDB for this SCSI Command.\r
356 @param[in] PageControl Specifies the PC field of the CDB for this SCSI Command. \r
357 @param[in] PageCode Specifies the Page Control field of the CDB for this SCSI Command. \r
358\r
359 @retval EFI_SUCCESS The command was executed successfully.\r
360 See HostAdapterStatus, TargetStatus, SenseDataLength,\r
361 and SenseData in that order for additional status information.\r
362 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the\r
363 entire DataBuffer could not be transferred.\r
364 The actual number of bytes transferred is returned\r
365 in DataLength.\r
366 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
367 there are too many SCSI Command Packets already queued.\r
368 The SCSI Request Packet was not sent, so no additional\r
369 status information is available. The caller may retry\r
370 again later.\r
371 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
372 SCSI Request Packet. See HostAdapterStatus, TargetStatus,\r
373 SenseDataLength, and SenseData in that order for\r
374 additional status information.\r
375 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
376 is not supported by the SCSI initiator(i.e., SCSI\r
377 Host Controller). The SCSI Request Packet was not\r
378 sent, so no additional status information is available.\r
379 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI\r
380 Request Packet to execute. See HostAdapterStatus,\r
381 TargetStatus, SenseDataLength, and SenseData in that\r
382 order for additional status information.\r
383\r
384**/\r
385EFI_STATUS\r
386EFIAPI\r
387ScsiModeSense10Command (\r
388 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
389 IN UINT64 Timeout,\r
390 IN OUT VOID *SenseData, OPTIONAL\r
391 IN OUT UINT8 *SenseDataLength,\r
392 OUT UINT8 *HostAdapterStatus,\r
393 OUT UINT8 *TargetStatus,\r
394 IN OUT VOID *DataBuffer, OPTIONAL\r
395 IN OUT UINT32 *DataLength,\r
396 IN UINT8 DBDField, OPTIONAL\r
397 IN UINT8 PageControl,\r
398 IN UINT8 PageCode\r
399 )\r
400{\r
401 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
402 UINT64 Lun;\r
403 UINT8 *Target;\r
404 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
405 EFI_STATUS Status;\r
406 UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];\r
407\r
408 ASSERT (SenseDataLength != NULL);\r
409 ASSERT (HostAdapterStatus != NULL);\r
410 ASSERT (TargetStatus != NULL);\r
411 ASSERT (DataLength != NULL);\r
412 ASSERT (ScsiIo != NULL);\r
413\r
414 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
415 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN);\r
416\r
417 CommandPacket.Timeout = Timeout;\r
418 CommandPacket.InDataBuffer = DataBuffer;\r
419 CommandPacket.SenseData = SenseData;\r
420 CommandPacket.InTransferLength= *DataLength;\r
421 CommandPacket.Cdb = Cdb;\r
422 //\r
423 // Fill Cdb for Mode Sense (10) Command\r
424 //\r
425 Target = &TargetArray[0];\r
426 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
427\r
428 Cdb[0] = EFI_SCSI_OP_MODE_SEN10;\r
429 //\r
430 // DBDField is in Cdb[1] bit3 of (bit7..0)\r
431 //\r
432 Cdb[1] = (UINT8) ((LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK) + ((DBDField << 3) & 0x08));\r
433 //\r
434 // PageControl is in Cdb[2] bit7..6, PageCode is in Cdb[2] bit5..0\r
435 //\r
436 Cdb[2] = (UINT8) (((PageControl << 6) & 0xc0) | (PageCode & 0x3f));\r
437 Cdb[7] = (UINT8) (*DataLength >> 8);\r
438 Cdb[8] = (UINT8) (*DataLength);\r
439\r
440 CommandPacket.CdbLength = EFI_SCSI_OP_LENGTH_TEN;\r
441 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
442 CommandPacket.SenseDataLength = *SenseDataLength;\r
443\r
444 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
445\r
446 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
447 *TargetStatus = CommandPacket.TargetStatus;\r
448 *SenseDataLength = CommandPacket.SenseDataLength;\r
449 *DataLength = CommandPacket.InTransferLength;\r
450\r
451 return Status;\r
452}\r
453\r
454\r
455/**\r
456 Execute Request Sense SCSI command on a specific SCSI target.\r
457\r
458 Executes the Request Sense command on the SCSI target specified by ScsiIo.\r
459 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
460 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.\r
461 If ScsiIo is NULL, then ASSERT().\r
462 If SenseDataLength is NULL, then ASSERT().\r
463 If HostAdapterStatus is NULL, then ASSERT().\r
464 If TargetStatus is NULL, then ASSERT().\r
465\r
466 @param[in] ScsiIo A pointer to SCSI IO protocol.\r
467 @param[in] Timeout The length of timeout period.\r
468 @param[in, out] SenseData A pointer to output sense data.\r
469 @param[in, out] SenseDataLength The length of output sense data.\r
470 @param[out] HostAdapterStatus The status of Host Adapter.\r
471 @param[out] TargetStatus The status of the target.\r
472\r
473 @retval EFI_SUCCESS Command is executed successfully.\r
474 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are\r
475 too many SCSI Command Packets already queued.\r
476 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r
477 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by\r
478 the SCSI initiator(i.e., SCSI Host Controller)\r
479 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r
480\r
481**/\r
482EFI_STATUS\r
483EFIAPI\r
484ScsiRequestSenseCommand (\r
485 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
486 IN UINT64 Timeout,\r
487 IN OUT VOID *SenseData, OPTIONAL\r
488 IN OUT UINT8 *SenseDataLength,\r
489 OUT UINT8 *HostAdapterStatus,\r
490 OUT UINT8 *TargetStatus\r
491 )\r
492{\r
493 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
494 UINT64 Lun;\r
495 UINT8 *Target;\r
496 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
497 EFI_STATUS Status;\r
498 UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];\r
499\r
500 ASSERT (SenseDataLength != NULL);\r
501 ASSERT (HostAdapterStatus != NULL);\r
502 ASSERT (TargetStatus != NULL);\r
503 ASSERT (ScsiIo != NULL);\r
504\r
505 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
506 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_SIX);\r
507\r
508 CommandPacket.Timeout = Timeout;\r
509 CommandPacket.InDataBuffer = SenseData;\r
510 CommandPacket.SenseData = NULL;\r
511 CommandPacket.InTransferLength= *SenseDataLength;\r
512 CommandPacket.Cdb = Cdb;\r
513 //\r
514 // Fill Cdb for Request Sense Command\r
515 //\r
516 Target = &TargetArray[0];\r
517 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
518\r
519 Cdb[0] = EFI_SCSI_OP_REQUEST_SENSE;\r
520 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
521 Cdb[4] = (UINT8) (*SenseDataLength);\r
522\r
523 CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;\r
524 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
525 CommandPacket.SenseDataLength = 0;\r
526\r
527 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
528\r
529 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
530 *TargetStatus = CommandPacket.TargetStatus;\r
531 *SenseDataLength = (UINT8) CommandPacket.InTransferLength;\r
532\r
533 return Status;\r
534}\r
535\r
536\r
537/**\r
538 Execute Read Capacity SCSI command on a specific SCSI target.\r
539\r
540 Executes the SCSI Read Capacity command on the SCSI target specified by ScsiIo.\r
541 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
542 If Timeout is greater than zero, then the command is executed and will timeout after\r
543 Timeout 100 ns units. The Pmi parameter is used to construct the CDB for this SCSI command.\r
544 If ScsiIo is NULL, then ASSERT().\r
545 If SenseDataLength is NULL, then ASSERT().\r
546 If HostAdapterStatus is NULL, then ASSERT().\r
547 If TargetStatus is NULL, then ASSERT().\r
548 If DataLength is NULL, then ASSERT().\r
549\r
550 @param[in] ScsiIo A pointer to SCSI IO protocol.\r
551 @param[in] Timeout The length of timeout period.\r
552 @param[in, out] SenseData A pointer to output sense data.\r
553 @param[in, out] SenseDataLength The length of output sense data.\r
554 @param[out] HostAdapterStatus The status of Host Adapter.\r
555 @param[out] TargetStatus The status of the target.\r
556 @param[in, out] DataBuffer A pointer to a data buffer.\r
557 @param[in, out] DataLength The length of data buffer.\r
558 @param[in] Pmi Partial medium indicator.\r
559\r
560 @retval EFI_SUCCESS Command is executed successfully.\r
561 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire\r
562 DataBuffer could not be transferred. The actual\r
563 number of bytes transferred is returned in DataLength.\r
564 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
565 there are too many SCSI Command Packets already queued.\r
566 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r
567 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
568 is not supported by the SCSI initiator(i.e., SCSI Host Controller)\r
569 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r
570\r
571**/\r
572EFI_STATUS\r
573EFIAPI\r
574ScsiReadCapacityCommand (\r
575 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
576 IN UINT64 Timeout,\r
577 IN OUT VOID *SenseData, OPTIONAL\r
578 IN OUT UINT8 *SenseDataLength,\r
579 OUT UINT8 *HostAdapterStatus,\r
580 OUT UINT8 *TargetStatus,\r
581 IN OUT VOID *DataBuffer, OPTIONAL\r
582 IN OUT UINT32 *DataLength,\r
583 IN BOOLEAN Pmi\r
584 )\r
585{\r
586 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
587 UINT64 Lun;\r
588 UINT8 *Target;\r
589 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
590 EFI_STATUS Status;\r
591 UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];\r
592\r
593 ASSERT (SenseDataLength != NULL);\r
594 ASSERT (HostAdapterStatus != NULL);\r
595 ASSERT (TargetStatus != NULL);\r
596 ASSERT (DataLength != NULL);\r
597 ASSERT (ScsiIo != NULL);\r
598\r
599 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
600 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN);\r
601\r
602 CommandPacket.Timeout = Timeout;\r
603 CommandPacket.InDataBuffer = DataBuffer;\r
604 CommandPacket.SenseData = SenseData;\r
605 CommandPacket.InTransferLength= *DataLength;\r
606 CommandPacket.Cdb = Cdb;\r
607 //\r
608 // Fill Cdb for Read Capacity Command\r
609 //\r
610 Target = &TargetArray[0];\r
611 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
612\r
613 Cdb[0] = EFI_SCSI_OP_READ_CAPACITY;\r
614 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
615 if (!Pmi) {\r
616 //\r
617 // Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.\r
618 //\r
619 ZeroMem ((Cdb + 2), 4);\r
620 } else {\r
621 Cdb[8] |= 0x01;\r
622 }\r
623\r
624 CommandPacket.CdbLength = EFI_SCSI_OP_LENGTH_TEN;\r
625 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
626 CommandPacket.SenseDataLength = *SenseDataLength;\r
627\r
628 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
629\r
630 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
631 *TargetStatus = CommandPacket.TargetStatus;\r
632 *SenseDataLength = CommandPacket.SenseDataLength;\r
633 *DataLength = CommandPacket.InTransferLength;\r
634\r
635 return Status;\r
636}\r
637\r
638\r
639/**\r
640 Execute Read Capacity SCSI 16 command on a specific SCSI target.\r
641\r
642 Executes the SCSI Read Capacity 16 command on the SCSI target specified by ScsiIo.\r
643 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
644 If Timeout is greater than zero, then the command is executed and will timeout after\r
645 Timeout 100 ns units. The Pmi parameter is used to construct the CDB for this SCSI command.\r
646 If ScsiIo is NULL, then ASSERT().\r
647 If SenseDataLength is NULL, then ASSERT().\r
648 If HostAdapterStatus is NULL, then ASSERT().\r
649 If TargetStatus is NULL, then ASSERT().\r
650 If DataLength is NULL, then ASSERT().\r
651\r
652 @param[in] ScsiIo A pointer to SCSI IO protocol.\r
653 @param[in] Timeout The length of timeout period.\r
654 @param[in, out] SenseData A pointer to output sense data.\r
655 @param[in, out] SenseDataLength The length of output sense data.\r
656 @param[out] HostAdapterStatus The status of Host Adapter.\r
657 @param[out] TargetStatus The status of the target.\r
658 @param[in, out] DataBuffer A pointer to a data buffer.\r
659 @param[in, out] DataLength The length of data buffer.\r
660 @param[in] Pmi Partial medium indicator.\r
661\r
662 @retval EFI_SUCCESS Command is executed successfully.\r
663 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire\r
664 DataBuffer could not be transferred. The actual\r
665 number of bytes transferred is returned in DataLength.\r
666 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
667 there are too many SCSI Command Packets already queued.\r
668 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r
669 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
670 is not supported by the SCSI initiator(i.e., SCSI Host Controller)\r
671 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r
672\r
673**/\r
674EFI_STATUS\r
675EFIAPI\r
676ScsiReadCapacity16Command (\r
677 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
678 IN UINT64 Timeout,\r
679 IN OUT VOID *SenseData, OPTIONAL\r
680 IN OUT UINT8 *SenseDataLength,\r
681 OUT UINT8 *HostAdapterStatus,\r
682 OUT UINT8 *TargetStatus,\r
683 IN OUT VOID *DataBuffer, OPTIONAL\r
684 IN OUT UINT32 *DataLength,\r
685 IN BOOLEAN Pmi\r
686 )\r
687{\r
688 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
689 UINT64 Lun;\r
690 UINT8 *Target;\r
691 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
692 EFI_STATUS Status;\r
693 UINT8 Cdb[16];\r
694\r
695 ASSERT (SenseDataLength != NULL);\r
696 ASSERT (HostAdapterStatus != NULL);\r
697 ASSERT (TargetStatus != NULL);\r
698 ASSERT (DataLength != NULL);\r
699 ASSERT (ScsiIo != NULL);\r
700\r
701 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
702 ZeroMem (Cdb, 16);\r
703\r
704 CommandPacket.Timeout = Timeout;\r
705 CommandPacket.InDataBuffer = DataBuffer;\r
706 CommandPacket.SenseData = SenseData;\r
707 CommandPacket.InTransferLength= *DataLength;\r
708 CommandPacket.Cdb = Cdb;\r
709 //\r
710 // Fill Cdb for Read Capacity Command\r
711 //\r
712 Target = &TargetArray[0];\r
713 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
714\r
715 Cdb[0] = EFI_SCSI_OP_READ_CAPACITY16;\r
716 Cdb[1] = 0x10;\r
717 if (!Pmi) {\r
718 //\r
719 // Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.9 MUST BE ZERO.\r
720 //\r
721 ZeroMem ((Cdb + 2), 8);\r
722 } else {\r
723 Cdb[14] |= 0x01;\r
724 }\r
725\r
726 Cdb[13] = 0x20;\r
727 CommandPacket.CdbLength = 16;\r
728 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
729 CommandPacket.SenseDataLength = *SenseDataLength;\r
730\r
731 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
732\r
733 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
734 *TargetStatus = CommandPacket.TargetStatus;\r
735 *SenseDataLength = CommandPacket.SenseDataLength;\r
736 *DataLength = CommandPacket.InTransferLength;\r
737\r
738 return Status;\r
739}\r
740\r
741\r
742/**\r
743 Execute Read(10) SCSI command on a specific SCSI target.\r
744\r
745 Executes the SCSI Read(10) command on the SCSI target specified by ScsiIo.\r
746 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
747 If Timeout is greater than zero, then the command is executed and will timeout\r
748 after Timeout 100 ns units. The StartLba and SectorSize parameters are used to\r
749 construct the CDB for this SCSI command.\r
750 If ScsiIo is NULL, then ASSERT().\r
751 If SenseDataLength is NULL, then ASSERT().\r
752 If HostAdapterStatus is NULL, then ASSERT().\r
753 If TargetStatus is NULL, then ASSERT().\r
754 If DataLength is NULL, then ASSERT().\r
755\r
756\r
757 @param[in] ScsiIo A pointer to SCSI IO protocol.\r
758 @param[in] Timeout The length of timeout period.\r
759 @param[in, out] SenseData A pointer to output sense data.\r
760 @param[in, out] SenseDataLength The length of output sense data.\r
761 @param[out] HostAdapterStatus The status of Host Adapter.\r
762 @param[out] TargetStatus The status of the target.\r
763 @param[in, out] DataBuffer Read 10 command data.\r
764 @param[in, out] DataLength The length of data buffer.\r
765 @param[in] StartLba The start address of LBA.\r
766 @param[in] SectorSize The sector size.\r
767\r
768 @retval EFI_SUCCESS Command is executed successfully.\r
769 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire DataBuffer could\r
770 not be transferred. The actual number of bytes transferred is returned in DataLength.\r
771 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many \r
772 SCSI Command Packets already queued.\r
773 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r
774 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by \r
775 the SCSI initiator(i.e., SCSI Host Controller)\r
776 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r
777\r
778**/\r
779EFI_STATUS\r
780EFIAPI\r
781ScsiRead10Command (\r
782 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
783 IN UINT64 Timeout,\r
784 IN OUT VOID *SenseData, OPTIONAL\r
785 IN OUT UINT8 *SenseDataLength,\r
786 OUT UINT8 *HostAdapterStatus,\r
787 OUT UINT8 *TargetStatus,\r
788 IN OUT VOID *DataBuffer, OPTIONAL\r
789 IN OUT UINT32 *DataLength,\r
790 IN UINT32 StartLba,\r
791 IN UINT32 SectorSize\r
792 )\r
793{\r
794 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
795 UINT64 Lun;\r
796 UINT8 *Target;\r
797 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
798 EFI_STATUS Status;\r
799 UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];\r
800\r
801 ASSERT (SenseDataLength != NULL);\r
802 ASSERT (HostAdapterStatus != NULL);\r
803 ASSERT (TargetStatus != NULL);\r
804 ASSERT (DataLength != NULL);\r
805 ASSERT (ScsiIo != NULL);\r
806\r
807 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
808 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN);\r
809\r
810 CommandPacket.Timeout = Timeout;\r
811 CommandPacket.InDataBuffer = DataBuffer;\r
812 CommandPacket.SenseData = SenseData;\r
813 CommandPacket.InTransferLength= *DataLength;\r
814 CommandPacket.Cdb = Cdb;\r
815 //\r
816 // Fill Cdb for Read (10) Command\r
817 //\r
818 Target = &TargetArray[0];\r
819 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
820\r
821 Cdb[0] = EFI_SCSI_OP_READ10;\r
822 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
823 Cdb[2] = (UINT8) (StartLba >> 24);\r
824 Cdb[3] = (UINT8) (StartLba >> 16);\r
825 Cdb[4] = (UINT8) (StartLba >> 8);\r
826 Cdb[5] = (UINT8) (StartLba & 0xff);\r
827 Cdb[7] = (UINT8) (SectorSize >> 8);\r
828 Cdb[8] = (UINT8) (SectorSize & 0xff);\r
829\r
830 CommandPacket.CdbLength = EFI_SCSI_OP_LENGTH_TEN;\r
831 CommandPacket.DataDirection = EFI_SCSI_DATA_IN;\r
832 CommandPacket.SenseDataLength = *SenseDataLength;\r
833\r
834 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
835\r
836 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
837 *TargetStatus = CommandPacket.TargetStatus;\r
838 *SenseDataLength = CommandPacket.SenseDataLength;\r
839 *DataLength = CommandPacket.InTransferLength;\r
840\r
841 return Status;\r
842}\r
843\r
844\r
845/**\r
846 Execute Write(10) SCSI command on a specific SCSI target.\r
847\r
848 Executes the SCSI Write(10) command on the SCSI target specified by ScsiIo.\r
849 If Timeout is zero, then this function waits indefinitely for the command to complete.\r
850 If Timeout is greater than zero, then the command is executed and will timeout after\r
851 Timeout 100 ns units. The StartLba and SectorSize parameters are used to construct\r
852 the CDB for this SCSI command.\r
853 If ScsiIo is NULL, then ASSERT().\r
854 If SenseDataLength is NULL, then ASSERT().\r
855 If HostAdapterStatus is NULL, then ASSERT().\r
856 If TargetStatus is NULL, then ASSERT().\r
857 If DataLength is NULL, then ASSERT().\r
858\r
859 @param[in] ScsiIo SCSI IO Protocol to use\r
860 @param[in] Timeout The length of timeout period.\r
861 @param[in, out] SenseData A pointer to output sense data.\r
862 @param[in, out] SenseDataLength The length of output sense data.\r
863 @param[out] HostAdapterStatus The status of Host Adapter.\r
864 @param[out] TargetStatus The status of the target.\r
865 @param[in, out] DataBuffer A pointer to a data buffer.\r
866 @param[in, out] DataLength The length of data buffer.\r
867 @param[in] StartLba The start address of LBA.\r
868 @param[in] SectorSize The sector size.\r
869\r
870 @retval EFI_SUCCESS Command is executed successfully.\r
871 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire DataBuffer could\r
872 not be transferred. The actual number of bytes transferred is returned in DataLength.\r
873 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many \r
874 SCSI Command Packets already queued.\r
875 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.\r
876 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by \r
877 the SCSI initiator(i.e., SCSI Host Controller)\r
878 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r
879\r
880**/\r
881EFI_STATUS\r
882EFIAPI\r
883ScsiWrite10Command (\r
884 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
885 IN UINT64 Timeout,\r
886 IN OUT VOID *SenseData, OPTIONAL\r
887 IN OUT UINT8 *SenseDataLength,\r
888 OUT UINT8 *HostAdapterStatus,\r
889 OUT UINT8 *TargetStatus,\r
890 IN OUT VOID *DataBuffer, OPTIONAL\r
891 IN OUT UINT32 *DataLength,\r
892 IN UINT32 StartLba,\r
893 IN UINT32 SectorSize\r
894 )\r
895{\r
896 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
897 UINT64 Lun;\r
898 UINT8 *Target;\r
899 UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
900 EFI_STATUS Status;\r
901 UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];\r
902\r
903 ASSERT (SenseDataLength != NULL);\r
904 ASSERT (HostAdapterStatus != NULL);\r
905 ASSERT (TargetStatus != NULL);\r
906 ASSERT (DataLength != NULL);\r
907 ASSERT (ScsiIo != NULL);\r
908\r
909 ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
910 ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN);\r
911\r
912 CommandPacket.Timeout = Timeout;\r
913 CommandPacket.OutDataBuffer = DataBuffer;\r
914 CommandPacket.SenseData = SenseData;\r
915 CommandPacket.OutTransferLength= *DataLength;\r
916 CommandPacket.Cdb = Cdb;\r
917 //\r
918 // Fill Cdb for Write (10) Command\r
919 //\r
920 Target = &TargetArray[0];\r
921 ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
922\r
923 Cdb[0] = EFI_SCSI_OP_WRITE10;\r
924 Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
925 Cdb[2] = (UINT8) (StartLba >> 24);\r
926 Cdb[3] = (UINT8) (StartLba >> 16);\r
927 Cdb[4] = (UINT8) (StartLba >> 8);\r
928 Cdb[5] = (UINT8) StartLba;\r
929 Cdb[7] = (UINT8) (SectorSize >> 8);\r
930 Cdb[8] = (UINT8) SectorSize;\r
931\r
932 CommandPacket.CdbLength = EFI_SCSI_OP_LENGTH_TEN;\r
933 CommandPacket.DataDirection = EFI_SCSI_DATA_OUT;\r
934 CommandPacket.SenseDataLength = *SenseDataLength;\r
935\r
936 Status = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
937\r
938 *HostAdapterStatus = CommandPacket.HostAdapterStatus;\r
939 *TargetStatus = CommandPacket.TargetStatus;\r
940 *SenseDataLength = CommandPacket.SenseDataLength;\r
941 *DataLength = CommandPacket.OutTransferLength;\r
942\r
943 return Status;\r
944}\r
945\r