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