/** @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
return EFI_SUCCESS;\r
}\r
\r
+ //\r
+ // Certain PCI device may incorrectly have capability pointing to itself,\r
+ // break to avoid dead loop.\r
+ //\r
+ if (CapabilityPtr == (UINT8) (CapabilityEntry >> 8)) {\r
+ break;\r
+ }\r
+\r
CapabilityPtr = (UINT8) (CapabilityEntry >> 8);\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
// 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