From 5c5a34d485eb200c81f89ebc8553a77167ba2c44 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Thu, 9 Jan 2014 19:15:06 +0000 Subject: MmcDxe: Perform diagnostics specifically on the requested controller In RunDiagnostics, find the controller specified by ControllerHandle and run diagnostics only on that controller, returning EFI_UNSUPPORTED if it isn't in the driver's pool of managed devices. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15075 6f19259b-4bc3-4df7-8a09-765794883524 --- EmbeddedPkg/Universal/MmcDxe/Diagnostics.c | 51 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'EmbeddedPkg') diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c index 14035afb10..310b7cc820 100644 --- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c +++ b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c @@ -1,7 +1,7 @@ /** @file Diagnostics Protocol implementation for the MMC DXE driver - Copyright (c) 2011, ARM Limited. All rights reserved. + Copyright (c) 2011-2014, ARM Limited. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -205,34 +205,43 @@ MmcDriverDiagnosticsRunDiagnostics ( DiagnosticLog (L"MMC Driver Diagnostics\n"); - // For each MMC instance + // Find the MMC Host instance on which we have been asked to run diagnostics + MmcHostInstance = NULL; CurrentLink = mMmcHostPool.ForwardLink; while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) { - MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink); - ASSERT (MmcHostInstance != NULL); + MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink); + ASSERT(MmcHostInstance != NULL); + if (MmcHostInstance->MmcHandle == ControllerHandle) { + break; + } + CurrentLink = CurrentLink->ForwardLink; + } - // LBA=1 Size=BlockSize - DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n"); - Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize); + // If we didn't find the controller, return EFI_UNSUPPORTED + if ((MmcHostInstance == NULL) + || (MmcHostInstance->MmcHandle != ControllerHandle)) { + return EFI_UNSUPPORTED; + } - // LBA=2 Size=BlockSize - DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n"); - Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize); + // LBA=1 Size=BlockSize + DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n"); + Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize); - // LBA=10 Size=BlockSize - DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n"); - Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize); + // LBA=2 Size=BlockSize + DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n"); + Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize); - // LBA=LastBlock Size=BlockSize - DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n"); - Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize); + // LBA=10 Size=BlockSize + DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n"); + Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize); - // LBA=1 Size=2*BlockSize - DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n"); - Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2*MmcHostInstance->BlockIo.Media->BlockSize); + // LBA=LastBlock Size=BlockSize + DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n"); + Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize); - CurrentLink = CurrentLink->ForwardLink; - } + // LBA=1 Size=2*BlockSize + DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n"); + Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2 * MmcHostInstance->BlockIo.Media->BlockSize); return Status; } -- cgit v1.2.3