]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg: Check if PcdUsbEhciPciAddress is set correctly to avoid assertion
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Nov 2011 06:12:06 +0000 (06:12 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Nov 2011 06:12:06 +0000 (06:12 +0000)
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

SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c

index 7fb671eb4b31368ff55a9a14b9589911ed409f51..567e06c9d36e9cfe8c43766a61840b2276183058 100644 (file)
@@ -164,9 +164,29 @@ CalculateUsbDebugPortBar (
  )\r
 {\r
   UINT16     PciStatus;\r
+  UINT16     VendorId;\r
+  UINT16     DeviceId;\r
+  UINT8      ProgInterface;\r
+  UINT8      SubClassCode;\r
+  UINT8      BaseCode;\r
   UINT8      CapabilityPtr;\r
   UINT8      CapabilityId;\r
 \r
+  VendorId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);\r
+  DeviceId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);\r
+  \r
+  if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  ProgInterface = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);\r
+  SubClassCode  = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);\r
+  BaseCode      = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);\r
+  \r
+  if ((ProgInterface != PCI_IF_EHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
   //\r
   // Enable Ehci Host Controller MMIO Space.\r
   //\r
@@ -1068,7 +1088,7 @@ DebugPortInitialize (
 \r
   Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);\r
   if (RETURN_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "USB Debug Port: EHCI host controller does not support debug port capability!\n"));\r
+    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"));\r
     goto Exit;\r
   }\r
 \r