]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ScsiLib.h
Fixed comments to follow coding standard.
[mirror_edk2.git] / MdePkg / Include / Library / ScsiLib.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 EfiScsiStallSeconds(a) (a) * EFI_SCSI_STALL_1_SECOND
33
34
35 /**
36 Function test the ready status of the SCSI unit.
37
38 @param[in] ScsiIo A pointer to SCSI IO protocol.
39 @param[in] Timeout The length of timeout period.
40 @param[out] SenseData A pointer to output sense data.
41 @param[out] SenseDataLength The length of output sense data.
42 @param[out] HostAdapterStatus The status of Host Adapter.
43 @param[out] TargetStatus The status of the target.
44
45 @retval EFI_SUCCESS The status of the unit is tested successfully.
46 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
47 but the entire DataBuffer could not be transferred.
48 The actual number of bytes transferred is returned
49 in InTransferLength.
50 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
51 there are too many SCSI Command Packets already
52 queued.
53 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
54 the SCSI Request Packet.
55 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
56 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
57 is not supported by the SCSI initiator(i.e., SCSI
58 Host Controller).
59 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
60 Request Packet to execute.
61
62 **/
63 EFI_STATUS
64 SubmitTestUnitReadyCommand (
65 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
66 IN UINT64 Timeout,
67 OUT VOID *SenseData,
68 OUT UINT8 *SenseDataLength,
69 OUT UINT8 *HostAdapterStatus,
70 OUT UINT8 *TargetStatus
71 );
72
73
74 /**
75 Function to submit SCSI inquiry command.
76
77 @param[in] ScsiIo SCSI IO Protocol to use
78 @param[in] Timeout The length of timeout period.
79 @param[out] SenseData A pointer to output sense data.
80 @param[in,out] SenseDataLength The length of output sense data.
81 @param[out] HostAdapterStatus The status of Host Adapter.
82 @param[out] TargetStatus The status of the target.
83 @param[in,out] InquirydataBuffer A pointer to inquiry data buffer.
84 @param[in,out] InquiryDataLength The length of inquiry data buffer.
85 @param[in] EnableVitalProductData Boolean to enable Vital Product Data.
86
87 @retval EFI_SUCCESS The status of the unit is tested successfully.
88 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
89 but the entire DataBuffer could not be transferred.
90 The actual number of bytes transferred is returned
91 in TransferLength.
92 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
93 there are too many SCSI Command Packets already
94 queued.
95 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
96 the SCSI Request Packet.
97 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
98 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
99 is not supported by the SCSI initiator(i.e., SCSI
100 Host Controller).
101 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
102 Request Packet to execute.
103
104 **/
105 EFI_STATUS
106 SubmitInquiryCommand (
107 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
108 IN UINT64 Timeout,
109 IN VOID *SenseData,
110 IN OUT UINT8 *SenseDataLength,
111 OUT UINT8 *HostAdapterStatus,
112 OUT UINT8 *TargetStatus,
113 IN OUT VOID *InquiryDataBuffer,
114 IN OUT UINT32 *InquiryDataLength,
115 IN BOOLEAN EnableVitalProductData
116 );
117
118
119 /**
120 Function to submit SCSI mode sense 10 command.
121
122 @param[in] ScsiIo A pointer to SCSI IO protocol.
123 @param[in] Timeout The length of timeout period.
124 @param[out] SenseData A pointer to output sense data.
125 @param[in,out] SenseDataLength The length of output sense data.
126 @param[out] HostAdapterStatus The status of Host Adapter.
127 @param[out] TargetStatus The status of the target.
128 @param[in] DataBuffer A pointer to input data buffer.
129 @param[in,out] DataLength The length of input data buffer.
130 @param[in] DBDField The DBD Field (Optional).
131 @param[in] PageControl Page Control.
132 @param[in] PageCode Page code.
133
134 @retval EFI_SUCCESS The status of the unit is tested successfully.
135 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
136 but the entire DataBuffer could not be transferred.
137 The actual number of bytes transferred is returned
138 in TransferLength.
139 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
140 there are too many SCSI Command Packets already
141 queued.
142 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
143 the SCSI Request Packet.
144 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
145 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
146 is not supported by the SCSI initiator(i.e., SCSI
147 Host Controller).
148 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
149 Request Packet to execute.
150
151 **/
152 EFI_STATUS
153 SubmitModeSense10Command (
154 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
155 IN UINT64 Timeout,
156 IN VOID *SenseData,
157 IN OUT UINT8 *SenseDataLength,
158 OUT UINT8 *HostAdapterStatus,
159 OUT UINT8 *TargetStatus,
160 IN VOID *DataBuffer,
161 IN OUT UINT32 *DataLength,
162 IN UINT8 DBDField, OPTIONAL
163 IN UINT8 PageControl,
164 IN UINT8 PageCode
165 );
166
167
168
169 /**
170 Function to submit SCSI request sense command.
171 ScsiIo - A pointer to SCSI IO protocol.
172 Timeout - The length of timeout period.
173 SenseData - A pointer to output sense data.
174 SenseDataLength - The length of output sense data.
175 HostAdapterStatus - The status of Host Adapter.
176 TargetStatus - The status of the target.
177
178 @param[in] ScsiIo SCSI IO Protocol to use
179 @param[in] Timeout TODO:
180 @param[out] SenseData TODO:
181 @param[in,out] SenseDataLength TODO:
182 @param[out] HostAdapterStatus TODO:
183 @param[out] TargetStatus TODO:
184
185 @retval EFI_SUCCESS Valid data returned
186 @retval EFI_SUCCESS The status of the unit is tested successfully.
187 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
188 but the entire DataBuffer could not be transferred.
189 The actual number of bytes transferred is returned
190 in TransferLength.
191 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
192 there are too many SCSI Command Packets already
193 queued.
194 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
195 the SCSI Request Packet.
196 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
197 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
198 is not supported by the SCSI initiator(i.e., SCSI
199 Host Controller).
200 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
201 Request Packet to execute.
202
203 **/
204 EFI_STATUS
205 SubmitRequestSenseCommand (
206 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
207 IN UINT64 Timeout,
208 IN VOID *SenseData,
209 IN OUT UINT8 *SenseDataLength,
210 OUT UINT8 *HostAdapterStatus,
211 OUT UINT8 *TargetStatus
212 );
213
214
215 /**
216 Function to submit read capacity command.
217
218 @param[in] ScsiIo A pointer to SCSI IO protocol.
219 @param[in] Timeout The length of timeout period.
220 @param[out] SenseData A pointer to output sense data.
221 @param[in,out] SenseDataLength The length of output sense data.
222 @param[out] HostAdapterStatus The status of Host Adapter.
223 @param[out] TargetStatus The status of the target.
224 @param[out] DataBuffer A pointer to a data buffer.
225 @param[in,out] DataLength The length of data buffer.
226 @param[in] PMI Partial medium indicator.
227
228 @retval EFI_SUCCESS The status of the unit is tested successfully.
229 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
230 but the entire DataBuffer could not be transferred.
231 The actual number of bytes transferred is returned
232 in TransferLength.
233 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
234 there are too many SCSI Command Packets already
235 queued.
236 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
237 the SCSI Request Packet.
238 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
239 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
240 is not supported by the SCSI initiator(i.e., SCSI
241 Host Controller).
242 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
243 Request Packet to execute.
244
245 **/
246 EFI_STATUS
247 SubmitReadCapacityCommand (
248 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
249 IN UINT64 Timeout,
250 IN VOID *SenseData,
251 IN OUT UINT8 *SenseDataLength,
252 OUT UINT8 *HostAdapterStatus,
253 OUT UINT8 *TargetStatus,
254 OUT VOID *DataBuffer,
255 IN OUT UINT32 *DataLength,
256 IN BOOLEAN PMI
257 );
258
259
260 /**
261 Function to submit read 10 command.
262
263 @param[in] ScsiIo A pointer to SCSI IO protocol.
264 @param[in] Timeout The length of timeout period.
265 @param[out] SenseData A pointer to output sense data.
266 @param[in,out] SenseDataLength The length of output sense data.
267 @param[out] HostAdapterStatus The status of Host Adapter.
268 @param[out] TargetStatus The status of the target.
269 @param[out] DataBuffer Read 10 command data.
270 @param[in,out] DataLength The length of data buffer.
271 @param[in] StartLba The start address of LBA.
272 @param[in] SectorSize The sector size.
273
274 @retval EFI_SUCCESS The status of the unit is tested successfully.
275 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
276 but the entire DataBuffer could not be transferred.
277 The actual number of bytes transferred is returned
278 in TransferLength.
279 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
280 there are too many SCSI Command Packets already
281 queued.
282 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
283 the SCSI Request Packet.
284 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
285 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
286 is not supported by the SCSI initiator(i.e., SCSI
287 Host Controller).
288 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
289 Request Packet to execute.
290
291 **/
292 EFI_STATUS
293 SubmitRead10Command (
294 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
295 IN UINT64 Timeout,
296 IN VOID *SenseData,
297 IN OUT UINT8 *SenseDataLength,
298 OUT UINT8 *HostAdapterStatus,
299 OUT UINT8 *TargetStatus,
300 OUT VOID *DataBuffer,
301 IN OUT UINT32 *DataLength,
302 IN UINT32 StartLba,
303 IN UINT32 SectorSize
304 );
305
306
307 /**
308 Function to submit SCSI write 10 command.
309
310 @param[in] ScsiIo SCSI IO Protocol to use
311 @param[in] Timeout The length of timeout period.
312 @param[out] SenseData A pointer to output sense data.
313 @param[in,out] SenseDataLength The length of output sense data.
314 @param[out] HostAdapterStatus The status of Host Adapter.
315 @param[out] TargetStatus The status of the target.
316 @param[out] DataBuffer A pointer to a data buffer.
317 @param[in,out] DataLength The length of data buffer.
318 @param[in] StartLba The start address of LBA.
319 @param[in] SectorSize The sector size.
320
321 @retval EFI_SUCCESS The status of the unit is tested successfully.
322 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
323 but the entire DataBuffer could not be transferred.
324 The actual number of bytes transferred is returned
325 in InTransferLength.
326 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
327 there are too many SCSI Command Packets already
328 queued.
329 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
330 the SCSI Request Packet.
331 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
332 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
333 is not supported by the SCSI initiator(i.e., SCSI
334 Host Controller).
335 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
336 Request Packet to execute.
337
338 **/
339 EFI_STATUS
340 SubmitWrite10Command (
341 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
342 IN UINT64 Timeout,
343 IN VOID *SenseData,
344 IN OUT UINT8 *SenseDataLength,
345 OUT UINT8 *HostAdapterStatus,
346 OUT UINT8 *TargetStatus,
347 OUT VOID *DataBuffer,
348 IN OUT UINT32 *DataLength,
349 IN UINT32 StartLba,
350 IN UINT32 SectorSize
351 );
352
353
354 #endif