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
/** @file\r
Diagnostics Protocol implementation for the MMC DXE driver\r
\r
/** @file\r
Diagnostics Protocol implementation for the MMC DXE driver\r
\r
- Copyright (c) 2011, ARM Limited. All rights reserved.\r
+ Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
\r
DiagnosticLog (L"MMC Driver Diagnostics\n");\r
\r
\r
DiagnosticLog (L"MMC Driver Diagnostics\n");\r
\r
- // For each MMC instance\r
+ // Find the MMC Host instance on which we have been asked to run diagnostics\r
+ MmcHostInstance = NULL;\r
CurrentLink = mMmcHostPool.ForwardLink;\r
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {\r
CurrentLink = mMmcHostPool.ForwardLink;\r
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {\r
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);\r
- ASSERT (MmcHostInstance != NULL);\r
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);\r
+ ASSERT(MmcHostInstance != NULL);\r
+ if (MmcHostInstance->MmcHandle == ControllerHandle) {\r
+ break;\r
+ }\r
+ CurrentLink = CurrentLink->ForwardLink;\r
+ }\r
- // LBA=1 Size=BlockSize\r
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");\r
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);\r
+ // If we didn't find the controller, return EFI_UNSUPPORTED\r
+ if ((MmcHostInstance == NULL)\r
+ || (MmcHostInstance->MmcHandle != ControllerHandle)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
- // LBA=2 Size=BlockSize\r
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n");\r
- Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);\r
+ // LBA=1 Size=BlockSize\r
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");\r
+ Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);\r
- // LBA=10 Size=BlockSize\r
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");\r
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize);\r
+ // LBA=2 Size=BlockSize\r
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n");\r
+ Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);\r
- // LBA=LastBlock Size=BlockSize\r
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");\r
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize);\r
+ // LBA=10 Size=BlockSize\r
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");\r
+ Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1, MmcHostInstance->BlockIo.Media->BlockSize);\r
- // LBA=1 Size=2*BlockSize\r
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");\r
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2*MmcHostInstance->BlockIo.Media->BlockSize);\r
+ // LBA=LastBlock Size=BlockSize\r
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");\r
+ Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock, MmcHostInstance->BlockIo.Media->BlockSize);\r
- CurrentLink = CurrentLink->ForwardLink;\r
- }\r
+ // LBA=1 Size=2*BlockSize\r
+ DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");\r
+ Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2 * MmcHostInstance->BlockIo.Media->BlockSize);\r