]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
1. Set the Target array to zero before fill the target id.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / ScsiBus.h
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ScsiBus.h
15
16 Abstract:
17
18 Header file for SCSI Bus Driver.
19
20 Revision History
21 --*/
22
23 #ifndef _SCSI_BUS_H
24 #define _SCSI_BUS_H
25
26
27 #include <IndustryStandard/scsi.h>
28 //
29 // 1000 * 1000 * 10
30 //
31 #define ONE_SECOND_TIMER 10000000
32
33 #define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')
34
35 typedef struct _SCSI_TARGET_ID {
36 union {
37 UINT32 Scsi;
38 UINT8 ExtScsi[4];
39 } ScsiId;
40 UINT8 ExtScsiId[12];
41 }SCSI_TARGET_ID;
42
43
44 typedef struct {
45 VOID *Data1;
46 VOID *Data2;
47 } SCSI_EVENT_DATA;
48
49
50 typedef struct {
51 UINT32 Signature;
52 EFI_HANDLE Handle;
53 EFI_SCSI_IO_PROTOCOL ScsiIo;
54 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
55 BOOLEAN ExtScsiSupport;
56 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
57 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
58 SCSI_TARGET_ID Pun;
59 UINT64 Lun;
60 UINT8 ScsiDeviceType;
61 UINT8 ScsiVersion;
62 BOOLEAN RemovableDevice;
63 } SCSI_IO_DEV;
64
65 #define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)
66
67 //
68 // SCSI Bus Controller device strcuture
69 //
70 #define EFI_SCSI_BUS_PROTOCOL_GUID \
71 { \
72 0x5261213D, 0x3A3D, 0x441E, {0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17} \
73 }
74
75 typedef struct _EFI_SCSI_BUS_PROTOCOL {
76 UINT64 Reserved;
77 } EFI_SCSI_BUS_PROTOCOL;
78
79 #define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')
80
81
82 typedef struct _SCSI_BUS_DEVICE {
83 UINTN Signature;
84 EFI_SCSI_BUS_PROTOCOL BusIdentify;
85 BOOLEAN ExtScsiSupport;
86 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiInterface;
87 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiInterface;
88 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
89 } SCSI_BUS_DEVICE;
90
91 #define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)
92
93 //
94 // Global Variables
95 //
96 extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;
97 extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;
98
99 EFI_STATUS
100 EFIAPI
101 SCSIBusDriverBindingSupported (
102 IN EFI_DRIVER_BINDING_PROTOCOL *This,
103 IN EFI_HANDLE Controller,
104 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
105 );
106
107 EFI_STATUS
108 EFIAPI
109 SCSIBusDriverBindingStart (
110 IN EFI_DRIVER_BINDING_PROTOCOL *This,
111 IN EFI_HANDLE Controller,
112 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
113 );
114
115 EFI_STATUS
116 EFIAPI
117 SCSIBusDriverBindingStop (
118 IN EFI_DRIVER_BINDING_PROTOCOL *This,
119 IN EFI_HANDLE Controller,
120 IN UINTN NumberOfChildren,
121 IN EFI_HANDLE *ChildHandleBuffer
122 );
123
124 //
125 // EFI Component Name Functions
126 //
127 EFI_STATUS
128 EFIAPI
129 ScsiBusComponentNameGetDriverName (
130 IN EFI_COMPONENT_NAME_PROTOCOL *This,
131 IN CHAR8 *Language,
132 OUT CHAR16 **DriverName
133 );
134
135 EFI_STATUS
136 EFIAPI
137 ScsiBusComponentNameGetControllerName (
138 IN EFI_COMPONENT_NAME_PROTOCOL *This,
139 IN EFI_HANDLE ControllerHandle,
140 IN EFI_HANDLE ChildHandle OPTIONAL,
141 IN CHAR8 *Language,
142 OUT CHAR16 **ControllerName
143 );
144
145 EFI_STATUS
146 EFIAPI
147 ScsiGetDeviceType (
148 IN EFI_SCSI_IO_PROTOCOL *This,
149 OUT UINT8 *DeviceType
150 )
151 /*++
152
153 Routine Description:
154
155 Retrieves the device type information of the SCSI Controller.
156
157 Arguments:
158
159 This - Protocol instance pointer.
160 DeviceType - A pointer to the device type information
161 retrieved from the SCSI Controller.
162
163 Returns:
164
165 EFI_SUCCESS - Retrieves the device type information successfully.
166 EFI_INVALID_PARAMETER - The DeviceType is NULL.
167
168 --*/
169 ;
170
171 EFI_STATUS
172 EFIAPI
173 ScsiResetBus (
174 IN EFI_SCSI_IO_PROTOCOL *This
175 )
176 /*++
177
178 Routine Description:
179
180 Resets the SCSI Bus that the SCSI Controller is attached to.
181
182 Arguments:
183
184 This - Protocol instance pointer.
185
186 Returns:
187
188 EFI_SUCCESS - The SCSI bus is reset successfully.
189 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
190 EFI_UNSUPPORTED - The bus reset operation is not supported by the
191 SCSI Host Controller.
192 EFI_TIMEOUT - A timeout occurred while attempting to reset
193 the SCSI bus.
194
195 --*/
196 ;
197
198 EFI_STATUS
199 EFIAPI
200 ScsiResetDevice (
201 IN EFI_SCSI_IO_PROTOCOL *This
202 )
203 /*++
204
205 Routine Description:
206
207 Resets the SCSI Controller that the device handle specifies.
208
209 Arguments:
210
211 This - Protocol instance pointer.
212
213 Returns:
214
215 EFI_SUCCESS - Reset the SCSI controller successfully.
216 EFI_DEVICE_ERROR - Errors are encountered when resetting the
217 SCSI Controller.
218 EFI_UNSUPPORTED - The SCSI bus does not support a device
219 reset operation.
220 EFI_TIMEOUT - A timeout occurred while attempting to
221 reset the SCSI Controller.
222
223 --*/
224 ;
225
226 EFI_STATUS
227 EFIAPI
228 ScsiExecuteSCSICommand (
229 IN EFI_SCSI_IO_PROTOCOL *This,
230 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,
231 IN EFI_EVENT Event
232 )
233 /*++
234
235 Routine Description:
236
237 Sends a SCSI Request Packet to the SCSI Controller for execution.
238
239 Arguments:
240
241 This - Protocol instance pointer.
242 Packet - The SCSI request packet to send to the SCSI
243 Controller specified by the device handle.
244 Event - If the SCSI bus where the SCSI device is attached
245 does not support non-blocking I/O, then Event is
246 ignored, and blocking I/O is performed.
247 If Event is NULL, then blocking I/O is performed.
248 If Event is not NULL and non-blocking I/O is
249 supported, then non-blocking I/O is performed,
250 and Event will be signaled when the SCSI Request
251 Packet completes.
252 Returns:
253
254 EFI_SUCCESS - The SCSI Request Packet was sent by the host
255 successfully, and TransferLength bytes were
256 transferred to/from DataBuffer.See
257 HostAdapterStatus, TargetStatus,
258 SenseDataLength, and SenseData in that order
259 for additional status information.
260 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
261 but the entire DataBuffer could not be transferred.
262 The actual number of bytes transferred is returned
263 in TransferLength. See HostAdapterStatus,
264 TargetStatus, SenseDataLength, and SenseData in
265 that order for additional status information.
266 EFI_NOT_READY - The SCSI Request Packet could not be sent because
267 there are too many SCSI Command Packets already
268 queued.The caller may retry again later.
269 EFI_DEVICE_ERROR - A device error occurred while attempting to send
270 the SCSI Request Packet. See HostAdapterStatus,
271 TargetStatus, SenseDataLength, and SenseData in
272 that order for additional status information.
273 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
274 The SCSI Request Packet was not sent, so no
275 additional status information is available.
276 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
277 is not supported by the SCSI initiator(i.e., SCSI
278 Host Controller). The SCSI Request Packet was not
279 sent, so no additional status information is
280 available.
281 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
282 Request Packet to execute. See HostAdapterStatus,
283 TargetStatus, SenseDataLength, and SenseData in
284 that order for additional status information.
285
286 --*/
287 ;
288
289 EFI_STATUS
290 ScsiScanCreateDevice (
291 EFI_DRIVER_BINDING_PROTOCOL *This,
292 EFI_HANDLE Controller,
293 SCSI_TARGET_ID *TargetId,
294 UINT64 Lun,
295 SCSI_BUS_DEVICE *ScsiBusDev
296 )
297 /*++
298
299 Routine Description:
300
301 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
302
303 Arguments:
304
305 This - Protocol instance pointer
306 Controller - Controller handle
307 Pun - The Pun of the SCSI device on the SCSI channel.
308 Lun - The Lun of the SCSI device on the SCSI channel.
309 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
310
311 Returns:
312
313 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
314 EFI_OUT_OF_RESOURCES - Fail to discover the device.
315
316 --*/
317 ;
318
319 BOOLEAN
320 DiscoverScsiDevice (
321 SCSI_IO_DEV *ScsiIoDevice
322 )
323 /*++
324
325 Routine Description:
326
327 Discovery SCSI Device
328
329 Arguments:
330
331 ScsiIoDevice - The pointer of SCSI_IO_DEV
332
333 Returns:
334
335 TRUE - Find SCSI Device and verify it.
336 FALSE - Unable to find SCSI Device.
337
338 --*/
339 ;
340 #endif