]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
SourceLevelDebugPkg DebugCommUsb3: Return error when debug cap is reset
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugCommunicationLibUsb3 / DebugCommunicationLibUsb3Common.c
index fb9ca84fc7bc09d649b0ebf896521e920df49ac2..86ecc2f9dbc7862daadd4702235d0757c30ae09a 100644 (file)
@@ -673,11 +673,19 @@ InitializeUsbDebugHardware (
   UINTN                           Index;\r
   UINT8                           TotalUsb3Port;\r
   EFI_PHYSICAL_ADDRESS            XhciOpRegister;\r
+  UINT32                          Dcddi1;\r
 \r
   XhciOpRegister = Handle->XhciOpRegister;\r
   TotalUsb3Port = MmioRead32 (((UINTN) Handle->XhciMmioBase + XHC_HCSPARAMS1_OFFSET)) >> 24;\r
 \r
   if (Handle->Initialized == USB3DBG_NOT_ENABLED) {\r
+    Dcddi1 = XhcReadDebugReg (Handle,XHC_DC_DCDDI1);\r
+    if (Dcddi1 != (UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL)) {\r
+      //\r
+      // The debug capability has been reset by other code, return device error.\r
+      //\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
     //\r
     // If XHCI supports debug capability, hardware resource has been allocated, \r
     // but it has not been enabled, try to enable again.\r