]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
Remove IfrLibConstruct, because it do nothing.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / ScsiBus.h
CommitLineData
3a10d471 1/*++\r
2\r
9cb8724d 3Copyright (c) 2006, 2008, Intel Corporation \r
3a10d471 4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ScsiBus.h\r
15\r
16Abstract:\r
17\r
18 Header file for SCSI Bus Driver.\r
19\r
20Revision History\r
f36d6e66 21--*/\r
3a10d471 22\r
3a10d471 23#ifndef _SCSI_BUS_H\r
24#define _SCSI_BUS_H\r
25\r
26\r
9cb8724d 27#include <IndustryStandard/Scsi.h>\r
3a10d471 28//\r
29// 1000 * 1000 * 10\r
30//\r
31#define ONE_SECOND_TIMER 10000000 \r
32\r
33#define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')\r
34\r
70c94b3b 35typedef struct _SCSI_TARGET_ID {\r
36 union {\r
37 UINT32 Scsi;\r
38 UINT8 ExtScsi[4]; \r
39 } ScsiId;\r
40 UINT8 ExtScsiId[12];\r
41}SCSI_TARGET_ID;\r
42\r
43\r
44typedef struct {\r
45 VOID *Data1;\r
46 VOID *Data2;\r
47} SCSI_EVENT_DATA;\r
48\r
49\r
3a10d471 50typedef struct {\r
70c94b3b 51 UINT32 Signature;\r
52 EFI_HANDLE Handle;\r
53 EFI_SCSI_IO_PROTOCOL ScsiIo;\r
54 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
55 BOOLEAN ExtScsiSupport; \r
56 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r
57 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;\r
58 SCSI_TARGET_ID Pun;\r
59 UINT64 Lun;\r
60 UINT8 ScsiDeviceType;\r
61 UINT8 ScsiVersion;\r
62 BOOLEAN RemovableDevice;\r
3a10d471 63} SCSI_IO_DEV;\r
64\r
65#define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)\r
66\r
70c94b3b 67//\r
68// SCSI Bus Controller device strcuture\r
69//\r
70#define EFI_SCSI_BUS_PROTOCOL_GUID \\r
71 { \\r
84b5c78e 72 0x5261213D, 0x3A3D, 0x441E, {0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17} \\r
70c94b3b 73 }\r
74\r
75typedef struct _EFI_SCSI_BUS_PROTOCOL {\r
76 UINT64 Reserved;\r
77} EFI_SCSI_BUS_PROTOCOL;\r
78\r
79#define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')\r
80\r
81\r
82typedef struct _SCSI_BUS_DEVICE {\r
83 UINTN Signature;\r
84 EFI_SCSI_BUS_PROTOCOL BusIdentify;\r
85 BOOLEAN ExtScsiSupport; \r
86 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiInterface;\r
87 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiInterface;\r
88 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
89} SCSI_BUS_DEVICE;\r
90\r
91#define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)\r
92\r
3a10d471 93//\r
94// Global Variables\r
95//\r
70da5bc2 96extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;\r
97extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;\r
98extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2;\r
3a10d471 99\r
100EFI_STATUS\r
101EFIAPI\r
102SCSIBusDriverBindingSupported (\r
103 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
104 IN EFI_HANDLE Controller,\r
105 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
106 );\r
107\r
108EFI_STATUS\r
109EFIAPI\r
110SCSIBusDriverBindingStart (\r
111 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
112 IN EFI_HANDLE Controller,\r
113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
114 );\r
115\r
116EFI_STATUS\r
117EFIAPI\r
118SCSIBusDriverBindingStop (\r
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
120 IN EFI_HANDLE Controller,\r
121 IN UINTN NumberOfChildren,\r
122 IN EFI_HANDLE *ChildHandleBuffer\r
123 );\r
124\r
125//\r
126// EFI Component Name Functions\r
127//\r
70da5bc2 128/**\r
129 Retrieves a Unicode string that is the user readable name of the driver.\r
130\r
131 This function retrieves the user readable name of a driver in the form of a\r
132 Unicode string. If the driver specified by This has a user readable name in\r
133 the language specified by Language, then a pointer to the driver name is\r
134 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
135 by This does not support the language specified by Language,\r
136 then EFI_UNSUPPORTED is returned.\r
137\r
138 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
139 EFI_COMPONENT_NAME_PROTOCOL instance.\r
140\r
141 @param Language[in] A pointer to a Null-terminated ASCII string\r
142 array indicating the language. This is the\r
143 language of the driver name that the caller is\r
144 requesting, and it must match one of the\r
145 languages specified in SupportedLanguages. The\r
146 number of languages supported by a driver is up\r
147 to the driver writer. Language is specified\r
148 in RFC 3066 or ISO 639-2 language code format.\r
149\r
150 @param DriverName[out] A pointer to the Unicode string to return.\r
151 This Unicode string is the name of the\r
152 driver specified by This in the language\r
153 specified by Language.\r
154\r
155 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
156 This and the language specified by Language was\r
157 returned in DriverName.\r
158\r
159 @retval EFI_INVALID_PARAMETER Language is NULL.\r
160\r
161 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
162\r
163 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
164 the language specified by Language.\r
165\r
166**/\r
3a10d471 167EFI_STATUS\r
168EFIAPI\r
169ScsiBusComponentNameGetDriverName (\r
170 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
171 IN CHAR8 *Language,\r
172 OUT CHAR16 **DriverName\r
173 );\r
174\r
70da5bc2 175\r
176/**\r
177 Retrieves a Unicode string that is the user readable name of the controller\r
178 that is being managed by a driver.\r
179\r
180 This function retrieves the user readable name of the controller specified by\r
181 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
182 driver specified by This has a user readable name in the language specified by\r
183 Language, then a pointer to the controller name is returned in ControllerName,\r
184 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
185 managing the controller specified by ControllerHandle and ChildHandle,\r
186 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
187 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
188\r
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
190 EFI_COMPONENT_NAME_PROTOCOL instance.\r
191\r
192 @param ControllerHandle[in] The handle of a controller that the driver\r
193 specified by This is managing. This handle\r
194 specifies the controller whose name is to be\r
195 returned.\r
196\r
197 @param ChildHandle[in] The handle of the child controller to retrieve\r
198 the name of. This is an optional parameter that\r
199 may be NULL. It will be NULL for device\r
200 drivers. It will also be NULL for a bus drivers\r
201 that wish to retrieve the name of the bus\r
202 controller. It will not be NULL for a bus\r
203 driver that wishes to retrieve the name of a\r
204 child controller.\r
205\r
206 @param Language[in] A pointer to a Null-terminated ASCII string\r
207 array indicating the language. This is the\r
208 language of the driver name that the caller is\r
209 requesting, and it must match one of the\r
210 languages specified in SupportedLanguages. The\r
211 number of languages supported by a driver is up\r
212 to the driver writer. Language is specified in\r
213 RFC 3066 or ISO 639-2 language code format.\r
214\r
215 @param ControllerName[out] A pointer to the Unicode string to return.\r
216 This Unicode string is the name of the\r
217 controller specified by ControllerHandle and\r
218 ChildHandle in the language specified by\r
219 Language from the point of view of the driver\r
220 specified by This.\r
221\r
222 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
223 the language specified by Language for the\r
224 driver specified by This was returned in\r
225 DriverName.\r
226\r
227 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
228\r
229 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
230 EFI_HANDLE.\r
231\r
232 @retval EFI_INVALID_PARAMETER Language is NULL.\r
233\r
234 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
235\r
236 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
237 managing the controller specified by\r
238 ControllerHandle and ChildHandle.\r
239\r
240 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
241 the language specified by Language.\r
242\r
243**/\r
3a10d471 244EFI_STATUS\r
245EFIAPI\r
246ScsiBusComponentNameGetControllerName (\r
247 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
248 IN EFI_HANDLE ControllerHandle,\r
249 IN EFI_HANDLE ChildHandle OPTIONAL,\r
250 IN CHAR8 *Language,\r
251 OUT CHAR16 **ControllerName\r
252 );\r
253\r
70da5bc2 254\r
3a10d471 255EFI_STATUS\r
256EFIAPI\r
257ScsiGetDeviceType (\r
258 IN EFI_SCSI_IO_PROTOCOL *This,\r
259 OUT UINT8 *DeviceType\r
260 )\r
261/*++\r
262\r
263Routine Description:\r
264\r
70c94b3b 265 Retrieves the device type information of the SCSI Controller.\r
266 \r
3a10d471 267Arguments:\r
268\r
70c94b3b 269 This - Protocol instance pointer.\r
270 DeviceType - A pointer to the device type information\r
271 retrieved from the SCSI Controller. \r
3a10d471 272\r
273Returns:\r
274\r
70c94b3b 275 EFI_SUCCESS - Retrieves the device type information successfully.\r
276 EFI_INVALID_PARAMETER - The DeviceType is NULL.\r
3a10d471 277\r
278--*/\r
279;\r
280\r
281EFI_STATUS\r
282EFIAPI\r
283ScsiResetBus (\r
284 IN EFI_SCSI_IO_PROTOCOL *This\r
285 )\r
286/*++\r
287\r
288Routine Description:\r
289\r
70c94b3b 290 Resets the SCSI Bus that the SCSI Controller is attached to.\r
291 \r
3a10d471 292Arguments:\r
293\r
70c94b3b 294 This - Protocol instance pointer.\r
3a10d471 295\r
296Returns:\r
297\r
70c94b3b 298 EFI_SUCCESS - The SCSI bus is reset successfully.\r
299 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.\r
300 EFI_UNSUPPORTED - The bus reset operation is not supported by the\r
301 SCSI Host Controller.\r
302 EFI_TIMEOUT - A timeout occurred while attempting to reset \r
303 the SCSI bus.\r
3a10d471 304\r
305--*/\r
306;\r
307\r
308EFI_STATUS\r
309EFIAPI\r
310ScsiResetDevice (\r
311 IN EFI_SCSI_IO_PROTOCOL *This\r
312 )\r
313/*++\r
314\r
315Routine Description:\r
316\r
70c94b3b 317 Resets the SCSI Controller that the device handle specifies.\r
318 \r
3a10d471 319Arguments:\r
320\r
70c94b3b 321 This - Protocol instance pointer.\r
322 \r
3a10d471 323Returns:\r
324\r
70c94b3b 325 EFI_SUCCESS - Reset the SCSI controller successfully.\r
326 EFI_DEVICE_ERROR - Errors are encountered when resetting the\r
327 SCSI Controller.\r
328 EFI_UNSUPPORTED - The SCSI bus does not support a device \r
329 reset operation.\r
330 EFI_TIMEOUT - A timeout occurred while attempting to \r
331 reset the SCSI Controller.\r
3a10d471 332\r
333--*/\r
334;\r
335\r
336EFI_STATUS\r
337EFIAPI\r
338ScsiExecuteSCSICommand (\r
339 IN EFI_SCSI_IO_PROTOCOL *This,\r
340 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,\r
341 IN EFI_EVENT Event\r
342 )\r
343/*++\r
344\r
345Routine Description:\r
346\r
70c94b3b 347 Sends a SCSI Request Packet to the SCSI Controller for execution.\r
348 \r
3a10d471 349Arguments:\r
350\r
70c94b3b 351 This - Protocol instance pointer.\r
352 Packet - The SCSI request packet to send to the SCSI \r
353 Controller specified by the device handle.\r
354 Event - If the SCSI bus where the SCSI device is attached\r
355 does not support non-blocking I/O, then Event is \r
356 ignored, and blocking I/O is performed. \r
357 If Event is NULL, then blocking I/O is performed.\r
358 If Event is not NULL and non-blocking I/O is \r
359 supported, then non-blocking I/O is performed,\r
360 and Event will be signaled when the SCSI Request\r
361 Packet completes.\r
3a10d471 362Returns:\r
363\r
70c94b3b 364 EFI_SUCCESS - The SCSI Request Packet was sent by the host \r
365 successfully, and TransferLength bytes were \r
366 transferred to/from DataBuffer.See \r
367 HostAdapterStatus, TargetStatus, \r
368 SenseDataLength, and SenseData in that order\r
369 for additional status information.\r
370 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed, \r
371 but the entire DataBuffer could not be transferred.\r
372 The actual number of bytes transferred is returned\r
373 in TransferLength. See HostAdapterStatus, \r
374 TargetStatus, SenseDataLength, and SenseData in \r
375 that order for additional status information.\r
376 EFI_NOT_READY - The SCSI Request Packet could not be sent because \r
377 there are too many SCSI Command Packets already \r
378 queued.The caller may retry again later.\r
379 EFI_DEVICE_ERROR - A device error occurred while attempting to send \r
380 the SCSI Request Packet. See HostAdapterStatus, \r
381 TargetStatus, SenseDataLength, and SenseData in \r
382 that order for additional status information.\r
383 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid. \r
384 The SCSI Request Packet was not sent, so no \r
385 additional status information is available.\r
386 EFI_UNSUPPORTED - The command described by the SCSI Request Packet\r
387 is not supported by the SCSI initiator(i.e., SCSI \r
388 Host Controller). The SCSI Request Packet was not\r
389 sent, so no additional status information is \r
390 available.\r
391 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI \r
392 Request Packet to execute. See HostAdapterStatus,\r
393 TargetStatus, SenseDataLength, and SenseData in \r
394 that order for additional status information.\r
3a10d471 395\r
396--*/\r
397;\r
398\r
399EFI_STATUS\r
400ScsiScanCreateDevice (\r
401 EFI_DRIVER_BINDING_PROTOCOL *This,\r
402 EFI_HANDLE Controller,\r
70c94b3b 403 SCSI_TARGET_ID *TargetId,\r
3a10d471 404 UINT64 Lun,\r
70c94b3b 405 SCSI_BUS_DEVICE *ScsiBusDev\r
3a10d471 406 )\r
407/*++\r
408\r
409Routine Description:\r
410\r
70c94b3b 411 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.\r
3a10d471 412\r
413Arguments:\r
414\r
70c94b3b 415 This - Protocol instance pointer\r
416 Controller - Controller handle\r
417 Pun - The Pun of the SCSI device on the SCSI channel.\r
418 Lun - The Lun of the SCSI device on the SCSI channel.\r
419 ScsiBusDev - The pointer of SCSI_BUS_DEVICE\r
3a10d471 420\r
421Returns:\r
422\r
70c94b3b 423 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.\r
424 EFI_OUT_OF_RESOURCES - Fail to discover the device.\r
3a10d471 425\r
426--*/\r
427;\r
428\r
429BOOLEAN\r
430DiscoverScsiDevice (\r
431 SCSI_IO_DEV *ScsiIoDevice\r
432 )\r
433/*++\r
434\r
435Routine Description:\r
436\r
f36d6e66 437 Discovery SCSI Device\r
3a10d471 438\r
439Arguments:\r
440\r
f36d6e66 441 ScsiIoDevice - The pointer of SCSI_IO_DEV\r
3a10d471 442\r
443Returns:\r
444\r
f36d6e66 445 TRUE - Find SCSI Device and verify it.\r
446 FALSE - Unable to find SCSI Device. \r
3a10d471 447\r
448--*/\r
449;\r
450#endif\r