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