]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/ScsiIo.h
1) Modify ScsiIo protocol according to UEFI specification
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiIo.h
1 /** @file
2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __EFI_SCSI_IO_PROTOCOL_H__
16 #define __EFI_SCSI_IO_PROTOCOL_H__
17
18 #define EFI_SCSI_IO_PROTOCOL_GUID \
19 { \
20 0x932f4736, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
21 }
22
23 //
24 // Forward reference for pure ANSI compatability
25 //
26 typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;
27
28 //
29 // SCSI Data Direction definition
30 //
31 #define EFI_SCSI_IO_DATA_DIRECTION_READ 0
32 #define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1
33 #define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2
34
35 //
36 // SCSI Host Adapter Status definition
37 //
38 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00
39 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command
40 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing
41 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command
42 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected
43 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
44 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command
45 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout
46 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun
47 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free
48 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure
49 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f
50
51
52 //
53 // SCSI Target Status definition
54 //
55 #define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00
56 #define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition
57 #define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 // condition met
58 #define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 // busy
59 #define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate
60 #define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met
61 #define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict
62 #define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated
63 #define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 // queue full
64
65 typedef struct {
66 UINT64 Timeout;
67 VOID *InDataBuffer;
68 VOID *OutDataBuffer;
69 VOID *SenseData;
70 VOID *Cdb;
71 UINT32 InTransferLength;
72 UINT32 OutTransferLength;
73 UINT8 CdbLength;
74 UINT8 DataDirection;
75 UINT8 HostAdapterStatus;
76 UINT8 TargetStatus;
77 UINT8 SenseDataLength;
78 } EFI_SCSI_IO_SCSI_REQUEST_PACKET;
79
80 /**
81 Retrieves the device type information of the SCSI Controller.
82
83 @param This Protocol instance pointer.
84 @param DeviceType A pointer to the device type information
85 retrieved from the SCSI Controller.
86
87 @retval EFI_SUCCESS Retrieves the device type information successfully.
88 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.
89
90 **/
91 typedef
92 EFI_STATUS
93 (EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE) (
94 IN EFI_SCSI_IO_PROTOCOL *This,
95 OUT UINT8 *DeviceType
96 )
97 ;
98
99 /**
100 Retrieves the device location in the SCSI channel.
101
102 @param This Protocol instance pointer.
103 @param Target A pointer to the Target ID of a SCSI device
104 on the SCSI channel.
105 @param Lun A pointer to the LUN of the SCSI device on
106 the SCSI channel.
107
108 @retval EFI_SUCCESS Retrieves the device location successfully.
109 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL.
110
111 **/
112 typedef
113 EFI_STATUS
114 (EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION) (
115 IN EFI_SCSI_IO_PROTOCOL *This,
116 IN OUT UINT8 **Target,
117 OUT UINT64 *Lun
118 )
119 ;
120
121 /**
122 Resets the SCSI Bus that the SCSI Controller is attached to.
123
124 @param This Protocol instance pointer.
125
126 @retval EFI_SUCCESS The SCSI bus is reset successfully.
127 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.
128 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the
129 SCSI Host Controller.
130 @retval EFI_TIMEOUT A timeout occurred while attempting to reset
131 the SCSI bus.
132
133 **/
134 typedef
135 EFI_STATUS
136 (EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS) (
137 IN EFI_SCSI_IO_PROTOCOL *This
138 )
139 ;
140
141 /**
142 Resets the SCSI Controller that the device handle specifies.
143
144 @param This Protocol instance pointer.
145
146 @retval EFI_SUCCESS Reset the SCSI controller successfully.
147 @retval EFI_DEVICE_ERROR Errors are encountered when resetting the
148 SCSI Controller.
149 @retval EFI_UNSUPPORTED The SCSI bus does not support a device
150 reset operation.
151 @retval EFI_TIMEOUT A timeout occurred while attempting to
152 reset the SCSI Controller.
153
154 **/
155 typedef
156 EFI_STATUS
157 (EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE) (
158 IN EFI_SCSI_IO_PROTOCOL *This
159 )
160 ;
161
162
163 /**
164 Sends a SCSI Request Packet to the SCSI Controller for execution.
165
166 @param This Protocol instance pointer.
167 @param Packet The SCSI request packet to send to the SCSI
168 Controller specified by the device handle.
169 @param Event If the SCSI bus where the SCSI device is attached
170 does not support non-blocking I/O, then Event is
171 ignored, and blocking I/O is performed.
172 If Event is NULL, then blocking I/O is performed.
173 If Event is not NULL and non-blocking I/O is
174 supported, then non-blocking I/O is performed,
175 and Event will be signaled when the SCSI Request
176 Packet completes.
177
178 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host
179 successfully, and TransferLength bytes were
180 transferred to/from DataBuffer.See
181 HostAdapterStatus, TargetStatus,
182 SenseDataLength, and SenseData in that order
183 for additional status information.
184 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed,
185 but the entire DataBuffer could not be transferred.
186 The actual number of bytes transferred is returned
187 in TransferLength. See HostAdapterStatus,
188 TargetStatus, SenseDataLength, and SenseData in
189 that order for additional status information.
190 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
191 there are too many SCSI Command Packets already
192 queued.The caller may retry again later.
193 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
194 the SCSI Request Packet. See HostAdapterStatus,
195 TargetStatus, SenseDataLength, and SenseData in
196 that order for additional status information.
197 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
198 The SCSI Request Packet was not sent, so no
199 additional status information is available.
200 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
201 is not supported by the SCSI initiator(i.e., SCSI
202 Host Controller). The SCSI Request Packet was not
203 sent, so no additional status information is
204 available.
205 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
206 Request Packet to execute. See HostAdapterStatus,
207 TargetStatus, SenseDataLength, and SenseData in
208 that order for additional status information.
209
210 **/
211 typedef
212 EFI_STATUS
213 (EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND) (
214 IN EFI_SCSI_IO_PROTOCOL *This,
215 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet,
216 IN EFI_EVENT Event OPTIONAL
217 )
218 ;
219
220 struct _EFI_SCSI_IO_PROTOCOL {
221 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType;
222 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation;
223 EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus;
224 EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice;
225 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand;
226 UINT32 IoAlign;
227 };
228
229 extern EFI_GUID gEfiScsiIoProtocolGuid;
230
231 #endif