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