]>
Commit | Line | Data |
---|---|---|
aca84419 | 1 | /** @file |
2 | Header file for ATA/ATAPI PASS THRU driver. | |
3 | ||
490b5ea1 | 4 | Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> |
aca84419 | 5 | 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 | #ifndef __ATA_ATAPI_PASS_THRU_H__ | |
15 | #define __ATA_ATAPI_PASS_THRU_H__ | |
16 | ||
17 | #include <Uefi.h> | |
18 | ||
19 | #include <IndustryStandard/Pci.h> | |
20 | #include <IndustryStandard/Atapi.h> | |
21 | #include <IndustryStandard/Scsi.h> | |
22 | ||
23 | #include <Protocol/PciIo.h> | |
24 | #include <Protocol/IdeControllerInit.h> | |
25 | #include <Protocol/AtaPassThru.h> | |
26 | #include <Protocol/ScsiPassThruExt.h> | |
27 | ||
28 | #include <Library/DebugLib.h> | |
29 | #include <Library/BaseLib.h> | |
30 | #include <Library/BaseMemoryLib.h> | |
31 | #include <Library/UefiDriverEntryPoint.h> | |
32 | #include <Library/UefiBootServicesTableLib.h> | |
33 | #include <Library/UefiLib.h> | |
34 | #include <Library/PciLib.h> | |
35 | #include <Library/PcdLib.h> | |
36 | #include <Library/TimerLib.h> | |
37 | #include <Library/MemoryAllocationLib.h> | |
38 | #include <Library/ReportStatusCodeLib.h> | |
39 | #include <Library/DevicePathLib.h> | |
40 | ||
41 | #include "IdeMode.h" | |
42 | #include "AhciMode.h" | |
43 | ||
44 | extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding; | |
45 | extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName; | |
46 | extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2; | |
47 | ||
48 | #define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't') | |
49 | #define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v') | |
490b5ea1 | 50 | #define ATA_NONBLOCKING_TASK_SIGNATURE SIGNATURE_32 ('a', 't', 's', 'k') |
51 | ||
52 | typedef struct _ATA_NONBLOCK_TASK ATA_NONBLOCK_TASK; | |
aca84419 | 53 | |
54 | typedef enum { | |
55 | EfiAtaIdeMode, | |
56 | EfiAtaAhciMode, | |
57 | EfiAtaRaidMode, | |
58 | EfiAtaUnknownMode | |
59 | } EFI_ATA_HC_WORK_MODE; | |
60 | ||
61 | typedef enum { | |
62 | EfiIdeCdrom, /* ATAPI CDROM */ | |
63 | EfiIdeHarddisk, /* Hard Disk */ | |
64 | EfiPortMultiplier, /* Port Multiplier */ | |
65 | EfiIdeUnknown | |
66 | } EFI_ATA_DEVICE_TYPE; | |
67 | ||
68 | // | |
69 | // Ahci mode device info | |
70 | // | |
71 | typedef struct { | |
72 | UINT32 Signature; | |
73 | LIST_ENTRY Link; | |
74 | ||
75 | UINT16 Port; | |
76 | UINT16 PortMultiplier; | |
77 | EFI_ATA_DEVICE_TYPE Type; | |
78 | ||
79 | EFI_IDENTIFY_DATA *IdentifyData; | |
80 | } EFI_ATA_DEVICE_INFO; | |
81 | ||
82 | typedef struct { | |
83 | UINT32 Signature; | |
84 | ||
85 | EFI_HANDLE ControllerHandle; | |
86 | EFI_PCI_IO_PROTOCOL *PciIo; | |
87 | EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit; | |
88 | ||
89 | EFI_ATA_PASS_THRU_MODE AtaPassThruMode; | |
90 | EFI_ATA_PASS_THRU_PROTOCOL AtaPassThru; | |
91 | EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode; | |
92 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru; | |
93 | ||
94 | EFI_ATA_HC_WORK_MODE Mode; | |
95 | ||
96 | EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel]; | |
97 | EFI_AHCI_REGISTERS AhciRegisters; | |
98 | ||
99 | // | |
100 | // The attached device list | |
101 | // | |
102 | LIST_ENTRY DeviceList; | |
103 | UINT64 OriginalPciAttributes; | |
104 | \r | |
105 | // | |
106 | // For AtaPassThru protocol, using the following bytes to record the previous call in | |
107 | // GetNextPort()/GetNextDevice(). | |
108 | // | |
109 | UINT16 PreviousPort; | |
110 | UINT16 PreviousPortMultiplier; | |
111 | // | |
112 | // For ExtScsiPassThru protocol, using the following bytes to record the previous call in | |
113 | // GetNextTarget()/GetNextTargetLun(). | |
114 | // | |
115 | UINT16 PreviousTargetId; | |
116 | UINT64 PreviousLun; | |
490b5ea1 | 117 | |
118 | // | |
119 | // For Non-blocking. | |
120 | // | |
121 | EFI_EVENT TimerEvent; | |
122 | LIST_ENTRY NonBlockingTaskList; | |
aca84419 | 123 | } ATA_ATAPI_PASS_THRU_INSTANCE; |
124 | ||
490b5ea1 | 125 | // |
126 | // Task for Non-blocking mode. | |
127 | // | |
128 | struct _ATA_NONBLOCK_TASK { | |
129 | UINT32 Signature; | |
130 | LIST_ENTRY Link; | |
131 | ||
132 | UINT16 Port; | |
133 | UINT16 PortMultiplier; | |
134 | EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet; | |
135 | BOOLEAN IsStart; | |
136 | EFI_EVENT Event; | |
137 | UINT64 RetryTimes; | |
138 | VOID *Map; // Pointer to map. | |
139 | VOID *TableMap;// Pointer to PRD table map. | |
140 | EFI_ATA_DMA_PRD *MapBaseAddress; // Pointer to range Base address for Map. | |
141 | UINTN PageCount; // The page numbers used by PCIO freebuffer. | |
142 | }; | |
143 | ||
aca84419 | 144 | // |
145 | // Timeout value which uses 100ns as a unit. | |
146 | // It means 3 second span. | |
147 | // | |
148 | #define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3) | |
149 | ||
150 | #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0) | |
151 | ||
152 | #define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ | |
153 | CR (a, \ | |
154 | ATA_ATAPI_PASS_THRU_INSTANCE, \ | |
155 | AtaPassThru, \ | |
156 | ATA_ATAPI_PASS_THRU_SIGNATURE \ | |
157 | ) | |
158 | ||
159 | #define EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \ | |
160 | CR (a, \ | |
161 | ATA_ATAPI_PASS_THRU_INSTANCE, \ | |
162 | ExtScsiPassThru, \ | |
163 | ATA_ATAPI_PASS_THRU_SIGNATURE \ | |
164 | ) | |
165 | ||
166 | #define ATA_ATAPI_DEVICE_INFO_FROM_THIS(a) \ | |
167 | CR (a, \ | |
168 | EFI_ATA_DEVICE_INFO, \ | |
169 | Link, \ | |
170 | ATA_ATAPI_DEVICE_SIGNATURE \ | |
171 | ); | |
490b5ea1 | 172 | |
173 | #define ATA_NON_BLOCK_TASK_FROM_ENTRY(a) \ | |
174 | CR (a, \ | |
175 | ATA_NONBLOCK_TASK, \ | |
176 | Link, \ | |
177 | ATA_NONBLOCKING_TASK_SIGNATURE \ | |
178 | ); | |
179 | ||
aca84419 | 180 | /** |
181 | Retrieves a Unicode string that is the user readable name of the driver. | |
182 | ||
183 | This function retrieves the user readable name of a driver in the form of a | |
184 | Unicode string. If the driver specified by This has a user readable name in | |
185 | the language specified by Language, then a pointer to the driver name is | |
186 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified | |
187 | by This does not support the language specified by Language, | |
188 | then EFI_UNSUPPORTED is returned. | |
189 | ||
190 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or | |
191 | EFI_COMPONENT_NAME_PROTOCOL instance. | |
192 | ||
193 | @param Language[in] A pointer to a Null-terminated ASCII string | |
194 | array indicating the language. This is the | |
195 | language of the driver name that the caller is | |
196 | requesting, and it must match one of the | |
197 | languages specified in SupportedLanguages. The | |
198 | number of languages supported by a driver is up | |
199 | to the driver writer. Language is specified | |
200 | in RFC 4646 or ISO 639-2 language code format. | |
201 | ||
202 | @param DriverName[out] A pointer to the Unicode string to return. | |
203 | This Unicode string is the name of the | |
204 | driver specified by This in the language | |
205 | specified by Language. | |
206 | ||
207 | @retval EFI_SUCCESS The Unicode string for the Driver specified by | |
208 | This and the language specified by Language was | |
209 | returned in DriverName. | |
210 | ||
211 | @retval EFI_INVALID_PARAMETER Language is NULL. | |
212 | ||
213 | @retval EFI_INVALID_PARAMETER DriverName is NULL. | |
214 | ||
215 | @retval EFI_UNSUPPORTED The driver specified by This does not support | |
216 | the language specified by Language. | |
217 | ||
218 | **/ | |
219 | EFI_STATUS | |
220 | EFIAPI | |
221 | AtaAtapiPassThruComponentNameGetDriverName ( | |
222 | IN EFI_COMPONENT_NAME_PROTOCOL *This, | |
223 | IN CHAR8 *Language, | |
224 | OUT CHAR16 **DriverName | |
225 | ); | |
226 | ||
227 | /** | |
228 | Retrieves a Unicode string that is the user readable name of the controller | |
229 | that is being managed by a driver. | |
230 | ||
231 | This function retrieves the user readable name of the controller specified by | |
232 | ControllerHandle and ChildHandle in the form of a Unicode string. If the | |
233 | driver specified by This has a user readable name in the language specified by | |
234 | Language, then a pointer to the controller name is returned in ControllerName, | |
235 | and EFI_SUCCESS is returned. If the driver specified by This is not currently | |
236 | managing the controller specified by ControllerHandle and ChildHandle, | |
237 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not | |
238 | support the language specified by Language, then EFI_UNSUPPORTED is returned. | |
239 | ||
240 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or | |
241 | EFI_COMPONENT_NAME_PROTOCOL instance. | |
242 | ||
243 | @param ControllerHandle[in] The handle of a controller that the driver | |
244 | specified by This is managing. This handle | |
245 | specifies the controller whose name is to be | |
246 | returned. | |
247 | ||
248 | @param ChildHandle[in] The handle of the child controller to retrieve | |
249 | the name of. This is an optional parameter that | |
250 | may be NULL. It will be NULL for device | |
251 | drivers. It will also be NULL for a bus drivers | |
252 | that wish to retrieve the name of the bus | |
253 | controller. It will not be NULL for a bus | |
254 | driver that wishes to retrieve the name of a | |
255 | child controller. | |
256 | ||
257 | @param Language[in] A pointer to a Null-terminated ASCII string | |
258 | array indicating the language. This is the | |
259 | language of the driver name that the caller is | |
260 | requesting, and it must match one of the | |
261 | languages specified in SupportedLanguages. The | |
262 | number of languages supported by a driver is up | |
263 | to the driver writer. Language is specified in | |
264 | RFC 4646 or ISO 639-2 language code format. | |
265 | ||
266 | @param ControllerName[out] A pointer to the Unicode string to return. | |
267 | This Unicode string is the name of the | |
268 | controller specified by ControllerHandle and | |
269 | ChildHandle in the language specified by | |
270 | Language from the point of view of the driver | |
271 | specified by This. | |
272 | ||
273 | @retval EFI_SUCCESS The Unicode string for the user readable name in | |
274 | the language specified by Language for the | |
275 | driver specified by This was returned in | |
276 | DriverName. | |
277 | ||
278 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. | |
279 | ||
280 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid | |
281 | EFI_HANDLE. | |
282 | ||
283 | @retval EFI_INVALID_PARAMETER Language is NULL. | |
284 | ||
285 | @retval EFI_INVALID_PARAMETER ControllerName is NULL. | |
286 | ||
287 | @retval EFI_UNSUPPORTED The driver specified by This is not currently | |
288 | managing the controller specified by | |
289 | ControllerHandle and ChildHandle. | |
290 | ||
291 | @retval EFI_UNSUPPORTED The driver specified by This does not support | |
292 | the language specified by Language. | |
293 | ||
294 | **/ | |
295 | EFI_STATUS | |
296 | EFIAPI | |
297 | AtaAtapiPassThruComponentNameGetControllerName ( | |
298 | IN EFI_COMPONENT_NAME_PROTOCOL *This, | |
299 | IN EFI_HANDLE ControllerHandle, | |
300 | IN EFI_HANDLE ChildHandle OPTIONAL, | |
301 | IN CHAR8 *Language, | |
302 | OUT CHAR16 **ControllerName | |
303 | ); | |
304 | ||
305 | /** | |
306 | Tests to see if this driver supports a given controller. If a child device is provided, | |
307 | it further tests to see if this driver supports creating a handle for the specified child device. | |
308 | ||
309 | This function checks to see if the driver specified by This supports the device specified by | |
310 | ControllerHandle. Drivers will typically use the device path attached to | |
311 | ControllerHandle and/or the services from the bus I/O abstraction attached to | |
312 | ControllerHandle to determine if the driver supports ControllerHandle. This function | |
313 | may be called many times during platform initialization. In order to reduce boot times, the tests | |
314 | performed by this function must be very small, and take as little time as possible to execute. This | |
315 | function must not change the state of any hardware devices, and this function must be aware that the | |
316 | device specified by ControllerHandle may already be managed by the same driver or a | |
317 | different driver. This function must match its calls to AllocatePages() with FreePages(), | |
318 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). | |
319 | Because ControllerHandle may have been previously started by the same driver, if a protocol is | |
320 | already in the opened state, then it must not be closed with CloseProtocol(). This is required | |
321 | to guarantee the state of ControllerHandle is not modified by this function. | |
322 | ||
323 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. | |
324 | @param[in] ControllerHandle The handle of the controller to test. This handle | |
325 | must support a protocol interface that supplies | |
326 | an I/O abstraction to the driver. | |
327 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This | |
328 | parameter is ignored by device drivers, and is optional for bus | |
329 | drivers. For bus drivers, if this parameter is not NULL, then | |
330 | the bus driver must determine if the bus controller specified | |
331 | by ControllerHandle and the child controller specified | |
332 | by RemainingDevicePath are both supported by this | |
333 | bus driver. | |
334 | ||
335 | @retval EFI_SUCCESS The device specified by ControllerHandle and | |
336 | RemainingDevicePath is supported by the driver specified by This. | |
337 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and | |
338 | RemainingDevicePath is already being managed by the driver | |
339 | specified by This. | |
340 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and | |
341 | RemainingDevicePath is already being managed by a different | |
342 | driver or an application that requires exclusive access. | |
343 | Currently not implemented. | |
344 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and | |
345 | RemainingDevicePath is not supported by the driver specified by This. | |
346 | **/ | |
347 | EFI_STATUS | |
348 | EFIAPI | |
349 | AtaAtapiPassThruSupported ( | |
350 | IN EFI_DRIVER_BINDING_PROTOCOL *This, | |
351 | IN EFI_HANDLE Controller, | |
352 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath | |
353 | ); | |
354 | ||
355 | /** | |
356 | Starts a device controller or a bus controller. | |
357 | ||
358 | The Start() function is designed to be invoked from the EFI boot service ConnectController(). | |
359 | As a result, much of the error checking on the parameters to Start() has been moved into this | |
360 | common boot service. It is legal to call Start() from other locations, | |
361 | but the following calling restrictions must be followed, or the system behavior will not be deterministic. | |
362 | 1. ControllerHandle must be a valid EFI_HANDLE. | |
363 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned | |
364 | EFI_DEVICE_PATH_PROTOCOL. | |
365 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must | |
366 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. | |
367 | ||
368 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. | |
369 | @param[in] ControllerHandle The handle of the controller to start. This handle | |
370 | must support a protocol interface that supplies | |
371 | an I/O abstraction to the driver. | |
372 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This | |
373 | parameter is ignored by device drivers, and is optional for bus | |
374 | drivers. For a bus driver, if this parameter is NULL, then handles | |
375 | for all the children of Controller are created by this driver. | |
376 | If this parameter is not NULL and the first Device Path Node is | |
377 | not the End of Device Path Node, then only the handle for the | |
378 | child device specified by the first Device Path Node of | |
379 | RemainingDevicePath is created by this driver. | |
380 | If the first Device Path Node of RemainingDevicePath is | |
381 | the End of Device Path Node, no child handle is created by this | |
382 | driver. | |
383 | ||
384 | @retval EFI_SUCCESS The device was started. | |
385 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. | |
386 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. | |
387 | @retval Others The driver failded to start the device. | |
388 | ||
389 | **/ | |
390 | EFI_STATUS | |
391 | EFIAPI | |
392 | AtaAtapiPassThruStart ( | |
393 | IN EFI_DRIVER_BINDING_PROTOCOL *This, | |
394 | IN EFI_HANDLE Controller, | |
395 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath | |
396 | ); | |
397 | ||
398 | /** | |
399 | Stops a device controller or a bus controller. | |
400 | ||
401 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). | |
402 | As a result, much of the error checking on the parameters to Stop() has been moved | |
403 | into this common boot service. It is legal to call Stop() from other locations, | |
404 | but the following calling restrictions must be followed, or the system behavior will not be deterministic. | |
405 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this | |
406 | same driver's Start() function. | |
407 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid | |
408 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's | |
409 | Start() function, and the Start() function must have called OpenProtocol() on | |
410 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. | |
411 | ||
412 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. | |
413 | @param[in] ControllerHandle A handle to the device being stopped. The handle must | |
414 | support a bus specific I/O protocol for the driver | |
415 | to use to stop the device. | |
416 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. | |
417 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL | |
418 | if NumberOfChildren is 0. | |
419 | ||
420 | @retval EFI_SUCCESS The device was stopped. | |
421 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. | |
422 | ||
423 | **/ | |
424 | EFI_STATUS | |
425 | EFIAPI | |
426 | AtaAtapiPassThruStop ( | |
427 | IN EFI_DRIVER_BINDING_PROTOCOL *This, | |
428 | IN EFI_HANDLE Controller, | |
429 | IN UINTN NumberOfChildren, | |
430 | IN EFI_HANDLE *ChildHandleBuffer | |
431 | ); | |
432 | ||
433 | /** | |
434 | Traverse the attached ATA devices list to find out the device to access. | |
435 | ||
436 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
437 | @param[in] Port The port number of the ATA device to send the command. | |
438 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command. | |
439 | If there is no port multiplier, then specify 0. | |
440 | @param[in] DeviceType The device type of the ATA device. | |
441 | ||
442 | @retval The pointer to the data structure of the device info to access. | |
443 | ||
444 | **/ | |
445 | LIST_ENTRY * | |
446 | EFIAPI | |
447 | SearchDeviceInfoList ( | |
448 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, | |
449 | IN UINT16 Port, | |
450 | IN UINT16 PortMultiplier, | |
451 | IN EFI_ATA_DEVICE_TYPE DeviceType | |
452 | ); | |
453 | ||
454 | /** | |
455 | Allocate device info data structure to contain device info. | |
456 | And insert the data structure to the tail of device list for tracing. | |
457 | ||
458 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
459 | @param[in] Port The port number of the ATA device to send the command. | |
460 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command. | |
461 | If there is no port multiplier, then specify 0. | |
462 | @param[in] DeviceType The device type of the ATA device. | |
463 | @param[in] IdentifyData The data buffer to store the output of the IDENTIFY cmd. | |
464 | ||
465 | @retval EFI_SUCCESS Successfully insert the ata device to the tail of device list. | |
466 | @retval EFI_OUT_OF_RESOURCES Can not allocate enough resource for use. | |
467 | ||
468 | **/ | |
469 | EFI_STATUS | |
470 | EFIAPI | |
471 | CreateNewDeviceInfo ( | |
472 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, | |
473 | IN UINT16 Port, | |
474 | IN UINT16 PortMultiplier, | |
475 | IN EFI_ATA_DEVICE_TYPE DeviceType, | |
476 | IN EFI_IDENTIFY_DATA *IdentifyData | |
477 | ); | |
478 | ||
479 | /** | |
480 | Destroy all attached ATA devices info. | |
481 | ||
482 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
483 | ||
484 | **/ | |
485 | VOID | |
486 | EFIAPI | |
487 | DestroyDeviceInfoList ( | |
488 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance | |
489 | ); | |
490 | ||
490b5ea1 | 491 | /** |
492 | Destroy all pending non blocking tasks. | |
493 | ||
494 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
495 | ||
496 | **/ | |
497 | VOID | |
498 | EFIAPI | |
499 | DestroyAsynTaskList ( | |
500 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance | |
501 | ); | |
502 | ||
aca84419 | 503 | /** |
504 | Enumerate all attached ATA devices at IDE mode or AHCI mode separately. | |
505 | ||
506 | The function is designed to enumerate all attached ATA devices. | |
507 | ||
508 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
509 | ||
510 | @retval EFI_SUCCESS Successfully enumerate attached ATA devices. | |
511 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. | |
512 | ||
513 | **/ | |
514 | EFI_STATUS | |
515 | EFIAPI | |
516 | EnumerateAttachedDevice ( | |
517 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance | |
518 | ); | |
519 | ||
490b5ea1 | 520 | /** |
521 | Call back funtion when the timer event is signaled. | |
522 | ||
523 | @param[in] Event The Event this notify function registered to. | |
524 | @param[in] Context Pointer to the context data registered to the | |
525 | Event. | |
526 | ||
527 | **/ | |
528 | VOID | |
529 | EFIAPI | |
530 | AsyncNonBlockingTransferRoutine ( | |
531 | EFI_EVENT Event, | |
532 | VOID* Context | |
533 | ); | |
534 | ||
aca84419 | 535 | /** |
536 | Sends an ATA command to an ATA device that is attached to the ATA controller. This function | |
537 | supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, | |
538 | and the non-blocking I/O functionality is optional. | |
539 | ||
540 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
541 | @param[in] Port The port number of the ATA device to send the command. | |
542 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command. | |
543 | If there is no port multiplier, then specify 0. | |
544 | @param[in, out] Packet A pointer to the ATA command to send to the ATA device specified by Port | |
545 | and PortMultiplierPort. | |
546 | @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking | |
547 | I/O is performed. If Event is NULL, then blocking I/O is performed. If | |
548 | Event is not NULL and non blocking I/O is supported, then non-blocking | |
549 | I/O is performed, and Event will be signaled when the ATA command completes. | |
550 | ||
551 | @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands, | |
552 | InTransferLength bytes were transferred from InDataBuffer. For write and | |
553 | bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer. | |
554 | @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred | |
555 | is returned in InTransferLength. For write and bi-directional commands, | |
556 | OutTransferLength bytes were transferred by OutDataBuffer. | |
557 | @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands | |
558 | already queued. The caller may retry again later. | |
559 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command. | |
560 | @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA | |
561 | command was not sent, so no additional status information is available. | |
562 | ||
563 | **/ | |
564 | EFI_STATUS | |
565 | EFIAPI | |
566 | AtaPassThruPassThru ( | |
567 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
568 | IN UINT16 Port, | |
569 | IN UINT16 PortMultiplierPort, | |
570 | IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet, | |
571 | IN EFI_EVENT Event OPTIONAL | |
572 | ); | |
573 | ||
574 | /** | |
575 | Used to retrieve the list of legal port numbers for ATA devices on an ATA controller. | |
576 | These can either be the list of ports where ATA devices are actually present or the | |
577 | list of legal port numbers for the ATA controller. Regardless, the caller of this | |
578 | function must probe the port number returned to see if an ATA device is actually | |
579 | present at that location on the ATA controller. | |
580 | ||
581 | The GetNextPort() function retrieves the port number on an ATA controller. If on input | |
582 | Port is 0xFFFF, then the port number of the first port on the ATA controller is returned | |
583 | in Port and EFI_SUCCESS is returned. | |
584 | ||
585 | If Port is a port number that was returned on a previous call to GetNextPort(), then the | |
586 | port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS | |
587 | is returned. If Port is not 0xFFFF and Port was not returned on a previous call to | |
588 | GetNextPort(), then EFI_INVALID_PARAMETER is returned. | |
589 | ||
590 | If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is | |
591 | returned. | |
592 | ||
593 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
594 | @param[in, out] Port On input, a pointer to the port number on the ATA controller. | |
595 | On output, a pointer to the next port number on the ATA | |
596 | controller. An input value of 0xFFFF retrieves the first port | |
597 | number on the ATA controller. | |
598 | ||
599 | @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port. | |
600 | @retval EFI_NOT_FOUND There are no more ports on this ATA controller. | |
601 | @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call | |
602 | to GetNextPort(). | |
603 | ||
604 | **/ | |
605 | EFI_STATUS | |
606 | EFIAPI | |
607 | AtaPassThruGetNextPort ( | |
608 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
609 | IN OUT UINT16 *Port | |
610 | ); | |
611 | ||
612 | /** | |
613 | Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA | |
614 | controller. These can either be the list of port multiplier ports where ATA devices are actually | |
615 | present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this | |
616 | function must probe the port number and port multiplier port number returned to see if an ATA | |
617 | device is actually present. | |
618 | ||
619 | The GetNextDevice() function retrieves the port multiplier port number of an ATA device | |
620 | present on a port of an ATA controller. | |
490b5ea1 | 621 | |
aca84419 | 622 | If PortMultiplierPort points to a port multiplier port number value that was returned on a |
623 | previous call to GetNextDevice(), then the port multiplier port number of the next ATA device | |
624 | on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is | |
625 | returned. | |
490b5ea1 | 626 | |
aca84419 | 627 | If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first |
628 | ATA device on port of the ATA controller is returned in PortMultiplierPort and | |
629 | EFI_SUCCESS is returned. | |
490b5ea1 | 630 | |
aca84419 | 631 | If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort |
632 | was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER | |
633 | is returned. | |
634 | ||
635 | If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of | |
636 | the ATA controller, then EFI_NOT_FOUND is returned. | |
637 | ||
638 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
639 | @param[in] Port The port number present on the ATA controller. | |
640 | @param[in, out] PortMultiplierPort On input, a pointer to the port multiplier port number of an | |
641 | ATA device present on the ATA controller. | |
642 | If on input a PortMultiplierPort of 0xFFFF is specified, | |
643 | then the port multiplier port number of the first ATA device | |
644 | is returned. On output, a pointer to the port multiplier port | |
645 | number of the next ATA device present on an ATA controller. | |
646 | ||
647 | @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port | |
648 | of the ATA controller was returned in PortMultiplierPort. | |
649 | @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller. | |
650 | @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not | |
651 | returned on a previous call to GetNextDevice(). | |
652 | ||
653 | **/ | |
654 | EFI_STATUS | |
655 | EFIAPI | |
656 | AtaPassThruGetNextDevice ( | |
657 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
658 | IN UINT16 Port, | |
659 | IN OUT UINT16 *PortMultiplierPort | |
660 | ); | |
661 | ||
662 | /** | |
663 | Used to allocate and build a device path node for an ATA device on an ATA controller. | |
664 | ||
665 | The BuildDevicePath() function allocates and builds a single device node for the ATA | |
666 | device specified by Port and PortMultiplierPort. If the ATA device specified by Port and | |
667 | PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned. | |
668 | If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough | |
669 | resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned. | |
670 | ||
671 | Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of | |
672 | DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort, | |
673 | and EFI_SUCCESS is returned. | |
674 | ||
675 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
676 | @param[in] Port Port specifies the port number of the ATA device for which a | |
677 | device path node is to be allocated and built. | |
678 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a | |
679 | device path node is to be allocated and built. If there is no | |
680 | port multiplier, then specify 0. | |
681 | @param[in, out] DevicePath A pointer to a single device path node that describes the ATA | |
682 | device specified by Port and PortMultiplierPort. This function | |
683 | is responsible for allocating the buffer DevicePath with the | |
684 | boot service AllocatePool(). It is the caller's responsibility | |
685 | to free DevicePath when the caller is finished with DevicePath. | |
686 | @retval EFI_SUCCESS The device path node that describes the ATA device specified by | |
687 | Port and PortMultiplierPort was allocated and returned in DevicePath. | |
688 | @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not | |
689 | exist on the ATA controller. | |
690 | @retval EFI_INVALID_PARAMETER DevicePath is NULL. | |
691 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath. | |
692 | ||
693 | **/ | |
694 | EFI_STATUS | |
695 | EFIAPI | |
696 | AtaPassThruBuildDevicePath ( | |
697 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
698 | IN UINT16 Port, | |
699 | IN UINT16 PortMultiplierPort, | |
700 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath | |
701 | ); | |
702 | ||
703 | /** | |
704 | Used to translate a device path node to a port number and port multiplier port number. | |
705 | ||
706 | The GetDevice() function determines the port and port multiplier port number associated with | |
707 | the ATA device described by DevicePath. If DevicePath is a device path node type that the | |
708 | ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents | |
709 | DevicePath into a port number and port multiplier port number. | |
710 | ||
711 | If this translation is successful, then that port number and port multiplier port number are returned | |
712 | in Port and PortMultiplierPort, and EFI_SUCCESS is returned. | |
713 | ||
714 | If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned. | |
715 | ||
716 | If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then | |
717 | EFI_UNSUPPORTED is returned. | |
718 | ||
719 | If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not | |
720 | a valid translation from DevicePath to a port number and port multiplier port number, then | |
721 | EFI_NOT_FOUND is returned. | |
722 | ||
723 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
724 | @param[in] DevicePath A pointer to the device path node that describes an ATA device on the | |
725 | ATA controller. | |
726 | @param[out] Port On return, points to the port number of an ATA device on the ATA controller. | |
727 | @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device | |
728 | on the ATA controller. | |
729 | ||
730 | @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier | |
731 | port number, and they were returned in Port and PortMultiplierPort. | |
732 | @retval EFI_INVALID_PARAMETER DevicePath is NULL. | |
733 | @retval EFI_INVALID_PARAMETER Port is NULL. | |
734 | @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL. | |
735 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath. | |
736 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier | |
737 | port number does not exist. | |
490b5ea1 | 738 | |
aca84419 | 739 | **/ |
740 | EFI_STATUS | |
741 | EFIAPI | |
742 | AtaPassThruGetDevice ( | |
743 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
744 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, | |
745 | OUT UINT16 *Port, | |
746 | OUT UINT16 *PortMultiplierPort | |
747 | ); | |
748 | ||
749 | /** | |
750 | Resets a specific port on the ATA controller. This operation also resets all the ATA devices | |
751 | connected to the port. | |
752 | ||
753 | The ResetChannel() function resets an a specific port on an ATA controller. This operation | |
754 | resets all the ATA devices connected to that port. If this ATA controller does not support | |
755 | a reset port operation, then EFI_UNSUPPORTED is returned. | |
756 | ||
757 | If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is | |
758 | returned. | |
759 | ||
760 | If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned. | |
761 | ||
762 | If the port reset operation is completed, then EFI_SUCCESS is returned. | |
763 | ||
764 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
765 | @param[in] Port The port number on the ATA controller. | |
766 | ||
767 | @retval EFI_SUCCESS The ATA controller port was reset. | |
768 | @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation. | |
769 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port. | |
770 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port. | |
771 | ||
772 | **/ | |
773 | EFI_STATUS | |
774 | EFIAPI | |
775 | AtaPassThruResetPort ( | |
776 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
777 | IN UINT16 Port | |
778 | ); | |
779 | ||
780 | /** | |
781 | Resets an ATA device that is connected to an ATA controller. | |
782 | ||
783 | The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort. | |
784 | If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is | |
785 | returned. | |
786 | ||
787 | If Port or PortMultiplierPort are not in a valid range for this ATA controller, then | |
788 | EFI_INVALID_PARAMETER is returned. | |
789 | ||
790 | If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR | |
791 | is returned. | |
792 | ||
793 | If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is | |
794 | returned. | |
795 | ||
796 | If the device reset operation is completed, then EFI_SUCCESS is returned. | |
797 | ||
798 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. | |
799 | @param[in] Port Port represents the port number of the ATA device to be reset. | |
800 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset. | |
801 | If there is no port multiplier, then specify 0. | |
802 | @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset. | |
803 | @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation. | |
804 | @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid. | |
805 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device | |
806 | specified by Port and PortMultiplierPort. | |
807 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device | |
808 | specified by Port and PortMultiplierPort. | |
809 | ||
810 | **/ | |
811 | EFI_STATUS | |
812 | EFIAPI | |
813 | AtaPassThruResetDevice ( | |
814 | IN EFI_ATA_PASS_THRU_PROTOCOL *This, | |
815 | IN UINT16 Port, | |
816 | IN UINT16 PortMultiplierPort | |
817 | ); | |
818 | ||
819 | /** | |
820 | Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function | |
821 | supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the | |
822 | nonblocking I/O functionality is optional. | |
823 | ||
824 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
825 | @param Target The Target is an array of size TARGET_MAX_BYTES and it represents | |
826 | the id of the SCSI device to send the SCSI Request Packet. Each | |
827 | transport driver may choose to utilize a subset of this size to suit the needs | |
828 | of transport target representation. For example, a Fibre Channel driver | |
829 | may use only 8 bytes (WWN) to represent an FC target. | |
830 | @param Lun The LUN of the SCSI device to send the SCSI Request Packet. | |
831 | @param Packet A pointer to the SCSI Request Packet to send to the SCSI device | |
832 | specified by Target and Lun. | |
833 | @param Event If nonblocking I/O is not supported then Event is ignored, and blocking | |
834 | I/O is performed. If Event is NULL, then blocking I/O is performed. If | |
835 | Event is not NULL and non blocking I/O is supported, then | |
836 | nonblocking I/O is performed, and Event will be signaled when the | |
837 | SCSI Request Packet completes. | |
838 | ||
839 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional | |
840 | commands, InTransferLength bytes were transferred from | |
841 | InDataBuffer. For write and bi-directional commands, | |
842 | OutTransferLength bytes were transferred by | |
843 | OutDataBuffer. | |
844 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that | |
845 | could be transferred is returned in InTransferLength. For write | |
846 | and bi-directional commands, OutTransferLength bytes were | |
847 | transferred by OutDataBuffer. | |
848 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many | |
849 | SCSI Request Packets already queued. The caller may retry again later. | |
850 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request | |
851 | Packet. | |
852 | @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid. | |
853 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported | |
854 | by the host adapter. This includes the case of Bi-directional SCSI | |
855 | commands not supported by the implementation. The SCSI Request | |
856 | Packet was not sent, so no additional status information is available. | |
857 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute. | |
858 | ||
859 | **/ | |
860 | EFI_STATUS | |
861 | EFIAPI | |
862 | ExtScsiPassThruPassThru ( | |
863 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
864 | IN UINT8 *Target, | |
865 | IN UINT64 Lun, | |
866 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, | |
867 | IN EFI_EVENT Event OPTIONAL | |
868 | ); | |
869 | ||
870 | /** | |
871 | Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These | |
872 | can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal | |
873 | Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the | |
874 | Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI | |
490b5ea1 | 875 | channel. |
aca84419 | 876 | |
877 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
878 | @param Target On input, a pointer to the Target ID (an array of size | |
879 | TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel. | |
880 | On output, a pointer to the Target ID (an array of | |
881 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI | |
882 | channel. An input value of 0xF(all bytes in the array are 0xF) in the | |
883 | Target array retrieves the Target ID of the first SCSI device present on a | |
884 | SCSI channel. | |
885 | @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI | |
886 | channel. On output, a pointer to the LUN of the next SCSI device present | |
887 | on a SCSI channel. | |
888 | ||
889 | @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI | |
890 | channel was returned in Target and Lun. | |
891 | @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were | |
892 | not returned on a previous call to GetNextTargetLun(). | |
893 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel. | |
894 | ||
895 | **/ | |
896 | EFI_STATUS | |
897 | EFIAPI | |
898 | ExtScsiPassThruGetNextTargetLun ( | |
899 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
900 | IN OUT UINT8 **Target, | |
901 | IN OUT UINT64 *Lun | |
902 | ); | |
903 | ||
904 | /** | |
905 | Used to allocate and build a device path node for a SCSI device on a SCSI channel. | |
906 | ||
907 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
908 | @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the | |
909 | Target ID of the SCSI device for which a device path node is to be | |
910 | allocated and built. Transport drivers may chose to utilize a subset of | |
911 | this size to suit the representation of targets. For example, a Fibre | |
912 | Channel driver may use only 8 bytes (WWN) in the array to represent a | |
913 | FC target. | |
914 | @param Lun The LUN of the SCSI device for which a device path node is to be | |
915 | allocated and built. | |
916 | @param DevicePath A pointer to a single device path node that describes the SCSI device | |
917 | specified by Target and Lun. This function is responsible for | |
918 | allocating the buffer DevicePath with the boot service | |
919 | AllocatePool(). It is the caller's responsibility to free | |
920 | DevicePath when the caller is finished with DevicePath. | |
921 | ||
922 | @retval EFI_SUCCESS The device path node that describes the SCSI device specified by | |
923 | Target and Lun was allocated and returned in | |
924 | DevicePath. | |
925 | @retval EFI_INVALID_PARAMETER DevicePath is NULL. | |
926 | @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist | |
927 | on the SCSI channel. | |
928 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath. | |
929 | ||
930 | **/ | |
931 | EFI_STATUS | |
932 | EFIAPI | |
933 | ExtScsiPassThruBuildDevicePath ( | |
934 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
935 | IN UINT8 *Target, | |
936 | IN UINT64 Lun, | |
937 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath | |
938 | ); | |
939 | ||
940 | /** | |
941 | Used to translate a device path node to a Target ID and LUN. | |
942 | ||
943 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
944 | @param DevicePath A pointer to a single device path node that describes the SCSI device | |
945 | on the SCSI channel. | |
946 | @param Target A pointer to the Target Array which represents the ID of a SCSI device | |
947 | on the SCSI channel. | |
948 | @param Lun A pointer to the LUN of a SCSI device on the SCSI channel. | |
949 | ||
950 | @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and | |
951 | LUN, and they were returned in Target and Lun. | |
952 | @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL. | |
953 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN | |
954 | does not exist. | |
955 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in | |
956 | DevicePath. | |
957 | ||
958 | **/ | |
959 | EFI_STATUS | |
960 | EFIAPI | |
961 | ExtScsiPassThruGetTargetLun ( | |
962 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
963 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, | |
964 | OUT UINT8 **Target, | |
965 | OUT UINT64 *Lun | |
966 | ); | |
967 | ||
968 | /** | |
969 | Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel. | |
970 | ||
971 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
972 | ||
973 | @retval EFI_SUCCESS The SCSI channel was reset. | |
974 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel. | |
975 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel. | |
976 | @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation. | |
977 | ||
978 | **/ | |
979 | EFI_STATUS | |
980 | EFIAPI | |
981 | ExtScsiPassThruResetChannel ( | |
982 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This | |
983 | ); | |
490b5ea1 | 984 | |
aca84419 | 985 | /** |
986 | Resets a SCSI logical unit that is connected to a SCSI channel. | |
987 | ||
988 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
989 | @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the | |
990 | target port ID of the SCSI device containing the SCSI logical unit to | |
991 | reset. Transport drivers may chose to utilize a subset of this array to suit | |
992 | the representation of their targets. | |
993 | @param Lun The LUN of the SCSI device to reset. | |
994 | ||
995 | @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset. | |
996 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL. | |
997 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device | |
998 | specified by Target and Lun. | |
999 | @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation. | |
1000 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device | |
1001 | specified by Target and Lun. | |
1002 | ||
1003 | **/ | |
1004 | EFI_STATUS | |
1005 | EFIAPI | |
1006 | ExtScsiPassThruResetTargetLun ( | |
1007 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
1008 | IN UINT8 *Target, | |
1009 | IN UINT64 Lun | |
1010 | ); | |
1011 | ||
1012 | /** | |
1013 | Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either | |
1014 | be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs | |
1015 | for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to | |
1016 | see if a SCSI device is actually present at that location on the SCSI channel. | |
1017 | ||
1018 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. | |
1019 | @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel. | |
1020 | On output, a pointer to the Target ID (an array of | |
1021 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI | |
1022 | channel. An input value of 0xF(all bytes in the array are 0xF) in the | |
1023 | Target array retrieves the Target ID of the first SCSI device present on a | |
1024 | SCSI channel. | |
1025 | ||
1026 | @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI | |
1027 | channel was returned in Target. | |
1028 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL. | |
1029 | @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not | |
1030 | returned on a previous call to GetNextTarget(). | |
1031 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel. | |
1032 | ||
1033 | **/ | |
1034 | EFI_STATUS | |
1035 | EFIAPI | |
1036 | ExtScsiPassThruGetNextTarget ( | |
1037 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, | |
1038 | IN OUT UINT8 **Target | |
1039 | ); | |
1040 | ||
1041 | /** | |
1042 | Initialize ATA host controller at IDE mode. | |
1043 | ||
1044 | The function is designed to initialize ATA host controller. | |
1045 | ||
1046 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
1047 | ||
1048 | **/ | |
1049 | EFI_STATUS | |
1050 | EFIAPI | |
1051 | IdeModeInitialization ( | |
1052 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance | |
1053 | ); | |
1054 | ||
1055 | /** | |
1056 | Initialize ATA host controller at AHCI mode. | |
1057 | ||
1058 | The function is designed to initialize ATA host controller. | |
1059 | ||
1060 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance. | |
1061 | ||
1062 | **/ | |
1063 | EFI_STATUS | |
1064 | EFIAPI | |
1065 | AhciModeInitialization ( | |
1066 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance | |
1067 | ); | |
1068 | ||
490b5ea1 | 1069 | /** |
1070 | Start a non data transfer on specific port. | |
1071 | ||
1072 | @param[in] PciIo The PCI IO protocol instance. | |
1073 | @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS. | |
1074 | @param[in] Port The number of port. | |
1075 | @param[in] PortMultiplier The timeout value of stop. | |
1076 | @param[in] AtapiCommand The atapi command will be used for the | |
1077 | transfer. | |
1078 | @param[in] AtapiCommandLength The length of the atapi command. | |
1079 | @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data. | |
1080 | @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data. | |
1081 | @param[in] Timeout The timeout value of non data transfer. | |
1082 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1083 | used by non-blocking mode. | |
1084 | ||
1085 | @retval EFI_DEVICE_ERROR The non data transfer abort with error occurs. | |
1086 | @retval EFI_TIMEOUT The operation is time out. | |
1087 | @retval EFI_UNSUPPORTED The device is not ready for transfer. | |
1088 | @retval EFI_SUCCESS The non data transfer executes successfully. | |
1089 | ||
1090 | **/ | |
1091 | EFI_STATUS | |
1092 | EFIAPI | |
1093 | AhciNonDataTransfer ( | |
1094 | IN EFI_PCI_IO_PROTOCOL *PciIo, | |
1095 | IN EFI_AHCI_REGISTERS *AhciRegisters, | |
1096 | IN UINT8 Port, | |
1097 | IN UINT8 PortMultiplier, | |
1098 | IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, | |
1099 | IN UINT8 AtapiCommandLength, | |
1100 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1101 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1102 | IN UINT64 Timeout, | |
1103 | IN ATA_NONBLOCK_TASK *Task | |
1104 | ); | |
1105 | ||
1106 | /** | |
1107 | Start a DMA data transfer on specific port | |
1108 | ||
1109 | @param[in] Instance The ATA_ATAPI_PASS_THRU_INSTANCE protocol instance. | |
1110 | @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS. | |
1111 | @param[in] Port The number of port. | |
1112 | @param[in] PortMultiplier The timeout value of stop. | |
1113 | @param[in] AtapiCommand The atapi command will be used for the | |
1114 | transfer. | |
1115 | @param[in] AtapiCommandLength The length of the atapi command. | |
1116 | @param[in] Read The transfer direction. | |
1117 | @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data. | |
1118 | @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data. | |
1119 | @param[in, out] MemoryAddr The pointer to the data buffer. | |
1120 | @param[in] DataCount The data count to be transferred. | |
1121 | @param[in] Timeout The timeout value of non data transfer. | |
1122 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1123 | used by non-blocking mode. | |
1124 | ||
1125 | @retval EFI_DEVICE_ERROR The DMA data transfer abort with error occurs. | |
1126 | @retval EFI_TIMEOUT The operation is time out. | |
1127 | @retval EFI_UNSUPPORTED The device is not ready for transfer. | |
1128 | @retval EFI_SUCCESS The DMA data transfer executes successfully. | |
1129 | ||
1130 | **/ | |
1131 | EFI_STATUS | |
1132 | EFIAPI | |
1133 | AhciDmaTransfer ( | |
1134 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, | |
1135 | IN EFI_AHCI_REGISTERS *AhciRegisters, | |
1136 | IN UINT8 Port, | |
1137 | IN UINT8 PortMultiplier, | |
1138 | IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, | |
1139 | IN UINT8 AtapiCommandLength, | |
1140 | IN BOOLEAN Read, | |
1141 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1142 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1143 | IN OUT VOID *MemoryAddr, | |
1144 | IN UINTN DataCount, | |
1145 | IN UINT64 Timeout, | |
1146 | IN ATA_NONBLOCK_TASK *Task | |
1147 | ); | |
1148 | ||
1149 | /** | |
1150 | Start a PIO data transfer on specific port. | |
1151 | ||
1152 | @param[in] PciIo The PCI IO protocol instance. | |
1153 | @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS. | |
1154 | @param[in] Port The number of port. | |
1155 | @param[in] PortMultiplier The timeout value of stop. | |
1156 | @param[in] AtapiCommand The atapi command will be used for the | |
1157 | transfer. | |
1158 | @param[in] AtapiCommandLength The length of the atapi command. | |
1159 | @param[in] Read The transfer direction. | |
1160 | @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data. | |
1161 | @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data. | |
1162 | @param[in, out] MemoryAddr The pointer to the data buffer. | |
1163 | @param[in] DataCount The data count to be transferred. | |
1164 | @param[in] Timeout The timeout value of non data transfer. | |
1165 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1166 | used by non-blocking mode. | |
1167 | ||
1168 | @retval EFI_DEVICE_ERROR The PIO data transfer abort with error occurs. | |
1169 | @retval EFI_TIMEOUT The operation is time out. | |
1170 | @retval EFI_UNSUPPORTED The device is not ready for transfer. | |
1171 | @retval EFI_SUCCESS The PIO data transfer executes successfully. | |
1172 | ||
1173 | **/ | |
1174 | EFI_STATUS | |
1175 | EFIAPI | |
1176 | AhciPioTransfer ( | |
1177 | IN EFI_PCI_IO_PROTOCOL *PciIo, | |
1178 | IN EFI_AHCI_REGISTERS *AhciRegisters, | |
1179 | IN UINT8 Port, | |
1180 | IN UINT8 PortMultiplier, | |
1181 | IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, | |
1182 | IN UINT8 AtapiCommandLength, | |
1183 | IN BOOLEAN Read, | |
1184 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1185 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1186 | IN OUT VOID *MemoryAddr, | |
1187 | IN UINT32 DataCount, | |
1188 | IN UINT64 Timeout, | |
1189 | IN ATA_NONBLOCK_TASK *Task | |
1190 | ); | |
1191 | ||
1192 | /** | |
1193 | Send ATA command into device with NON_DATA protocol | |
1194 | ||
1195 | @param[in] PciIo A pointer to ATA_ATAPI_PASS_THRU_INSTANCE | |
1196 | data structure. | |
1197 | @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure. | |
1198 | @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data | |
1199 | structure. | |
1200 | @param[in, out] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure. | |
1201 | @param[in] Timeout The time to complete the command. | |
1202 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1203 | used by non-blocking mode. | |
1204 | ||
1205 | @retval EFI_SUCCESS Reading succeed | |
1206 | @retval EFI_ABORTED Command failed | |
1207 | @retval EFI_DEVICE_ERROR Device status error. | |
1208 | ||
1209 | **/ | |
1210 | EFI_STATUS | |
1211 | EFIAPI | |
1212 | AtaNonDataCommandIn ( | |
1213 | IN EFI_PCI_IO_PROTOCOL *PciIo, | |
1214 | IN EFI_IDE_REGISTERS *IdeRegisters, | |
1215 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1216 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1217 | IN UINT64 Timeout, | |
1218 | IN ATA_NONBLOCK_TASK *Task | |
1219 | ); | |
1220 | ||
1221 | /** | |
1222 | Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt). | |
1223 | ||
1224 | @param[in] Instance A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data | |
1225 | structure. | |
1226 | @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure. | |
1227 | @param[in] Read Flag used to determine the data transfer | |
1228 | direction. Read equals 1, means data transferred | |
1229 | from device to host;Read equals 0, means data | |
1230 | transferred from host to device. | |
1231 | @param[in] DataBuffer A pointer to the source buffer for the data. | |
1232 | @param[in] DataLength The length of the data. | |
1233 | @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data structure. | |
1234 | @param[in, out] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure. | |
1235 | @param[in] Timeout The time to complete the command. | |
1236 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1237 | used by non-blocking mode. | |
1238 | ||
1239 | @retval EFI_SUCCESS the operation is successful. | |
1240 | @retval EFI_OUT_OF_RESOURCES Build PRD table failed | |
1241 | @retval EFI_UNSUPPORTED Unknown channel or operations command | |
1242 | @retval EFI_DEVICE_ERROR Ata command execute failed | |
1243 | ||
1244 | **/ | |
1245 | EFI_STATUS | |
1246 | EFIAPI | |
1247 | AtaUdmaInOut ( | |
1248 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, | |
1249 | IN EFI_IDE_REGISTERS *IdeRegisters, | |
1250 | IN BOOLEAN Read, | |
1251 | IN VOID *DataBuffer, | |
1252 | IN UINT64 DataLength, | |
1253 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1254 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1255 | IN UINT64 Timeout, | |
1256 | IN ATA_NONBLOCK_TASK *Task | |
1257 | ); | |
1258 | ||
1259 | /** | |
1260 | This function is used to send out ATA commands conforms to the PIO Data In Protocol. | |
1261 | ||
1262 | @param[in] PciIo A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data | |
1263 | structure. | |
1264 | @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure. | |
1265 | @param[in, out] Buffer A pointer to the source buffer for the data. | |
1266 | @param[in] ByteCount The length of the data. | |
1267 | @param[in] Read Flag used to determine the data transfer direction. | |
1268 | Read equals 1, means data transferred from device | |
1269 | to host;Read equals 0, means data transferred | |
1270 | from host to device. | |
1271 | @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data structure. | |
1272 | @param[in] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure. | |
1273 | @param[in] Timeout The time to complete the command. | |
1274 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK | |
1275 | used by non-blocking mode. | |
1276 | ||
1277 | @retval EFI_SUCCESS send out the ATA command and device send required data successfully. | |
1278 | @retval EFI_DEVICE_ERROR command sent failed. | |
1279 | ||
1280 | **/ | |
1281 | EFI_STATUS | |
1282 | EFIAPI | |
1283 | AtaPioDataInOut ( | |
1284 | IN EFI_PCI_IO_PROTOCOL *PciIo, | |
1285 | IN EFI_IDE_REGISTERS *IdeRegisters, | |
1286 | IN OUT VOID *Buffer, | |
1287 | IN UINT64 ByteCount, | |
1288 | IN BOOLEAN Read, | |
1289 | IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, | |
1290 | IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, | |
1291 | IN UINT64 Timeout, | |
1292 | IN ATA_NONBLOCK_TASK *Task | |
1293 | ); | |
1294 | ||
aca84419 | 1295 | #endif |
1296 |