summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg
diff options
context:
space:
mode:
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-08 06:12:06 +0000
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-08 06:12:06 +0000
commitf98c2685597a15bbc01637777b831717e52424fe (patch)
tree57db9e390c483294eb2812163aaff23cd2112b97 /SourceLevelDebugPkg
parent59b9d73e5ff2331330805756aa4a32039670d097 (diff)
downloadedk2-platforms-f98c2685597a15bbc01637777b831717e52424fe.tar.xz
SourceLevelDebugPkg: Check if PcdUsbEhciPciAddress is set correctly to avoid assertion
Signed-off-by: erictian Reviewed-by: niruiyu Reviewed-by: vanjeff git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12670 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg')
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
index 7fb671eb4b..567e06c9d3 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
@@ -164,9 +164,29 @@ CalculateUsbDebugPortBar (
)
{
UINT16 PciStatus;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 ProgInterface;
+ UINT8 SubClassCode;
+ UINT8 BaseCode;
UINT8 CapabilityPtr;
UINT8 CapabilityId;
+ VendorId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);
+ DeviceId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);
+
+ if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ ProgInterface = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);
+ SubClassCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);
+ BaseCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);
+
+ if ((ProgInterface != PCI_IF_EHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {
+ return RETURN_UNSUPPORTED;
+ }
+
//
// Enable Ehci Host Controller MMIO Space.
//
@@ -1068,7 +1088,7 @@ DebugPortInitialize (
Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
if (RETURN_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "USB Debug Port: EHCI host controller does not support debug port capability!\n"));
+ DEBUG ((EFI_D_ERROR, "USB Debug Port: the pci device pointed by PcdUsbEhciPciAddress is not EHCI host controller or does not support debug port capability!\n"));
goto Exit;
}