]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Common Libarary for SCSI\r | |
3 | \r | |
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 | |
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 | #ifndef _SCSI_LIB_H_\r | |
16 | #define _SCSI_LIB_H_\r | |
17 | \r | |
18 | #include <Protocol/ScsiIo.h>\r | |
19 | \r | |
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 | |
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 | |
32 | #define EfiScsiStallSeconds(a) ((a) * EFI_SCSI_STALL_1_SECOND)\r | |
33 | \r | |
34 | \r | |
35 | /**\r | |
36 | Function test the ready status of the SCSI unit.\r | |
37 | \r | |
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 | |
47 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r | |
48 | @param[in] Timeout The length of timeout period.\r | |
49 | @param[in] SenseData A pointer to output sense data.\r | |
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 | |
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 | |
64 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL.\r | |
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 | |
70 | \r | |
71 | **/\r | |
72 | EFI_STATUS\r | |
73 | EFIAPI\r | |
74 | ScsiTestUnitReadyCommand (\r | |
75 | IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r | |
76 | IN UINT64 Timeout,\r | |
77 | IN VOID *SenseData,\r | |
78 | OUT UINT8 *SenseDataLength,\r | |
79 | OUT UINT8 *HostAdapterStatus,\r | |
80 | OUT UINT8 *TargetStatus\r | |
81 | );\r | |
82 | \r | |
83 | \r | |
84 | /**\r | |
85 | Function to submit SCSI inquiry command.\r | |
86 | \r | |
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 | |
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 | |
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 | |
124 | \r | |
125 | **/\r | |
126 | EFI_STATUS\r | |
127 | EFIAPI\r | |
128 | ScsiInquiryCommand (\r | |
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 | |
138 | );\r | |
139 | \r | |
140 | \r | |
141 | /**\r | |
142 | Function to submit SCSI mode sense 10 command.\r | |
143 | \r | |
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 | |
155 | @param[in] ScsiIo A pointer to SCSI IO protocol.\r | |
156 | @param[in] Timeout The length of timeout period.\r | |
157 | @param[in] SenseData A pointer to output sense data.\r | |
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 | |
167 | @retval EFI_SUCCESS The status of the unit is tested successfully.\r | |
168 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r | |
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 | |
177 | @retval EFI_INVALID_PARAMETER ScsiIo is NULL. \r | |
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 | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | EFIAPI\r | |
187 | ScsiModeSense10Command (\r | |
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 | |
199 | );\r | |
200 | \r | |
201 | \r | |
202 | \r | |
203 | /**\r | |
204 | Function to submit SCSI request sense command.\r | |
205 | \r | |
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 | |
230 | \r | |
231 | **/\r | |
232 | EFI_STATUS\r | |
233 | EFIAPI\r | |
234 | ScsiRequestSenseCommand (\r | |
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 | |
241 | );\r | |
242 | \r | |
243 | \r | |
244 | /**\r | |
245 | Function to submit read capacity command.\r | |
246 | \r | |
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 | |
278 | \r | |
279 | **/\r | |
280 | EFI_STATUS\r | |
281 | EFIAPI\r | |
282 | ScsiReadCapacityCommand (\r | |
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 | |
292 | );\r | |
293 | \r | |
294 | \r | |
295 | /**\r | |
296 | Function to submit read 10 command.\r | |
297 | \r | |
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 | |
300 | \r | |
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 | |
330 | \r | |
331 | **/\r | |
332 | EFI_STATUS\r | |
333 | EFIAPI\r | |
334 | ScsiRead10Command (\r | |
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 | |
345 | );\r | |
346 | \r | |
347 | \r | |
348 | /**\r | |
349 | Function to submit SCSI write 10 command.\r | |
350 | \r | |
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 | |
383 | \r | |
384 | **/\r | |
385 | EFI_STATUS\r | |
386 | EFIAPI\r | |
387 | ScsiWrite10Command (\r | |
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 | |
398 | );\r | |
399 | \r | |
400 | \r | |
401 | #endif\r |