25 ATA_ATAPI_PASS_THRU_SIGNATURE,
63 EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,
132UINT8 mScsiId[TARGET_MAX_BYTES] = {
133 0xFF, 0xFF, 0xFF, 0xFF,
134 0xFF, 0xFF, 0xFF, 0xFF,
135 0xFF, 0xFF, 0xFF, 0xFF,
136 0xFF, 0xFF, 0xFF, 0xFF
141 EDKII_ATA_ATAPI_POLICY_VERSION,
187 IN UINT16 PortMultiplierPort,
193 EFI_ATA_PASS_THRU_CMD_PROTOCOL Protocol;
194 EFI_ATA_HC_WORK_MODE Mode;
197 Protocol = Packet->Protocol;
199 Mode = Instance->Mode;
207 if (EFI_ERROR (Status)) {
212 case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
215 &Instance->IdeRegisters[Port],
222 case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:
225 &Instance->IdeRegisters[Port],
226 Packet->InDataBuffer,
227 Packet->InTransferLength,
235 case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:
238 &Instance->IdeRegisters[Port],
239 Packet->OutDataBuffer,
240 Packet->OutTransferLength,
248 case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN:
251 &Instance->IdeRegisters[Port],
253 Packet->InDataBuffer,
254 Packet->InTransferLength,
261 case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT:
264 &Instance->IdeRegisters[Port],
266 Packet->OutDataBuffer,
267 Packet->OutTransferLength,
275 return EFI_UNSUPPORTED;
280 if (PortMultiplierPort == 0xFFFF) {
286 PortMultiplierPort = 0;
290 case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
293 &Instance->AhciRegisters,
295 (UINT8)PortMultiplierPort,
304 case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:
307 &Instance->AhciRegisters,
309 (UINT8)PortMultiplierPort,
315 Packet->InDataBuffer,
316 Packet->InTransferLength,
321 case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:
324 &Instance->AhciRegisters,
326 (UINT8)PortMultiplierPort,
332 Packet->OutDataBuffer,
333 Packet->OutTransferLength,
338 case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN:
341 &Instance->AhciRegisters,
343 (UINT8)PortMultiplierPort,
349 Packet->InDataBuffer,
350 Packet->InTransferLength,
355 case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT:
358 &Instance->AhciRegisters,
360 (UINT8)PortMultiplierPort,
366 Packet->OutDataBuffer,
367 Packet->OutTransferLength,
373 return EFI_UNSUPPORTED;
379 Status = EFI_DEVICE_ERROR;
408 EntryHeader = &Instance->NonBlockingTaskList;
416 Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (Entry);
423 Task->PortMultiplier,
433 if ((Status != EFI_NOT_READY) && (Status !=
EFI_SUCCESS)) {
442 if (Status == EFI_NOT_READY) {
446 gBS->SignalEvent (Task->Event);
477 &gAtaAtapiPassThruDriverBinding,
479 &gAtaAtapiPassThruComponentName,
480 &gAtaAtapiPassThruComponentName2
547 Status =
gBS->OpenProtocol (
549 &gEfiDevicePathProtocolGuid,
550 (VOID *)&ParentDevicePath,
551 This->DriverBindingHandle,
553 EFI_OPEN_PROTOCOL_BY_DRIVER
555 if (EFI_ERROR (Status)) {
567 &gEfiDevicePathProtocolGuid,
568 This->DriverBindingHandle,
572 Status =
gBS->OpenProtocol (
574 &gEfiIdeControllerInitProtocolGuid,
575 (VOID **)&IdeControllerInit,
576 This->DriverBindingHandle,
578 EFI_OPEN_PROTOCOL_BY_DRIVER
581 if (EFI_ERROR (Status)) {
593 &gEfiIdeControllerInitProtocolGuid,
594 This->DriverBindingHandle,
601 Status =
gBS->OpenProtocol (
603 &gEfiPciIoProtocolGuid,
605 This->DriverBindingHandle,
607 EFI_OPEN_PROTOCOL_GET_PROTOCOL
609 if (EFI_ERROR (Status)) {
617 Status = PciIo->Pci.
Read (
620 PCI_CLASSCODE_OFFSET,
621 sizeof (PciData.Hdr.ClassCode),
622 PciData.Hdr.ClassCode
624 if (EFI_ERROR (Status)) {
625 return EFI_UNSUPPORTED;
632 return EFI_UNSUPPORTED;
682 UINT64 EnabledPciAttributes;
683 UINT64 OriginalPciAttributes;
686 IdeControllerInit =
NULL;
688 OriginalPciAttributes = 0;
690 DEBUG ((DEBUG_INFO,
"==AtaAtapiPassThru Start== Controller = %x\n", Controller));
692 Status =
gBS->OpenProtocol (
694 &gEfiIdeControllerInitProtocolGuid,
695 (VOID **)&IdeControllerInit,
696 This->DriverBindingHandle,
698 EFI_OPEN_PROTOCOL_BY_DRIVER
701 if (EFI_ERROR (Status)) {
702 DEBUG ((DEBUG_ERROR,
"Open Ide_Controller_Init Error, Status=%r", Status));
706 Status =
gBS->OpenProtocol (
708 &gEfiPciIoProtocolGuid,
710 This->DriverBindingHandle,
712 EFI_OPEN_PROTOCOL_GET_PROTOCOL
714 if (EFI_ERROR (Status)) {
715 DEBUG ((DEBUG_ERROR,
"Get Pci_Io Protocol Error, Status=%r", Status));
719 Status = PciIo->Attributes (
723 &OriginalPciAttributes
726 if (EFI_ERROR (Status)) {
730 Status = PciIo->Attributes (
734 &EnabledPciAttributes
736 if (!EFI_ERROR (Status)) {
737 EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE;
738 Status = PciIo->Attributes (
741 EnabledPciAttributes,
746 if (EFI_ERROR (Status)) {
750 Status =
gBS->LocateProtocol (&gEdkiiAtaAtapiPolicyProtocolGuid,
NULL, (VOID **)&mAtaAtapiPolicy);
751 if (EFI_ERROR (Status)) {
755 mAtaAtapiPolicy = &mDefaultAtaAtapiPolicy;
762 if (Instance ==
NULL) {
766 Instance->ControllerHandle = Controller;
767 Instance->IdeControllerInit = IdeControllerInit;
768 Instance->PciIo = PciIo;
769 Instance->EnabledPciAttributes = EnabledPciAttributes;
770 Instance->OriginalPciAttributes = OriginalPciAttributes;
771 Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode;
772 Instance->ExtScsiPassThru.
Mode = &Instance->ExtScsiPassThruMode;
776 Instance->TimerEvent =
NULL;
778 Status =
gBS->CreateEvent (
779 EVT_TIMER | EVT_NOTIFY_SIGNAL,
783 &Instance->TimerEvent
785 if (EFI_ERROR (Status)) {
793 if (EFI_ERROR (Status)) {
801 if (EFI_ERROR (Status)) {
805 Status =
gBS->InstallMultipleProtocolInterfaces (
807 &gEfiAtaPassThruProtocolGuid,
808 &(Instance->AtaPassThru),
809 &gEfiExtScsiPassThruProtocolGuid,
810 &(Instance->ExtScsiPassThru),
818 if (IdeControllerInit !=
NULL) {
821 &gEfiIdeControllerInitProtocolGuid,
822 This->DriverBindingHandle,
827 if ((Instance !=
NULL) && (Instance->TimerEvent !=
NULL)) {
828 gBS->CloseEvent (Instance->TimerEvent);
831 if (Instance !=
NULL) {
839 return EFI_UNSUPPORTED;
883 DEBUG ((DEBUG_INFO,
"==AtaAtapiPassThru Stop== Controller = %x\n", Controller));
885 Status =
gBS->OpenProtocol (
887 &gEfiAtaPassThruProtocolGuid,
888 (VOID **)&AtaPassThru,
889 This->DriverBindingHandle,
891 EFI_OPEN_PROTOCOL_GET_PROTOCOL
894 if (EFI_ERROR (Status)) {
895 return EFI_DEVICE_ERROR;
898 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (AtaPassThru);
900 Status =
gBS->UninstallMultipleProtocolInterfaces (
902 &gEfiAtaPassThruProtocolGuid,
903 &(Instance->AtaPassThru),
904 &gEfiExtScsiPassThruProtocolGuid,
905 &(Instance->ExtScsiPassThru),
909 if (EFI_ERROR (Status)) {
910 return EFI_DEVICE_ERROR;
918 &gEfiIdeControllerInitProtocolGuid,
919 This->DriverBindingHandle,
926 if (Instance->TimerEvent !=
NULL) {
927 gBS->CloseEvent (Instance->TimerEvent);
928 Instance->TimerEvent =
NULL;
937 PciIo = Instance->PciIo;
945 Instance->EnabledPciAttributes,
953 if (Instance->Mode == EfiAtaAhciMode) {
954 AhciRegisters = &Instance->AhciRegisters;
957 AhciRegisters->MapCommandTable
962 AhciRegisters->AhciCommandTable
966 AhciRegisters->MapCmdList
971 AhciRegisters->AhciCmdList
975 AhciRegisters->MapRFis
980 AhciRegisters->AhciRFis
987 Status = PciIo->Attributes (
990 Instance->OriginalPciAttributes,
1017 IN UINT16 PortMultiplier,
1018 IN EFI_ATA_DEVICE_TYPE DeviceType
1025 while (!
IsNull (&Instance->DeviceList, Node)) {
1026 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1034 if ((Instance->Mode == EfiAtaAhciMode) &&
1035 (DeviceInfo->Type == EfiIdeCdrom) &&
1036 (PortMultiplier == 0xFF))
1038 PortMultiplier = 0xFFFF;
1041 if ((DeviceInfo->Type == DeviceType) &&
1042 (Port == DeviceInfo->Port) &&
1043 (PortMultiplier == DeviceInfo->PortMultiplier))
1074 IN UINT16 PortMultiplier,
1075 IN EFI_ATA_DEVICE_TYPE DeviceType,
1083 if (DeviceInfo ==
NULL) {
1084 return EFI_OUT_OF_RESOURCES;
1087 DeviceInfo->Signature = ATA_ATAPI_DEVICE_SIGNATURE;
1088 DeviceInfo->Port = Port;
1089 DeviceInfo->PortMultiplier = PortMultiplier;
1090 DeviceInfo->Type = DeviceType;
1092 if (IdentifyData !=
NULL) {
1094 if (DeviceInfo->IdentifyData ==
NULL) {
1096 return EFI_OUT_OF_RESOURCES;
1121 while (!
IsNull (&Instance->DeviceList, Node)) {
1122 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1127 if (DeviceInfo->IdentifyData !=
NULL) {
1128 FreePool (DeviceInfo->IdentifyData);
1147 IN BOOLEAN IsSigEvent
1155 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1156 if (!
IsListEmpty (&Instance->NonBlockingTaskList)) {
1160 for (Entry = (&Instance->NonBlockingTaskList)->ForwardLink;
1161 Entry != (&Instance->NonBlockingTaskList);
1165 Entry = Entry->ForwardLink;
1166 Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (DelEntry);
1170 Task->Packet->
Asb->AtaStatus = 0x01;
1171 gBS->SignalEvent (Task->Event);
1178 gBS->RestoreTPL (OldTpl);
1204 Status = Instance->PciIo->Pci.Read (
1207 PCI_CLASSCODE_OFFSET,
1208 sizeof (PciData.Hdr.ClassCode),
1209 PciData.Hdr.ClassCode
1213 ClassCode = PciData.Hdr.ClassCode[1];
1215 switch (ClassCode) {
1216 case PCI_CLASS_MASS_STORAGE_IDE:
1220 Instance->Mode = EfiAtaIdeMode;
1223 if (EFI_ERROR (Status)) {
1224 Status = EFI_DEVICE_ERROR;
1233 Instance->Mode = EfiAtaAhciMode;
1237 if (EFI_ERROR (Status)) {
1238 Status = EFI_DEVICE_ERROR;
1244 Status = EFI_UNSUPPORTED;
1285 IN UINT16 PortMultiplierPort,
1295 UINT32 MaxSectorCount;
1300 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1302 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
1303 return EFI_INVALID_PARAMETER;
1306 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
1307 return EFI_INVALID_PARAMETER;
1310 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->Asb, This->Mode->IoAlign)) {
1311 return EFI_INVALID_PARAMETER;
1319 return EFI_INVALID_PARAMETER;
1328 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1329 IdentifyData = DeviceInfo->IdentifyData;
1330 MaxSectorCount = 0x100;
1333 if (Capacity > 0xFFFFFFF) {
1338 MaxSectorCount = 0x10000;
1355 if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
1356 (Packet->InTransferLength != 0))
1358 Packet->InTransferLength = Packet->InTransferLength * BlockSize;
1364 if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
1365 (Packet->OutTransferLength != 0))
1367 Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;
1375 if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||
1376 ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize)))
1378 return EFI_BAD_BUFFER_SIZE;
1384 if (Event !=
NULL) {
1387 return EFI_OUT_OF_RESOURCES;
1390 Task->Signature = ATA_NONBLOCKING_TASK_SIGNATURE;
1392 Task->PortMultiplier = PortMultiplierPort;
1393 Task->Packet = Packet;
1394 Task->Event = Event;
1395 Task->IsStart =
FALSE;
1396 Task->RetryTimes =
DivU64x32 (Packet->Timeout, 1000) + 1;
1397 if (Packet->Timeout == 0) {
1398 Task->InfiniteWait =
TRUE;
1400 Task->InfiniteWait =
FALSE;
1403 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1405 gBS->RestoreTPL (OldTpl);
1461 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1464 return EFI_INVALID_PARAMETER;
1467 if (*Port == 0xFFFF) {
1473 while (!
IsNull (&Instance->DeviceList, Node)) {
1474 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1476 if (DeviceInfo->Type == EfiIdeHarddisk) {
1477 *Port = DeviceInfo->Port;
1484 return EFI_NOT_FOUND;
1485 }
else if (*Port == Instance->PreviousPort) {
1488 while (!
IsNull (&Instance->DeviceList, Node)) {
1489 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1491 if ((DeviceInfo->Type == EfiIdeHarddisk) &&
1492 (DeviceInfo->Port > *Port))
1494 *Port = DeviceInfo->Port;
1501 return EFI_NOT_FOUND;
1506 return EFI_INVALID_PARAMETER;
1513 Instance->PreviousPort = *Port;
1565 IN OUT UINT16 *PortMultiplierPort
1572 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1574 if (PortMultiplierPort ==
NULL) {
1575 return EFI_INVALID_PARAMETER;
1578 if (Instance->PreviousPortMultiplier == 0xFFFF) {
1584 Instance->PreviousPortMultiplier = 0;
1585 return EFI_NOT_FOUND;
1588 if (*PortMultiplierPort == Instance->PreviousPortMultiplier) {
1591 while (!
IsNull (&Instance->DeviceList, Node)) {
1592 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1594 if ((DeviceInfo->Type == EfiIdeHarddisk) &&
1595 (DeviceInfo->Port == Port) &&
1596 (DeviceInfo->PortMultiplier > *PortMultiplierPort))
1598 *PortMultiplierPort = DeviceInfo->PortMultiplier;
1605 return EFI_NOT_FOUND;
1606 }
else if (*PortMultiplierPort == 0xFFFF) {
1612 while (!
IsNull (&Instance->DeviceList, Node)) {
1613 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
1615 if ((DeviceInfo->Type == EfiIdeHarddisk) &&
1616 (DeviceInfo->Port == Port))
1618 *PortMultiplierPort = DeviceInfo->PortMultiplier;
1625 return EFI_NOT_FOUND;
1630 return EFI_INVALID_PARAMETER;
1637 Instance->PreviousPortMultiplier = *PortMultiplierPort;
1679 IN UINT16 PortMultiplierPort,
1687 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1692 if (DevicePath ==
NULL) {
1693 return EFI_INVALID_PARAMETER;
1698 return EFI_NOT_FOUND;
1701 if (Instance->Mode == EfiAtaIdeMode) {
1703 if (DevicePathNode ==
NULL) {
1704 return EFI_OUT_OF_RESOURCES;
1708 DevicePathNode->Atapi.
SlaveMaster = (UINT8)PortMultiplierPort;
1709 DevicePathNode->Atapi.
Lun = 0;
1712 if (DevicePathNode ==
NULL) {
1713 return EFI_OUT_OF_RESOURCES;
1718 DevicePathNode->Sata.
Lun = 0;
1768 OUT UINT16 *PortMultiplierPort
1775 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1780 if ((DevicePath ==
NULL) || (Port ==
NULL) || (PortMultiplierPort ==
NULL)) {
1781 return EFI_INVALID_PARAMETER;
1793 return EFI_UNSUPPORTED;
1798 if (Instance->Mode == EfiAtaIdeMode) {
1800 *PortMultiplierPort = DevicePathNode->Atapi.
SlaveMaster;
1809 return EFI_NOT_FOUND;
1888 IN UINT16 PortMultiplierPort
1894 Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
1899 return EFI_INVALID_PARAMETER;
1933 IN UINT8 SenseDataLength,
1945 Cdb[4] = SenseDataLength;
2013 UINT8 PortMultiplier;
2014 EFI_ATA_HC_WORK_MODE Mode;
2023 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2025 if ((Packet ==
NULL) || (Packet->Cdb ==
NULL)) {
2026 return EFI_INVALID_PARAMETER;
2032 if ((Packet->CdbLength != 6) && (Packet->CdbLength != 10) &&
2033 (Packet->CdbLength != 12) && (Packet->CdbLength != 16))
2035 return EFI_INVALID_PARAMETER;
2038 if ((Packet->SenseDataLength != 0) && (Packet->SenseData ==
NULL)) {
2039 return EFI_INVALID_PARAMETER;
2042 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
2043 return EFI_INVALID_PARAMETER;
2046 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
2047 return EFI_INVALID_PARAMETER;
2050 if ((This->Mode->IoAlign > 1) && !
ADDRESS_IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
2051 return EFI_INVALID_PARAMETER;
2058 return EFI_INVALID_PARAMETER;
2073 PortMultiplier = Target[1];
2077 return EFI_INVALID_PARAMETER;
2080 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
2092 Packet->SenseDataLength = 0;
2096 Mode = Instance->Mode;
2104 if (EFI_ERROR (Status)) {
2108 Status =
AtaPacketCommandExecute (Instance->PciIo, &Instance->IdeRegisters[Port], Port, PortMultiplier, Packet);
2110 case EfiAtaAhciMode:
2111 if (PortMultiplier == 0xFF) {
2122 Status = EFI_DEVICE_ERROR;
2129 if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8 *)Packet->Cdb) !=
ATA_CMD_REQUEST_SENSE)) {
2131 if (PtrSenseData ==
NULL) {
2132 return EFI_DEVICE_ERROR;
2135 for (SenseReq =
TRUE; SenseReq;) {
2144 if (EFI_ERROR (SenseStatus)) {
2155 if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||
2168 Packet->SenseDataLength = (UINT8)SenseDataLen;
2202 IN OUT UINT8 **Target,
2212 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2214 if ((Target ==
NULL) || (Lun ==
NULL)) {
2215 return EFI_INVALID_PARAMETER;
2218 if (*Target ==
NULL) {
2219 return EFI_INVALID_PARAMETER;
2223 Target16 = (UINT16 *)*Target;
2225 if (
CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
2230 if (
CompareMem (&Target8[2], &mScsiId[2], TARGET_MAX_BYTES - 2) != 0) {
2231 return EFI_INVALID_PARAMETER;
2238 if ((*Target16 != Instance->PreviousTargetId) ||
2239 (*Lun != Instance->PreviousLun))
2241 return EFI_INVALID_PARAMETER;
2254 while (!
IsNull (&Instance->DeviceList, Node)) {
2255 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
2257 if ((DeviceInfo->Type == EfiIdeCdrom) &&
2258 ((Target8[0] < DeviceInfo->Port) ||
2259 ((Target8[0] == DeviceInfo->Port) &&
2260 (Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
2262 Target8[0] = (UINT8)DeviceInfo->Port;
2263 Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
2270 return EFI_NOT_FOUND;
2276 while (!
IsNull (&Instance->DeviceList, Node)) {
2277 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
2279 if (DeviceInfo->Type == EfiIdeCdrom) {
2280 Target8[0] = (UINT8)DeviceInfo->Port;
2281 Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
2288 return EFI_NOT_FOUND;
2297 Instance->PreviousTargetId = *Target16;
2298 Instance->PreviousLun = *Lun;
2342 UINT8 PortMultiplier;
2344 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2347 PortMultiplier = Target[1];
2352 if (DevicePath ==
NULL) {
2353 return EFI_INVALID_PARAMETER;
2360 return EFI_NOT_FOUND;
2364 return EFI_NOT_FOUND;
2367 if (Instance->Mode == EfiAtaIdeMode) {
2369 if (DevicePathNode ==
NULL) {
2370 return EFI_OUT_OF_RESOURCES;
2374 DevicePathNode->Atapi.
SlaveMaster = PortMultiplier;
2375 DevicePathNode->Atapi.
Lun = (UINT16)Lun;
2378 if (DevicePathNode ==
NULL) {
2379 return EFI_OUT_OF_RESOURCES;
2390 DevicePathNode->Sata.
Lun = (UINT16)Lun;
2430 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2435 if ((DevicePath ==
NULL) || (Target ==
NULL) || (Lun ==
NULL)) {
2436 return EFI_INVALID_PARAMETER;
2439 if (*Target ==
NULL) {
2440 return EFI_INVALID_PARAMETER;
2452 return EFI_UNSUPPORTED;
2455 SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
2459 if (Instance->Mode == EfiAtaIdeMode) {
2461 (*Target)[1] = (UINT8)DevicePathNode->Atapi.
SlaveMaster;
2462 *Lun = (UINT8)DevicePathNode->Atapi.
Lun;
2466 *Lun = (UINT8)DevicePathNode->Sata.
Lun;
2472 return EFI_NOT_FOUND;
2476 return EFI_NOT_FOUND;
2535 UINT8 PortMultiplier;
2537 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2542 return EFI_INVALID_PARAMETER;
2557 PortMultiplier = Target[1];
2561 return EFI_INVALID_PARAMETER;
2596 IN OUT UINT8 **Target
2605 Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
2607 if ((Target ==
NULL) || (*Target ==
NULL)) {
2608 return EFI_INVALID_PARAMETER;
2612 Target16 = (UINT16 *)*Target;
2614 if (
CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
2619 if (
CompareMem (&Target8[2], &mScsiId[2], TARGET_MAX_BYTES - 2) != 0) {
2620 return EFI_INVALID_PARAMETER;
2627 if (*Target16 != Instance->PreviousTargetId) {
2628 return EFI_INVALID_PARAMETER;
2640 while (!
IsNull (&Instance->DeviceList, Node)) {
2641 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
2643 if ((DeviceInfo->Type == EfiIdeCdrom) &&
2644 ((Target8[0] < DeviceInfo->Port) ||
2645 ((Target8[0] == DeviceInfo->Port) &&
2646 (Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
2648 Target8[0] = (UINT8)DeviceInfo->Port;
2649 Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
2656 return EFI_NOT_FOUND;
2663 while (!
IsNull (&Instance->DeviceList, Node)) {
2664 DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
2666 if (DeviceInfo->Type == EfiIdeCdrom) {
2667 Target8[0] = (UINT8)DeviceInfo->Port;
2668 Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
2675 return EFI_NOT_FOUND;
2682 Instance->PreviousTargetId = *Target16;
EFI_STATUS AhciModeInitialization(IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS AhciNonDataTransfer(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout)
EFI_STATUS AhciPioTransfer(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout)
EFI_STATUS EFIAPI AhciPacketCommandExecute(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
EFI_STATUS EFIAPI AhciDmaTransfer(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, IN UINT8 AtapiCommandLength, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
EFI_STATUS EFIAPI AtaPacketRequestSense(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN VOID *SenseData, IN UINT8 SenseDataLength, IN UINT64 Timeout)
VOID EFIAPI AsyncNonBlockingTransferRoutine(EFI_EVENT Event, VOID *Context)
EFI_STATUS EFIAPI ExtScsiPassThruGetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT8 **Target, OUT UINT64 *Lun)
EFI_STATUS EFIAPI AtaAtapiPassThruSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI ExtScsiPassThruResetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun)
EFI_STATUS EFIAPI ExtScsiPassThruBuildDevicePath(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI ExtScsiPassThruGetNextTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
EFI_STATUS EFIAPI AtaPassThruPassThruExecute(IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet, IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN ATA_NONBLOCK_TASK *Task OPTIONAL)
EFI_STATUS EFIAPI AtaPassThruGetNextDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN OUT UINT16 *PortMultiplierPort)
EFI_STATUS EFIAPI AtaPassThruPassThru(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI AtaAtapiPassThruStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI AtaPassThruResetPort(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port)
EFI_STATUS EFIAPI ExtScsiPassThruResetChannel(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This)
VOID EFIAPI DestroyDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
EFI_STATUS EFIAPI EnumerateAttachedDevice(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
VOID EFIAPI DestroyAsynTaskList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN BOOLEAN IsSigEvent)
EFI_STATUS EFIAPI ExtScsiPassThruGetNextTarget(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target)
EFI_STATUS EFIAPI AtaPassThruBuildDevicePath(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI AtaPassThruGetNextPort(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN OUT UINT16 *Port)
EFI_STATUS EFIAPI InitializeAtaAtapiPassThru(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI CreateNewDeviceInfo(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType, IN EFI_IDENTIFY_DATA *IdentifyData)
EFI_STATUS EFIAPI AtaAtapiPassThruStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI AtaPassThruGetDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT16 *Port, OUT UINT16 *PortMultiplierPort)
EFI_STATUS EFIAPI AtaPassThruResetDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort)
LIST_ENTRY *EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
EFI_STATUS EFIAPI ExtScsiPassThruPassThru(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI AtaPioDataInOut(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN OUT VOID *Buffer, IN UINT64 ByteCount, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
EFI_STATUS EFIAPI AtaNonDataCommandIn(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
EFI_STATUS EFIAPI AtaUdmaInOut(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_IDE_REGISTERS *IdeRegisters, IN BOOLEAN Read, IN VOID *DataBuffer, IN UINT64 DataLength, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
EFI_STATUS EFIAPI IdeModeInitialization(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
#define ATA_CMD_REQUEST_SENSE
defined from ATA-4
#define ATA_CMD_IDENTIFY_DEVICE
defined from ATA-3
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MESSAGING_DEVICE_PATH
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS EFIAPI GetIdeRegisterIoAddr(IN EFI_PCI_IO_PROTOCOL *PciIo, IN OUT EFI_IDE_REGISTERS *IdeRegisters)
EFI_STATUS EFIAPI AtaPacketCommandExecute(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT8 Channel, IN UINT8 Device, IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
#define ADDRESS_IS_ALIGNED(Address, Alignment)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define EFI_ATA_PASS_THRU_ATTRIBUTES_NONBLOCKIO
#define EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL
#define EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL
@ EfiPciIoAttributeOperationDisable
@ EfiPciIoAttributeOperationGet
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSet
@ EfiPciIoAttributeOperationSupported
#define IS_PCI_SATADPA(_p)
#define PCI_CLASS_MASS_STORAGE_SATADPA
VOID *EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_EXT_SCSI_PASS_THRU_MODE * Mode
UINT16 maximum_lba_for_48bit_addressing[4]
word 100~103
UINT16 command_set_supported_83
word 83
UINT16 logic_sector_size_lo
word 117
UINT16 phy_logic_sector_support
word 106
UINT16 logic_sector_size_hi
word 118
EFI_ATA_STATUS_BLOCK * Asb
EFI_PCI_IO_PROTOCOL_CONFIG Read
UINT16 PortMultiplierPortNumber
EFI_ATA_IDENTIFY_DATA AtaData