]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
Update to support to produce Component Name and & Component Name 2 protocol based...
[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 extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2;
99
100 EFI_STATUS
101 EFIAPI
102 SCSIBusDriverBindingSupported (
103 IN EFI_DRIVER_BINDING_PROTOCOL *This,
104 IN EFI_HANDLE Controller,
105 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
106 );
107
108 EFI_STATUS
109 EFIAPI
110 SCSIBusDriverBindingStart (
111 IN EFI_DRIVER_BINDING_PROTOCOL *This,
112 IN EFI_HANDLE Controller,
113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
114 );
115
116 EFI_STATUS
117 EFIAPI
118 SCSIBusDriverBindingStop (
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,
120 IN EFI_HANDLE Controller,
121 IN UINTN NumberOfChildren,
122 IN EFI_HANDLE *ChildHandleBuffer
123 );
124
125 //
126 // EFI Component Name Functions
127 //
128 /**
129 Retrieves a Unicode string that is the user readable name of the driver.
130
131 This function retrieves the user readable name of a driver in the form of a
132 Unicode string. If the driver specified by This has a user readable name in
133 the language specified by Language, then a pointer to the driver name is
134 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
135 by This does not support the language specified by Language,
136 then EFI_UNSUPPORTED is returned.
137
138 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
139 EFI_COMPONENT_NAME_PROTOCOL instance.
140
141 @param Language[in] A pointer to a Null-terminated ASCII string
142 array indicating the language. This is the
143 language of the driver name that the caller is
144 requesting, and it must match one of the
145 languages specified in SupportedLanguages. The
146 number of languages supported by a driver is up
147 to the driver writer. Language is specified
148 in RFC 3066 or ISO 639-2 language code format.
149
150 @param DriverName[out] A pointer to the Unicode string to return.
151 This Unicode string is the name of the
152 driver specified by This in the language
153 specified by Language.
154
155 @retval EFI_SUCCESS The Unicode string for the Driver specified by
156 This and the language specified by Language was
157 returned in DriverName.
158
159 @retval EFI_INVALID_PARAMETER Language is NULL.
160
161 @retval EFI_INVALID_PARAMETER DriverName is NULL.
162
163 @retval EFI_UNSUPPORTED The driver specified by This does not support
164 the language specified by Language.
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 ScsiBusComponentNameGetDriverName (
170 IN EFI_COMPONENT_NAME_PROTOCOL *This,
171 IN CHAR8 *Language,
172 OUT CHAR16 **DriverName
173 );
174
175
176 /**
177 Retrieves a Unicode string that is the user readable name of the controller
178 that is being managed by a driver.
179
180 This function retrieves the user readable name of the controller specified by
181 ControllerHandle and ChildHandle in the form of a Unicode string. If the
182 driver specified by This has a user readable name in the language specified by
183 Language, then a pointer to the controller name is returned in ControllerName,
184 and EFI_SUCCESS is returned. If the driver specified by This is not currently
185 managing the controller specified by ControllerHandle and ChildHandle,
186 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
187 support the language specified by Language, then EFI_UNSUPPORTED is returned.
188
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
191
192 @param ControllerHandle[in] The handle of a controller that the driver
193 specified by This is managing. This handle
194 specifies the controller whose name is to be
195 returned.
196
197 @param ChildHandle[in] The handle of the child controller to retrieve
198 the name of. This is an optional parameter that
199 may be NULL. It will be NULL for device
200 drivers. It will also be NULL for a bus drivers
201 that wish to retrieve the name of the bus
202 controller. It will not be NULL for a bus
203 driver that wishes to retrieve the name of a
204 child controller.
205
206 @param Language[in] A pointer to a Null-terminated ASCII string
207 array indicating the language. This is the
208 language of the driver name that the caller is
209 requesting, and it must match one of the
210 languages specified in SupportedLanguages. The
211 number of languages supported by a driver is up
212 to the driver writer. Language is specified in
213 RFC 3066 or ISO 639-2 language code format.
214
215 @param ControllerName[out] A pointer to the Unicode string to return.
216 This Unicode string is the name of the
217 controller specified by ControllerHandle and
218 ChildHandle in the language specified by
219 Language from the point of view of the driver
220 specified by This.
221
222 @retval EFI_SUCCESS The Unicode string for the user readable name in
223 the language specified by Language for the
224 driver specified by This was returned in
225 DriverName.
226
227 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
228
229 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
230 EFI_HANDLE.
231
232 @retval EFI_INVALID_PARAMETER Language is NULL.
233
234 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
235
236 @retval EFI_UNSUPPORTED The driver specified by This is not currently
237 managing the controller specified by
238 ControllerHandle and ChildHandle.
239
240 @retval EFI_UNSUPPORTED The driver specified by This does not support
241 the language specified by Language.
242
243 **/
244 EFI_STATUS
245 EFIAPI
246 ScsiBusComponentNameGetControllerName (
247 IN EFI_COMPONENT_NAME_PROTOCOL *This,
248 IN EFI_HANDLE ControllerHandle,
249 IN EFI_HANDLE ChildHandle OPTIONAL,
250 IN CHAR8 *Language,
251 OUT CHAR16 **ControllerName
252 );
253
254
255 EFI_STATUS
256 EFIAPI
257 ScsiGetDeviceType (
258 IN EFI_SCSI_IO_PROTOCOL *This,
259 OUT UINT8 *DeviceType
260 )
261 /*++
262
263 Routine Description:
264
265 Retrieves the device type information of the SCSI Controller.
266
267 Arguments:
268
269 This - Protocol instance pointer.
270 DeviceType - A pointer to the device type information
271 retrieved from the SCSI Controller.
272
273 Returns:
274
275 EFI_SUCCESS - Retrieves the device type information successfully.
276 EFI_INVALID_PARAMETER - The DeviceType is NULL.
277
278 --*/
279 ;
280
281 EFI_STATUS
282 EFIAPI
283 ScsiResetBus (
284 IN EFI_SCSI_IO_PROTOCOL *This
285 )
286 /*++
287
288 Routine Description:
289
290 Resets the SCSI Bus that the SCSI Controller is attached to.
291
292 Arguments:
293
294 This - Protocol instance pointer.
295
296 Returns:
297
298 EFI_SUCCESS - The SCSI bus is reset successfully.
299 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
300 EFI_UNSUPPORTED - The bus reset operation is not supported by the
301 SCSI Host Controller.
302 EFI_TIMEOUT - A timeout occurred while attempting to reset
303 the SCSI bus.
304
305 --*/
306 ;
307
308 EFI_STATUS
309 EFIAPI
310 ScsiResetDevice (
311 IN EFI_SCSI_IO_PROTOCOL *This
312 )
313 /*++
314
315 Routine Description:
316
317 Resets the SCSI Controller that the device handle specifies.
318
319 Arguments:
320
321 This - Protocol instance pointer.
322
323 Returns:
324
325 EFI_SUCCESS - Reset the SCSI controller successfully.
326 EFI_DEVICE_ERROR - Errors are encountered when resetting the
327 SCSI Controller.
328 EFI_UNSUPPORTED - The SCSI bus does not support a device
329 reset operation.
330 EFI_TIMEOUT - A timeout occurred while attempting to
331 reset the SCSI Controller.
332
333 --*/
334 ;
335
336 EFI_STATUS
337 EFIAPI
338 ScsiExecuteSCSICommand (
339 IN EFI_SCSI_IO_PROTOCOL *This,
340 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,
341 IN EFI_EVENT Event
342 )
343 /*++
344
345 Routine Description:
346
347 Sends a SCSI Request Packet to the SCSI Controller for execution.
348
349 Arguments:
350
351 This - Protocol instance pointer.
352 Packet - The SCSI request packet to send to the SCSI
353 Controller specified by the device handle.
354 Event - If the SCSI bus where the SCSI device is attached
355 does not support non-blocking I/O, then Event is
356 ignored, and blocking I/O is performed.
357 If Event is NULL, then blocking I/O is performed.
358 If Event is not NULL and non-blocking I/O is
359 supported, then non-blocking I/O is performed,
360 and Event will be signaled when the SCSI Request
361 Packet completes.
362 Returns:
363
364 EFI_SUCCESS - The SCSI Request Packet was sent by the host
365 successfully, and TransferLength bytes were
366 transferred to/from DataBuffer.See
367 HostAdapterStatus, TargetStatus,
368 SenseDataLength, and SenseData in that order
369 for additional status information.
370 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
371 but the entire DataBuffer could not be transferred.
372 The actual number of bytes transferred is returned
373 in TransferLength. See HostAdapterStatus,
374 TargetStatus, SenseDataLength, and SenseData in
375 that order for additional status information.
376 EFI_NOT_READY - The SCSI Request Packet could not be sent because
377 there are too many SCSI Command Packets already
378 queued.The caller may retry again later.
379 EFI_DEVICE_ERROR - A device error occurred while attempting to send
380 the SCSI Request Packet. See HostAdapterStatus,
381 TargetStatus, SenseDataLength, and SenseData in
382 that order for additional status information.
383 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
384 The SCSI Request Packet was not sent, so no
385 additional status information is available.
386 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
387 is not supported by the SCSI initiator(i.e., SCSI
388 Host Controller). The SCSI Request Packet was not
389 sent, so no additional status information is
390 available.
391 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
392 Request Packet to execute. See HostAdapterStatus,
393 TargetStatus, SenseDataLength, and SenseData in
394 that order for additional status information.
395
396 --*/
397 ;
398
399 EFI_STATUS
400 ScsiScanCreateDevice (
401 EFI_DRIVER_BINDING_PROTOCOL *This,
402 EFI_HANDLE Controller,
403 SCSI_TARGET_ID *TargetId,
404 UINT64 Lun,
405 SCSI_BUS_DEVICE *ScsiBusDev
406 )
407 /*++
408
409 Routine Description:
410
411 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
412
413 Arguments:
414
415 This - Protocol instance pointer
416 Controller - Controller handle
417 Pun - The Pun of the SCSI device on the SCSI channel.
418 Lun - The Lun of the SCSI device on the SCSI channel.
419 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
420
421 Returns:
422
423 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
424 EFI_OUT_OF_RESOURCES - Fail to discover the device.
425
426 --*/
427 ;
428
429 BOOLEAN
430 DiscoverScsiDevice (
431 SCSI_IO_DEV *ScsiIoDevice
432 )
433 /*++
434
435 Routine Description:
436
437 Discovery SCSI Device
438
439 Arguments:
440
441 ScsiIoDevice - The pointer of SCSI_IO_DEV
442
443 Returns:
444
445 TRUE - Find SCSI Device and verify it.
446 FALSE - Unable to find SCSI Device.
447
448 --*/
449 ;
450 #endif