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