LocatePciExpressCapabilityRegBlock () doesn't check the return status of Pci.Read().
Certain platform's PciRootBridge.Pci.Read() doesn't support PCIE access causing the CapabilityEntry not updated.
If the uninitialized CapabilityEntry equals to a big enough initial value, the while-loop will never end.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Maurice Ma <maurice.ma@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17513
6f19259b-4bc3-4df7-8a09-
765794883524
/** @file\r
PCI command register operations supporting functions implementation for PCI Bus module.\r
\r
/** @file\r
PCI command register operations supporting functions implementation for PCI Bus module.\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
OUT UINT32 *NextRegBlock OPTIONAL\r
)\r
{\r
OUT UINT32 *NextRegBlock OPTIONAL\r
)\r
{\r
- UINT32 CapabilityPtr;\r
- UINT32 CapabilityEntry;\r
- UINT16 CapabilityID;\r
+ EFI_STATUS Status;\r
+ UINT32 CapabilityPtr;\r
+ UINT32 CapabilityEntry;\r
+ UINT16 CapabilityID;\r
\r
//\r
// To check the capability of this device supports\r
\r
//\r
// To check the capability of this device supports\r
// Mask it to DWORD alignment per PCI spec\r
//\r
CapabilityPtr &= 0xFFC;\r
// Mask it to DWORD alignment per PCI spec\r
//\r
CapabilityPtr &= 0xFFC;\r
- PciIoDevice->PciIo.Pci.Read (\r
- &PciIoDevice->PciIo,\r
- EfiPciIoWidthUint32,\r
- CapabilityPtr,\r
- 1,\r
- &CapabilityEntry\r
- );\r
+ Status = PciIoDevice->PciIo.Pci.Read (\r
+ &PciIoDevice->PciIo,\r
+ EfiPciIoWidthUint32,\r
+ CapabilityPtr,\r
+ 1,\r
+ &CapabilityEntry\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
\r
CapabilityID = (UINT16) CapabilityEntry;\r
\r
\r
CapabilityID = (UINT16) CapabilityEntry;\r
\r