]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Protocol/ScsiIo.h
MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiIo.h
... / ...
CommitLineData
1/** @file\r
2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.\r
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
6\r
7 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
8 This program and the accompanying materials \r
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
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
23 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \\r
24 }\r
25\r
26///\r
27/// Forward reference for pure ANSI compatability\r
28///\r
29typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;\r
30\r
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
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
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
71#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f\r
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
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
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
92\r
93typedef struct {\r
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
102 UINT64 Timeout;\r
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
107 VOID *InDataBuffer;\r
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
112 VOID *OutDataBuffer;\r
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
117 VOID *SenseData;\r
118 ///\r
119 /// A pointer to buffer that contains the Command Data Block to\r
120 /// send to the SCSI device.\r
121 ///\r
122 VOID *Cdb;\r
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
127 UINT32 InTransferLength;\r
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
132 UINT32 OutTransferLength;\r
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
137 UINT8 CdbLength;\r
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
142 UINT8 DataDirection;\r
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
148 UINT8 HostAdapterStatus;\r
149 ///\r
150 /// The status returned by the SCSI device when the SCSI Request\r
151 /// Packet was executed.\r
152 ///\r
153 UINT8 TargetStatus;\r
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
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
168 @retval EFI_SUCCESS Retrieved the device type information successfully.\r
169 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.\r
170\r
171**/\r
172typedef\r
173EFI_STATUS\r
174(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE)(\r
175 IN EFI_SCSI_IO_PROTOCOL *This,\r
176 OUT UINT8 *DeviceType\r
177 );\r
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
194(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION)(\r
195 IN EFI_SCSI_IO_PROTOCOL *This,\r
196 IN OUT UINT8 **Target,\r
197 OUT UINT64 *Lun\r
198 );\r
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
215(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS)(\r
216 IN EFI_SCSI_IO_PROTOCOL *This\r
217 );\r
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
225 @retval EFI_DEVICE_ERROR Errors were encountered when resetting the\r
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
235(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE)(\r
236 IN EFI_SCSI_IO_PROTOCOL *This\r
237 );\r
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
246 @param Event If the SCSI bus to which the SCSI device is attached\r
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
257 transferred to/from DataBuffer. See\r
258 HostAdapterStatus, TargetStatus,\r
259 SenseDataLength, and SenseData in that order\r
260 for additional status information.\r
261 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,\r
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
290(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND)(\r
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
294 );\r
295\r
296///\r
297/// Provides services to manage and communicate with SCSI devices.\r
298///\r
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
304 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand; \r
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
312 UINT32 IoAlign;\r
313};\r
314\r
315extern EFI_GUID gEfiScsiIoProtocolGuid;\r
316\r
317#endif\r