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