X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=SourceLevelDebugPkg%2FLibrary%2FDebugCommunicationLibUsb3%2FDebugCommunicationLibUsb3Common.c;fp=SourceLevelDebugPkg%2FLibrary%2FDebugCommunicationLibUsb3%2FDebugCommunicationLibUsb3Common.c;h=924dbfd9d59d7ca219f8f332c64490ddce279e22;hb=77695f4da3dc8eedb6fc7fc67f91ef6ccd22daee;hp=86ecc2f9dbc7862daadd4702235d0757c30ae09a;hpb=ba0014b9f8ae1a593f03e744f26008214c2b06a8;p=mirror_edk2.git diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c index 86ecc2f9db..924dbfd9d5 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c @@ -46,7 +46,7 @@ UINT16 mSerialNumberStrDesc[] = { **/ VOID XhcSetR32Bit( - IN OUT UINTN Register, + IN OUT UINTN Register, IN UINT32 BitMask ) { @@ -65,7 +65,7 @@ XhcSetR32Bit( **/ VOID XhcClearR32Bit( - IN OUT UINTN Register, + IN OUT UINTN Register, IN UINT32 BitMask ) { @@ -92,10 +92,10 @@ XhcWriteDebugReg ( ) { EFI_PHYSICAL_ADDRESS DebugCapabilityBase; - + DebugCapabilityBase = Handle->DebugCapabilityBase; MmioWrite32 ((UINTN)(DebugCapabilityBase + Offset), Data); - + return; } @@ -116,7 +116,7 @@ XhcReadDebugReg ( { UINT32 Data; EFI_PHYSICAL_ADDRESS DebugCapabilityBase; - + DebugCapabilityBase = Handle->DebugCapabilityBase; Data = MmioRead32 ((UINTN)(DebugCapabilityBase + Offset)); @@ -182,7 +182,7 @@ ProgramXhciBaseAddress ( UINT32 Low; UINT32 High; EFI_PHYSICAL_ADDRESS XhciMmioBase; - + Low = PciRead32 (PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET); High = PciRead32 (PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + 4); XhciMmioBase = (EFI_PHYSICAL_ADDRESS) (LShiftU64 ((UINT64) High, 32) | Low); @@ -263,7 +263,7 @@ CalculateUsbDebugPortMmioBase ( VendorId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_VENDOR_ID_OFFSET); DeviceId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_DEVICE_ID_OFFSET); - + if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) { goto Done; } @@ -271,7 +271,7 @@ CalculateUsbDebugPortMmioBase ( ProgInterface = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET); SubClassCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 1); BaseCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 2); - + if ((ProgInterface != PCI_IF_XHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) { goto Done; } @@ -282,7 +282,7 @@ CalculateUsbDebugPortMmioBase ( // Get capability pointer from HCCPARAMS at offset 0x10 // CapabilityPointer = Handle->XhciMmioBase + (MmioRead32 ((UINTN)(Handle->XhciMmioBase + XHC_HCCPARAMS_OFFSET)) >> 16) * 4; - + // // Search XHCI debug capability // @@ -377,7 +377,7 @@ CreateEventRing ( EVENT_RING_SEG_TABLE_ENTRY *ERSTBase; ASSERT (EventRing != NULL); - + // // Allocate Event Ring // @@ -390,7 +390,7 @@ CreateEventRing ( EventRing->TrbNumber = EVENT_RING_TRB_NUMBER; EventRing->EventRingDequeue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0; EventRing->EventRingEnqueue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0; - + // // Software maintains an Event Ring Consumer Cycle State (CCS) bit, initializing it to '1' // and toggling it every time the Event Ring Dequeue Pointer wraps back to the beginning of the Event Ring. @@ -473,7 +473,7 @@ CreateTransferRing ( { VOID *Buf; LINK_TRB *EndTrb; - + Buf = AllocateAlignBuffer (sizeof (TRB_TEMPLATE) * TrbNum); ASSERT (Buf != NULL); ASSERT (((UINTN) Buf & 0xF) == 0); @@ -523,7 +523,7 @@ CreateDebugCapabilityContext ( UINT8 *ManufacturerStrDesc; UINT8 *ProductStrDesc; UINT8 *SerialNumberStrDesc; - + // // Allocate debug device context // @@ -531,10 +531,10 @@ CreateDebugCapabilityContext ( ASSERT (Buf != NULL); ASSERT (((UINTN) Buf & 0xF) == 0); ZeroMem (Buf, sizeof (XHC_DC_CONTEXT)); - + DebugCapabilityContext = (XHC_DC_CONTEXT *)(UINTN) Buf; Handle->DebugCapabilityContext = (EFI_PHYSICAL_ADDRESS)(UINTN) DebugCapabilityContext; - + // // Initialize DbcInfoContext. // @@ -550,7 +550,7 @@ CreateDebugCapabilityContext ( DebugCapabilityContext->EpOutContext.EPType = ED_BULK_OUT; DebugCapabilityContext->EpOutContext.MaxPacketSize = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE; DebugCapabilityContext->EpOutContext.AverageTRBLength = 0x1000; - + // // Initialize EpInContext. // @@ -558,7 +558,7 @@ CreateDebugCapabilityContext ( DebugCapabilityContext->EpInContext.EPType = ED_BULK_IN; DebugCapabilityContext->EpInContext.MaxPacketSize = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE; DebugCapabilityContext->EpInContext.AverageTRBLength = 0x1000; - + // // Update string descriptor address // @@ -567,19 +567,19 @@ CreateDebugCapabilityContext ( ZeroMem (String0Desc, STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN); CopyMem (String0Desc, mString0Desc, STRING0_DESC_LEN); DebugCapabilityContext->DbcInfoContext.String0DescAddress = (UINT64)(UINTN)String0Desc; - + ManufacturerStrDesc = String0Desc + STRING0_DESC_LEN; CopyMem (ManufacturerStrDesc, mManufacturerStrDesc, MANU_DESC_LEN); DebugCapabilityContext->DbcInfoContext.ManufacturerStrDescAddress = (UINT64)(UINTN)ManufacturerStrDesc; - + ProductStrDesc = ManufacturerStrDesc + MANU_DESC_LEN; CopyMem (ProductStrDesc, mProductStrDesc, PRODUCT_DESC_LEN); DebugCapabilityContext->DbcInfoContext.ProductStrDescAddress = (UINT64)(UINTN)ProductStrDesc; - + SerialNumberStrDesc = ProductStrDesc + PRODUCT_DESC_LEN; CopyMem (SerialNumberStrDesc, mSerialNumberStrDesc, SERIAL_DESC_LEN); DebugCapabilityContext->DbcInfoContext.SerialNumberStrDescAddress = (UINT64)(UINTN)SerialNumberStrDesc; - + // // Allocate and initialize the Transfer Ring for the Input Endpoint Context. // @@ -687,7 +687,7 @@ InitializeUsbDebugHardware ( return EFI_DEVICE_ERROR; } // - // If XHCI supports debug capability, hardware resource has been allocated, + // If XHCI supports debug capability, hardware resource has been allocated, // but it has not been enabled, try to enable again. // goto Enable; @@ -708,7 +708,7 @@ InitializeUsbDebugHardware ( // // Reset port to get debug device discovered - // + // for (Index = 0; Index < TotalUsb3Port; Index++) { XhcSetR32Bit ((UINTN)XhciOpRegister + XHC_PORTSC_OFFSET + Index * 0x10, BIT4); MicroSecondDelay (10 * 1000); @@ -727,20 +727,20 @@ InitializeUsbDebugHardware ( Handle->UrbIn.Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer; Handle->Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer + XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE; Handle->UrbOut.Data = Handle->UrbIn.Data + XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2; - + // // Initialize event ring // ZeroMem (&Handle->EventRing, sizeof (EVENT_RING)); Status = CreateEventRing (Handle, &Handle->EventRing); ASSERT_EFI_ERROR (Status); - + // // Init IN and OUT endpoint context // Status = CreateDebugCapabilityContext (Handle); ASSERT_EFI_ERROR (Status); - + // // Init DCDDI1 and DCDDI2 // @@ -748,7 +748,7 @@ InitializeUsbDebugHardware ( Handle, XHC_DC_DCDDI1, (UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL) - ); + ); XhcWriteDebugReg ( Handle, @@ -759,7 +759,7 @@ InitializeUsbDebugHardware ( Enable: if ((Handle->Initialized == USB3DBG_NOT_ENABLED) && (!Handle->ChangePortPower)) { // - // If the first time detection is failed, turn port power off and on in order to + // If the first time detection is failed, turn port power off and on in order to // reset port status this time, then try to check if debug device is ready again. // for (Index = 0; Index < TotalUsb3Port; Index++) { @@ -775,9 +775,9 @@ Enable: // Set DCE bit and LSE bit to "1" in DCCTRL in first initialization // XhcSetDebugRegBit (Handle, XHC_DC_DCCTRL, BIT1|BIT31); - + XhcDetectDebugCapabilityReady (Handle); - + Status = RETURN_SUCCESS; if (!Handle->Ready) { Handle->Initialized = USB3DBG_NOT_ENABLED; @@ -823,7 +823,7 @@ DiscoverInitializeUsbDebugPort ( @param[in] Instance Debug port instance. -**/ +**/ VOID SetUsb3DebugPortInstance ( IN USB3_DEBUG_PORT_HANDLE *Instance @@ -839,7 +839,7 @@ SetUsb3DebugPortInstance ( /** Return USB3 debug instance address. -**/ +**/ USB3_DEBUG_PORT_HANDLE * GetUsb3DebugPortInstance ( VOID @@ -1010,7 +1010,7 @@ DebugPortWriteBuffer ( XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT); Total += Sent; } - + return Total; } @@ -1123,7 +1123,7 @@ DebugPortInitialize ( USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle; // - // Validate the PCD PcdDebugPortHandleBufferSize value + // Validate the PCD PcdDebugPortHandleBufferSize value // ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));