From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com []) by mx.groups.io with SMTP id smtpd.web11.3908.1604409850765584058 for ; Tue, 03 Nov 2020 05:24:17 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: mateusz.albecki@intel.com) IronPort-SDR: ZNYQd6Kwqt7zvTllFkkJ1FHrRmLc11bjcmkSkmUT32CVDtafRYLNGttltk5aO290a320EHSOks q4axGt9Mkm/g== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="169155239" X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="169155239" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 05:24:16 -0800 IronPort-SDR: c3iPYtL1jYeLdksiXuCVrHEUFJmsVa/cEYBGYf2u8PVvMzF9cnNcs5aK6yyFBLWVZ9KKWDK+uF uug4Aqu9u++w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="363023670" Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by FMSMGA003.fm.intel.com with ESMTP; 03 Nov 2020 05:24:15 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Albecki , Ray Ni , Hao A Wu Subject: [PATCH 4/4] MdeModulePkg/AtaAtapiPassThru: Trace ATA packets Date: Tue, 3 Nov 2020 14:23:48 +0100 Message-Id: <20201103132348.2916-5-mateusz.albecki@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20201103132348.2916-1-mateusz.albecki@intel.com> References: <20201103132348.2916-1-mateusz.albecki@intel.com> From: Albecki This simplify ATA driver debugging all ATA packets will be printed to debug port on DEBUG_VERBOSE level along with the packet execution status. Additionally failed packets and the failed packet execution status will be printed on DEBUG_ERROR level. Signed-off-by: Mateusz Albecki Cc: Ray Ni Cc: Hao A Wu --- .../Bus/Ata/AtaAtapiPassThru/AhciMode.c | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c index 4fe7e4b1dc..3a7a6eb018 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c @@ -846,6 +846,54 @@ AhciWaitUntilFisReceived ( return EFI_TIMEOUT; } +/** + Prints contents of the ATA command block into the debug port. + + @param[in] AtaCommandBlock AtaCommandBlock to print. + @param[in] DebugLevel Debug level on which to print. +**/ +VOID +AhciPrintCommandBlock ( + IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, + IN UINT32 DebugLevel + ) +{ + DEBUG ((DebugLevel, "ATA COMMAND BLOCK:\n")); + DEBUG ((DebugLevel, "AtaCommand: %d\n", AtaCommandBlock->AtaCommand)); + DEBUG ((DebugLevel, "AtaFeatures: %X\n", AtaCommandBlock->AtaFeatures)); + DEBUG ((DebugLevel, "AtaSectorNumber: %d\n", AtaCommandBlock->AtaSectorNumber)); + DEBUG ((DebugLevel, "AtaCylinderLow: %X\n", AtaCommandBlock->AtaCylinderHigh)); + DEBUG ((DebugLevel, "AtaCylinderHigh: %X\n", AtaCommandBlock->AtaCylinderHigh)); + DEBUG ((DebugLevel, "AtaDeviceHead: %d\n", AtaCommandBlock->AtaDeviceHead)); + DEBUG ((DebugLevel, "AtaSectorNumberExp: %d\n", AtaCommandBlock->AtaSectorNumberExp)); + DEBUG ((DebugLevel, "AtaCylinderLowExp: %X\n", AtaCommandBlock->AtaCylinderLowExp)); + DEBUG ((DebugLevel, "AtaCylinderHighExp: %X\n", AtaCommandBlock->AtaCylinderHighExp)); + DEBUG ((DebugLevel, "AtaFeaturesExp: %X\n", AtaCommandBlock->AtaFeaturesExp)); + DEBUG ((DebugLevel, "AtaSectorCount: %d\n", AtaCommandBlock->AtaSectorCount)); + DEBUG ((DebugLevel, "AtaSectorCountExp: %d\n", AtaCommandBlock->AtaSectorCountExp)); +} + +/** + Prints contents of the ATA status block into the debug port. + + @param[in] AtaStatusBlock AtaStatusBlock to print. + @param[in] DebugLevel Debug level on which to print. +**/ +VOID +AhciPrintStatusBlock ( + IN EFI_ATA_STATUS_BLOCK *AtaStatusBlock, + IN UINT32 DebugLevel + ) +{ + // + // Only print status and error since we have all of the rest printed as + // a part of command block print. + // + DEBUG ((DebugLevel, "ATA STATUS BLOCK:\n")); + DEBUG ((DebugLevel, "AtaStatus: %d\n", AtaStatusBlock->AtaStatus)); + DEBUG ((DebugLevel, "AtaError: %d\n", AtaStatusBlock->AtaError)); +} + /** Start a PIO data transfer on specific port. @@ -947,6 +995,8 @@ AhciPioTransfer ( DataCount ); + DEBUG ((DEBUG_VERBOSE, "Starting commmand: \n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status = AhciStartCommand ( PciIo, Port, @@ -1000,6 +1050,19 @@ AhciPioTransfer ( ); AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); + + if (Status == EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command:\n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } @@ -1132,6 +1195,8 @@ AhciDmaTransfer ( DataCount ); + DEBUG ((DEBUG_VERBOSE, "Starting commmand: \n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status = AhciStartCommand ( PciIo, Port, @@ -1168,6 +1233,8 @@ AhciDmaTransfer ( DataCount ); + DEBUG ((DEBUG_VERBOSE, "Starting commmand: \n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status = AhciStartCommand ( PciIo, Port, @@ -1238,6 +1305,19 @@ AhciDmaTransfer ( } AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); + + if (Status == EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command:\n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } @@ -1307,6 +1387,8 @@ AhciNonDataTransfer ( 0 ); + DEBUG ((DEBUG_VERBOSE, "Starting commmand: \n")); + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE); Status = AhciStartCommand ( PciIo, Port, @@ -1343,6 +1425,18 @@ AhciNonDataTransfer ( AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock); + if (Status == EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "Failed to execute command:\n")); + // + // Repeat command block here to make sure it is printed on + // device error debug level. + // + AhciPrintCommandBlock (AtaCommandBlock, DEBUG_ERROR); + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_ERROR); + } else { + AhciPrintStatusBlock (AtaStatusBlock, DEBUG_VERBOSE); + } + return Status; } -- 2.28.0.windows.1 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Sowackiego 173 | 80-298 Gdask | Sd Rejonowy Gdask Pnoc | VII Wydzia Gospodarczy Krajowego Rejestru Sdowego - KRS 101882 | NIP 957-07-52-316 | Kapita zakadowy 200.000 PLN. Ta wiadomo wraz z zacznikami jest przeznaczona dla okrelonego adresata i moe zawiera informacje poufne. W razie przypadkowego otrzymania tej wiadomoci, prosimy o powiadomienie nadawcy oraz trwae jej usunicie; jakiekolwiek przegldanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.