return EFI_TIMEOUT;\r
}\r
\r
+/**\r
+ Prints contents of the ATA command block into the debug port.\r
+\r
+ @param[in] AtaCommandBlock AtaCommandBlock to print.\r
+ @param[in] DebugLevel Debug level on which to print.\r
+**/\r
+VOID\r
+AhciPrintCommandBlock (\r
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,\r
+ IN UINT32 DebugLevel\r
+ )\r
+{\r
+ DEBUG ((DebugLevel, "ATA COMMAND BLOCK:\n"));\r
+ DEBUG ((DebugLevel, "AtaCommand: %d\n", AtaCommandBlock->AtaCommand));\r
+ DEBUG ((DebugLevel, "AtaFeatures: %X\n", AtaCommandBlock->AtaFeatures));\r
+ DEBUG ((DebugLevel, "AtaSectorNumber: %d\n", AtaCommandBlock->AtaSectorNumber));\r
+ DEBUG ((DebugLevel, "AtaCylinderLow: %X\n", AtaCommandBlock->AtaCylinderHigh));\r
+ DEBUG ((DebugLevel, "AtaCylinderHigh: %X\n", AtaCommandBlock->AtaCylinderHigh));\r
+ DEBUG ((DebugLevel, "AtaDeviceHead: %d\n", AtaCommandBlock->AtaDeviceHead));\r
+ DEBUG ((DebugLevel, "AtaSectorNumberExp: %d\n", AtaCommandBlock->AtaSectorNumberExp));\r
+ DEBUG ((DebugLevel, "AtaCylinderLowExp: %X\n", AtaCommandBlock->AtaCylinderLowExp));\r
+ DEBUG ((DebugLevel, "AtaCylinderHighExp: %X\n", AtaCommandBlock->AtaCylinderHighExp));\r
+ DEBUG ((DebugLevel, "AtaFeaturesExp: %X\n", AtaCommandBlock->AtaFeaturesExp));\r
+ DEBUG ((DebugLevel, "AtaSectorCount: %d\n", AtaCommandBlock->AtaSectorCount));\r
+ DEBUG ((DebugLevel, "AtaSectorCountExp: %d\n", AtaCommandBlock->AtaSectorCountExp));\r
+}\r
+\r
+/**\r
+ Prints contents of the ATA status block into the debug port.\r
+\r
+ @param[in] AtaStatusBlock AtaStatusBlock to print.\r
+ @param[in] DebugLevel Debug level on which to print.\r
+**/\r
+VOID\r
+AhciPrintStatusBlock (\r
+ IN EFI_ATA_STATUS_BLOCK *AtaStatusBlock,\r
+ IN UINT32 DebugLevel\r
+ )\r
+{\r
+ //\r
+ // Only print status and error since we have all of the rest printed as\r
+ // a part of command block print.\r
+ //\r
+ DEBUG ((DebugLevel, "ATA STATUS BLOCK:\n"));\r
+ DEBUG ((DebugLevel, "AtaStatus: %d\n", AtaStatusBlock->AtaStatus));\r
+ DEBUG ((DebugLevel, "AtaError: %d\n", AtaStatusBlock->AtaError));\r
+}\r
+\r
/**\r
Start a PIO data transfer on specific port.\r
\r
DataCount\r
);\r
\r
+ DEBUG ((DEBUG_VERBOSE, "Starting command for PIO transfer:\n"));\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);\r
Status = AhciStartCommand (\r
PciIo,\r
Port,\r
);\r
\r
AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock);\r
+\r
+ if (Status == EFI_DEVICE_ERROR) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to execute command for PIO transfer:\n"));\r
+ //\r
+ // Repeat command block here to make sure it is printed on\r
+ // device error debug level.\r
+ //\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR);\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR);\r
+ } else {\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE);\r
+ }\r
+\r
return Status;\r
}\r
\r
DataCount\r
);\r
\r
+ DEBUG ((DEBUG_VERBOSE, "Starting command for sync DMA transfer:\n"));\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);\r
Status = AhciStartCommand (\r
PciIo,\r
Port,\r
DataCount\r
);\r
\r
+ DEBUG ((DEBUG_VERBOSE, "Starting command for async DMA transfer:\n"));\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);\r
Status = AhciStartCommand (\r
PciIo,\r
Port,\r
}\r
\r
AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock);\r
+\r
+ if (Status == EFI_DEVICE_ERROR) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to execute command for DMA transfer:\n"));\r
+ //\r
+ // Repeat command block here to make sure it is printed on\r
+ // device error debug level.\r
+ //\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR);\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR);\r
+ } else {\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE);\r
+ }\r
+\r
return Status;\r
}\r
\r
0\r
);\r
\r
+ DEBUG ((DEBUG_VERBOSE, "Starting command for non data transfer:\n"));\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);\r
Status = AhciStartCommand (\r
PciIo,\r
Port,\r
\r
AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock);\r
\r
+ if (Status == EFI_DEVICE_ERROR) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to execute command for non data transfer:\n"));\r
+ //\r
+ // Repeat command block here to make sure it is printed on\r
+ // device error debug level.\r
+ //\r
+ AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR);\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR);\r
+ } else {\r
+ AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE);\r
+ }\r
+\r
return Status;\r
}\r
\r