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 <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15075 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-01-09 19:15:06 +00:00 committed by oliviermartin
parent b4fdedc254
commit 5c5a34d485
1 changed files with 34 additions and 25 deletions

View File

@ -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,35 +205,44 @@ 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);
// LBA=1 Size=BlockSize
DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
Status = MmcReadWriteDataTest (MmcHostInstance, 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=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=LastBlock Size=BlockSize
DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, 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);
MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
ASSERT(MmcHostInstance != NULL);
if (MmcHostInstance->MmcHandle == ControllerHandle) {
break;
}
CurrentLink = CurrentLink->ForwardLink;
}
// If we didn't find the controller, return EFI_UNSUPPORTED
if ((MmcHostInstance == NULL)
|| (MmcHostInstance->MmcHandle != ControllerHandle)) {
return EFI_UNSUPPORTED;
}
// LBA=1 Size=BlockSize
DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
Status = MmcReadWriteDataTest (MmcHostInstance, 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=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=LastBlock Size=BlockSize
DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, 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);
return Status;
}