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