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