]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/ScsiIo.h
MdePkg: Add definition for new warning code EFI_WARN_FILE_SYSTEM.
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiIo.h
CommitLineData
d1f95000 1/** @file\r
2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.\r
4ca9b6c4
LG
3 This protocol is used by code, typically drivers, running in the EFI boot \r
4 services environment to access SCSI devices. In particular, functions for \r
5 managing devices on SCSI buses are defined here.\r
d1f95000 6\r
754739ec 7 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
9df063a0 8 This program and the accompanying materials \r
d1f95000 9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
d1f95000 16**/\r
17\r
18#ifndef __EFI_SCSI_IO_PROTOCOL_H__\r
19#define __EFI_SCSI_IO_PROTOCOL_H__\r
20\r
21#define EFI_SCSI_IO_PROTOCOL_GUID \\r
22 { \\r
eecd469b 23 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \\r
d1f95000 24 }\r
25\r
99e8ed21 26///\r
27/// Forward reference for pure ANSI compatability\r
28///\r
d1f95000 29typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;\r
30\r
754739ec
FT
31//\r
32// SCSI Device type information, defined in the SCSI Primary Commands standard (e.g., SPC-4)\r
33//\r
34#define EFI_SCSI_IO_TYPE_DISK 0x00 ///< Disk device\r
35#define EFI_SCSI_IO_TYPE_TAPE 0x01 ///< Tape device\r
36#define EFI_SCSI_IO_TYPE_PRINTER 0x02 ///< Printer\r
37#define EFI_SCSI_IO_TYPE_PROCESSOR 0x03 ///< Processor\r
38#define EFI_SCSI_IO_TYPE_WORM 0x04 ///< Write-once read-multiple\r
39#define EFI_SCSI_IO_TYPE_CDROM 0x05 ///< CD or DVD device\r
40#define EFI_SCSI_IO_TYPE_SCANNER 0x06 ///< Scanner device\r
41#define EFI_SCSI_IO_TYPE_OPTICAL 0x07 ///< Optical memory device\r
42#define EFI_SCSI_IO_TYPE_MEDIUMCHANGER 0x08 ///< Medium Changer device\r
43#define EFI_SCSI_IO_TYPE_COMMUNICATION 0x09 ///< Communications device\r
44#define MFI_SCSI_IO_TYPE_A 0x0A ///< Obsolete\r
45#define MFI_SCSI_IO_TYPE_B 0x0B ///< Obsolete\r
46#define MFI_SCSI_IO_TYPE_RAID 0x0C ///< Storage array controller device (e.g., RAID)\r
47#define MFI_SCSI_IO_TYPE_SES 0x0D ///< Enclosure services device\r
48#define MFI_SCSI_IO_TYPE_RBC 0x0E ///< Simplified direct-access device (e.g., magnetic disk)\r
49#define MFI_SCSI_IO_TYPE_OCRW 0x0F ///< Optical card reader/writer device\r
50#define MFI_SCSI_IO_TYPE_BRIDGE 0x10 ///< Bridge Controller Commands\r
51#define MFI_SCSI_IO_TYPE_OSD 0x11 ///< Object-based Storage Device\r
52#define EFI_SCSI_IO_TYPE_RESERVED_LOW 0x12 ///< Reserved (low)\r
53#define EFI_SCSI_IO_TYPE_RESERVED_HIGH 0x1E ///< Reserved (high)\r
54#define EFI_SCSI_IO_TYPE_UNKNOWN 0x1F ///< Unknown no device type\r
55\r
d1f95000 56//\r
57// SCSI Data Direction definition\r
58//\r
59#define EFI_SCSI_IO_DATA_DIRECTION_READ 0\r
60#define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1\r
61#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2\r
62\r
63//\r
64// SCSI Host Adapter Status definition\r
65//\r
66#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00\r
992f22b9
LG
67#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 ///< timeout when processing the command\r
68#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b ///< timeout when waiting for the command processing\r
69#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d ///< a message reject was received when processing command\r
70#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e ///< a bus reset was detected\r
d1f95000 71#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f\r
992f22b9
LG
72#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 ///< the adapter failed in issuing request sense command\r
73#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 ///< selection timeout\r
74#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 ///< data overrun or data underrun\r
75#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 ///< Unexepected bus free\r
76#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 ///< Target bus phase sequence failure\r
d1f95000 77#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f\r
78\r
79\r
80//\r
81// SCSI Target Status definition\r
82//\r
83#define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00\r
992f22b9
LG
84#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 ///< check condition\r
85#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 ///< condition met\r
86#define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 ///< busy\r
87#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 ///< intermediate\r
88#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 ///< intermediate-condition met\r
89#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 ///< reservation conflict\r
90#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 ///< command terminated\r
91#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 ///< queue full\r
d1f95000 92\r
93typedef struct {\r
992f22b9
LG
94 ///\r
95 /// The timeout, in 100 ns units, to use for the execution of this SCSI\r
96 /// Request Packet. A Timeout value of 0 means that this function\r
97 /// will wait indefinitely for the SCSI Request Packet to execute. If\r
98 /// Timeout is greater than zero, then this function will return\r
99 /// EFI_TIMEOUT if the time required to execute the SCSI Request\r
100 /// Packet is greater than Timeout.\r
101 ///\r
d1f95000 102 UINT64 Timeout;\r
992f22b9
LG
103 ///\r
104 /// A pointer to the data buffer to transfer between the SCSI\r
105 /// controller and the SCSI device for SCSI READ command\r
106 ///\r
d1f95000 107 VOID *InDataBuffer;\r
992f22b9
LG
108 ///\r
109 /// A pointer to the data buffer to transfer between the SCSI\r
110 /// controller and the SCSI device for SCSI WRITE command.\r
111 ///\r
d1f95000 112 VOID *OutDataBuffer;\r
992f22b9
LG
113 ///\r
114 /// A pointer to the sense data that was generated by the execution of\r
115 /// the SCSI Request Packet.\r
116 ///\r
d1f95000 117 VOID *SenseData;\r
992f22b9
LG
118 ///\r
119 /// A pointer to buffer that contains the Command Data Block to\r
120 /// send to the SCSI device.\r
121 ///\r
d1f95000 122 VOID *Cdb;\r
992f22b9
LG
123 ///\r
124 /// On Input, the size, in bytes, of InDataBuffer. On output, the\r
125 /// number of bytes transferred between the SCSI controller and the SCSI device.\r
126 ///\r
d1f95000 127 UINT32 InTransferLength;\r
992f22b9
LG
128 ///\r
129 /// On Input, the size, in bytes of OutDataBuffer. On Output, the\r
130 /// Number of bytes transferred between SCSI Controller and the SCSI device.\r
131 ///\r
d1f95000 132 UINT32 OutTransferLength;\r
992f22b9
LG
133 ///\r
134 /// The length, in bytes, of the buffer Cdb. The standard values are\r
135 /// 6, 10, 12, and 16, but other values are possible if a variable length CDB is used.\r
136 ///\r
d1f95000 137 UINT8 CdbLength;\r
992f22b9
LG
138 ///\r
139 /// The direction of the data transfer. 0 for reads, 1 for writes. A\r
140 /// value of 2 is Reserved for Bi-Directional SCSI commands.\r
141 ///\r
d1f95000 142 UINT8 DataDirection;\r
992f22b9
LG
143 ///\r
144 /// The status of the SCSI Host Controller that produces the SCSI\r
145 /// bus where the SCSI device attached when the SCSI Request\r
146 /// Packet was executed on the SCSI Controller.\r
147 ///\r
d1f95000 148 UINT8 HostAdapterStatus;\r
992f22b9
LG
149 ///\r
150 /// The status returned by the SCSI device when the SCSI Request\r
151 /// Packet was executed.\r
152 ///\r
d1f95000 153 UINT8 TargetStatus;\r
992f22b9
LG
154 ///\r
155 /// On input, the length in bytes of the SenseData buffer. On\r
156 /// output, the number of bytes written to the SenseData buffer.\r
157 ///\r
d1f95000 158 UINT8 SenseDataLength;\r
159} EFI_SCSI_IO_SCSI_REQUEST_PACKET;\r
160\r
161/**\r
162 Retrieves the device type information of the SCSI Controller.\r
163\r
164 @param This Protocol instance pointer.\r
165 @param DeviceType A pointer to the device type information\r
166 retrieved from the SCSI Controller.\r
167\r
630b4187 168 @retval EFI_SUCCESS Retrieved the device type information successfully.\r
d1f95000 169 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.\r
170\r
171**/\r
172typedef\r
173EFI_STATUS\r
8b13229b 174(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE)(\r
d1f95000 175 IN EFI_SCSI_IO_PROTOCOL *This,\r
176 OUT UINT8 *DeviceType\r
ed66e1bc 177 );\r
d1f95000 178\r
179/**\r
180 Retrieves the device location in the SCSI channel.\r
181\r
182 @param This Protocol instance pointer.\r
183 @param Target A pointer to the Target ID of a SCSI device\r
184 on the SCSI channel.\r
185 @param Lun A pointer to the LUN of the SCSI device on\r
186 the SCSI channel.\r
187\r
188 @retval EFI_SUCCESS Retrieves the device location successfully.\r
189 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL.\r
190\r
191**/\r
192typedef\r
193EFI_STATUS\r
8b13229b 194(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION)(\r
d1f95000 195 IN EFI_SCSI_IO_PROTOCOL *This,\r
196 IN OUT UINT8 **Target,\r
197 OUT UINT64 *Lun\r
ed66e1bc 198 );\r
d1f95000 199\r
200/**\r
201 Resets the SCSI Bus that the SCSI Controller is attached to.\r
202\r
203 @param This Protocol instance pointer.\r
204\r
205 @retval EFI_SUCCESS The SCSI bus is reset successfully.\r
206 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.\r
207 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the\r
208 SCSI Host Controller.\r
209 @retval EFI_TIMEOUT A timeout occurred while attempting to reset\r
210 the SCSI bus.\r
211\r
212**/\r
213typedef\r
214EFI_STATUS\r
8b13229b 215(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS)(\r
d1f95000 216 IN EFI_SCSI_IO_PROTOCOL *This\r
ed66e1bc 217 );\r
d1f95000 218\r
219/**\r
220 Resets the SCSI Controller that the device handle specifies.\r
221\r
222 @param This Protocol instance pointer.\r
223\r
224 @retval EFI_SUCCESS Reset the SCSI controller successfully.\r
630b4187 225 @retval EFI_DEVICE_ERROR Errors were encountered when resetting the\r
d1f95000 226 SCSI Controller.\r
227 @retval EFI_UNSUPPORTED The SCSI bus does not support a device\r
228 reset operation.\r
229 @retval EFI_TIMEOUT A timeout occurred while attempting to\r
230 reset the SCSI Controller.\r
231\r
232**/\r
233typedef\r
234EFI_STATUS\r
8b13229b 235(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE)(\r
d1f95000 236 IN EFI_SCSI_IO_PROTOCOL *This\r
ed66e1bc 237 );\r
d1f95000 238\r
239\r
240/**\r
241 Sends a SCSI Request Packet to the SCSI Controller for execution.\r
242\r
243 @param This Protocol instance pointer.\r
244 @param Packet The SCSI request packet to send to the SCSI\r
245 Controller specified by the device handle.\r
630b4187 246 @param Event If the SCSI bus to which the SCSI device is attached\r
d1f95000 247 does not support non-blocking I/O, then Event is\r
248 ignored, and blocking I/O is performed.\r
249 If Event is NULL, then blocking I/O is performed.\r
250 If Event is not NULL and non-blocking I/O is\r
251 supported, then non-blocking I/O is performed,\r
252 and Event will be signaled when the SCSI Request\r
253 Packet completes.\r
254\r
255 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host\r
256 successfully, and TransferLength bytes were\r
630b4187 257 transferred to/from DataBuffer. See\r
d1f95000 258 HostAdapterStatus, TargetStatus,\r
259 SenseDataLength, and SenseData in that order\r
260 for additional status information.\r
c7a54f25 261 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,\r
d1f95000 262 but the entire DataBuffer could not be transferred.\r
263 The actual number of bytes transferred is returned\r
264 in TransferLength. See HostAdapterStatus,\r
265 TargetStatus, SenseDataLength, and SenseData in\r
266 that order for additional status information.\r
267 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
268 there are too many SCSI Command Packets already\r
269 queued.The caller may retry again later.\r
270 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
271 the SCSI Request Packet. See HostAdapterStatus,\r
272 TargetStatus, SenseDataLength, and SenseData in\r
273 that order for additional status information.\r
274 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.\r
275 The SCSI Request Packet was not sent, so no\r
276 additional status information is available.\r
277 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
278 is not supported by the SCSI initiator(i.e., SCSI\r
279 Host Controller). The SCSI Request Packet was not\r
280 sent, so no additional status information is\r
281 available.\r
282 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI\r
283 Request Packet to execute. See HostAdapterStatus,\r
284 TargetStatus, SenseDataLength, and SenseData in\r
285 that order for additional status information.\r
286\r
287**/\r
288typedef\r
289EFI_STATUS\r
8b13229b 290(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND)(\r
d1f95000 291 IN EFI_SCSI_IO_PROTOCOL *This,\r
292 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet,\r
293 IN EFI_EVENT Event OPTIONAL\r
ed66e1bc 294 );\r
d1f95000 295\r
44717a39 296///\r
297/// Provides services to manage and communicate with SCSI devices.\r
298///\r
d1f95000 299struct _EFI_SCSI_IO_PROTOCOL {\r
300 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType;\r
301 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation;\r
302 EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus;\r
303 EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice;\r
a02e796b 304 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand; \r
1f08a159 305\r
306 ///\r
307 /// Supplies the alignment requirement for any buffer used in a data transfer. \r
308 /// IoAlign values of 0 and 1 mean that the buffer can be placed anywhere in memory. \r
309 /// Otherwise, IoAlign must be a power of 2, and the requirement is that the \r
310 /// start address of a buffer must be evenly divisible by IoAlign with no remainder.\r
311 ///\r
d1f95000 312 UINT32 IoAlign;\r
313};\r
314\r
315extern EFI_GUID gEfiScsiIoProtocolGuid;\r
316\r
317#endif\r