]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/ScsiLib.h
Correct usage help information and error information format for GenVtf, EfiRom, and...
[mirror_edk2.git] / MdePkg / Include / Library / ScsiLib.h
CommitLineData
842f5579
A
1/** @file\r
2 Common Libarary for SCSI\r
fb3df220 3\r
842f5579
A
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
fb3df220 9\r
842f5579
A
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
fb3df220 12\r
842f5579 13**/\r
fb3df220 14\r
15#ifndef _SCSI_LIB_H\r
16#define _SCSI_LIB_H\r
17\r
c7d265a9 18#include <Protocol/ScsiIo.h>\r
19\r
fb3df220 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
bf231ea6
A
34\r
35/**
36 Function test the ready status of the SCSI unit.\r
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.\r
46 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r
47 but the entire DataBuffer could not be transferred.\r
48 The actual number of bytes transferred is returned\r
49 in InTransferLength.\r
50 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
51 there are too many SCSI Command Packets already \r
52 queued.\r
53 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
54 the SCSI Request Packet.\r
55 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
56 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
57 is not supported by the SCSI initiator(i.e., SCSI \r
58 Host Controller).\r
59 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
60 Request Packet to execute.\r
61
62**/\r
fb3df220 63EFI_STATUS\r
64SubmitTestUnitReadyCommand (\r
65 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
66 IN UINT64 Timeout,\r
67 OUT VOID *SenseData,\r
68 OUT UINT8 *SenseDataLength,\r
69 OUT UINT8 *HostAdapterStatus,\r
70 OUT UINT8 *TargetStatus\r
bf231ea6
A
71 );\r
72\r
73\r
74/**
75 Function to submit SCSI inquiry command.\r
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.\r
88 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r
89 but the entire DataBuffer could not be transferred.\r
90 The actual number of bytes transferred is returned\r
91 in TransferLength.\r
92 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
93 there are too many SCSI Command Packets already \r
94 queued.\r
95 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
96 the SCSI Request Packet.\r
97 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
98 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
99 is not supported by the SCSI initiator(i.e., SCSI \r
100 Host Controller).\r
101 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
102 Request Packet to execute.\r
103
104**/\r
fb3df220 105EFI_STATUS\r
106SubmitInquiryCommand (\r
107 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
108 IN UINT64 Timeout,\r
109 IN VOID *SenseData,\r
110 IN OUT UINT8 *SenseDataLength,\r
111 OUT UINT8 *HostAdapterStatus,\r
112 OUT UINT8 *TargetStatus,\r
113 IN OUT VOID *InquiryDataBuffer,\r
114 IN OUT UINT32 *InquiryDataLength,\r
115 IN BOOLEAN EnableVitalProductData\r
bf231ea6
A
116 );\r
117\r
118\r
119/**
120 Function to submit SCSI mode sense 10 command.\r
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.\r
135 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, \r
136 but the entire DataBuffer could not be transferred.\r
137 The actual number of bytes transferred is returned\r
138 in TransferLength.\r
139 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
140 there are too many SCSI Command Packets already \r
141 queued.\r
142 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
143 the SCSI Request Packet.\r
144 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
145 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
146 is not supported by the SCSI initiator(i.e., SCSI \r
147 Host Controller).\r
148 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
149 Request Packet to execute.\r
150
151**/\r
fb3df220 152EFI_STATUS\r
153SubmitModeSense10Command (\r
154 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
155 IN UINT64 Timeout,\r
156 IN VOID *SenseData,\r
157 IN OUT UINT8 *SenseDataLength,\r
158 OUT UINT8 *HostAdapterStatus,\r
159 OUT UINT8 *TargetStatus,\r
160 IN VOID *DataBuffer,\r
161 IN OUT UINT32 *DataLength,\r
162 IN UINT8 DBDField, OPTIONAL\r
163 IN UINT8 PageControl,\r
164 IN UINT8 PageCode\r
bf231ea6
A
165 );\r
166\r
167\r
168\r
169/**
170 Function to submit SCSI request sense command.\r
171 ScsiIo - A pointer to SCSI IO protocol.\r
172 Timeout - The length of timeout period.\r
173 SenseData - A pointer to output sense data.\r
174 SenseDataLength - The length of output sense data.\r
175 HostAdapterStatus - The status of Host Adapter.\r
176 TargetStatus - The status of the target.\r
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.\r
187 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, \r
188 but the entire DataBuffer could not be transferred.\r
189 The actual number of bytes transferred is returned\r
190 in TransferLength.\r
191 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
192 there are too many SCSI Command Packets already \r
193 queued.\r
194 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
195 the SCSI Request Packet.\r
196 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
197 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
198 is not supported by the SCSI initiator(i.e., SCSI \r
199 Host Controller).\r
200 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
201 Request Packet to execute.\r
202
203**/\r
fb3df220 204EFI_STATUS\r
205SubmitRequestSenseCommand (\r
206 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
207 IN UINT64 Timeout,\r
208 IN VOID *SenseData,\r
209 IN OUT UINT8 *SenseDataLength,\r
210 OUT UINT8 *HostAdapterStatus,\r
211 OUT UINT8 *TargetStatus\r
bf231ea6
A
212 );\r
213\r
214\r
215/**
216 Function to submit read capacity command.\r
217\r
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.\r
229 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, \r
230 but the entire DataBuffer could not be transferred.\r
231 The actual number of bytes transferred is returned\r
232 in TransferLength.\r
233 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
234 there are too many SCSI Command Packets already \r
235 queued.\r
236 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
237 the SCSI Request Packet.\r
238 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
239 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
240 is not supported by the SCSI initiator(i.e., SCSI \r
241 Host Controller).\r
242 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
243 Request Packet to execute.\r
244
245**/\r
fb3df220 246EFI_STATUS\r
247SubmitReadCapacityCommand (\r
248 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
249 IN UINT64 Timeout,\r
250 IN VOID *SenseData,\r
251 IN OUT UINT8 *SenseDataLength,\r
252 OUT UINT8 *HostAdapterStatus,\r
253 OUT UINT8 *TargetStatus,\r
254 OUT VOID *DataBuffer,\r
255 IN OUT UINT32 *DataLength,\r
256 IN BOOLEAN PMI\r
bf231ea6
A
257 );\r
258\r
259\r
260/**
261 Function to submit read 10 command.\r
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.\r
275 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, \r
276 but the entire DataBuffer could not be transferred.\r
277 The actual number of bytes transferred is returned\r
278 in TransferLength.\r
279 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
280 there are too many SCSI Command Packets already \r
281 queued.\r
282 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
283 the SCSI Request Packet.\r
284 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
285 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
286 is not supported by the SCSI initiator(i.e., SCSI \r
287 Host Controller).\r
288 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
289 Request Packet to execute.\r
290
291**/\r
fb3df220 292EFI_STATUS\r
293SubmitRead10Command (\r
294 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
295 IN UINT64 Timeout,\r
296 IN VOID *SenseData,\r
297 IN OUT UINT8 *SenseDataLength,\r
298 OUT UINT8 *HostAdapterStatus,\r
299 OUT UINT8 *TargetStatus,\r
300 OUT VOID *DataBuffer,\r
301 IN OUT UINT32 *DataLength,\r
302 IN UINT32 StartLba,\r
303 IN UINT32 SectorSize\r
bf231ea6
A
304 );\r
305\r
306\r
307/**
308 Function to submit SCSI write 10 command.\r
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.\r
322 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, \r
323 but the entire DataBuffer could not be transferred.\r
324 The actual number of bytes transferred is returned\r
325 in InTransferLength.\r
326 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because \r
327 there are too many SCSI Command Packets already \r
328 queued.\r
329 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send \r
330 the SCSI Request Packet.\r
331 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. \r
332 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
333 is not supported by the SCSI initiator(i.e., SCSI \r
334 Host Controller).\r
335 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI \r
336 Request Packet to execute.\r
337
338**/\r
fb3df220 339EFI_STATUS\r
340SubmitWrite10Command (\r
341 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,\r
342 IN UINT64 Timeout,\r
343 IN VOID *SenseData,\r
344 IN OUT UINT8 *SenseDataLength,\r
345 OUT UINT8 *HostAdapterStatus,\r
346 OUT UINT8 *TargetStatus,\r
347 OUT VOID *DataBuffer,\r
348 IN OUT UINT32 *DataLength,\r
349 IN UINT32 StartLba,\r
350 IN UINT32 SectorSize\r
bf231ea6 351 );\r
fb3df220 352\r
fb3df220 353\r
354#endif\r