**/\r
VOID\r
XhcSetR32Bit(\r
- IN OUT UINTN Register, \r
+ IN OUT UINTN Register,\r
IN UINT32 BitMask\r
)\r
{\r
**/\r
VOID\r
XhcClearR32Bit(\r
- IN OUT UINTN Register, \r
+ IN OUT UINTN Register,\r
IN UINT32 BitMask\r
)\r
{\r
)\r
{\r
EFI_PHYSICAL_ADDRESS DebugCapabilityBase;\r
- \r
+\r
DebugCapabilityBase = Handle->DebugCapabilityBase;\r
MmioWrite32 ((UINTN)(DebugCapabilityBase + Offset), Data);\r
- \r
+\r
return;\r
}\r
\r
{\r
UINT32 Data;\r
EFI_PHYSICAL_ADDRESS DebugCapabilityBase;\r
- \r
+\r
DebugCapabilityBase = Handle->DebugCapabilityBase;\r
Data = MmioRead32 ((UINTN)(DebugCapabilityBase + Offset));\r
\r
UINT32 Low;\r
UINT32 High;\r
EFI_PHYSICAL_ADDRESS XhciMmioBase;\r
- \r
+\r
Low = PciRead32 (PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
High = PciRead32 (PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + 4);\r
XhciMmioBase = (EFI_PHYSICAL_ADDRESS) (LShiftU64 ((UINT64) High, 32) | Low);\r
\r
VendorId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_VENDOR_ID_OFFSET);\r
DeviceId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_DEVICE_ID_OFFSET);\r
- \r
+\r
if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {\r
goto Done;\r
}\r
ProgInterface = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET);\r
SubClassCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);\r
BaseCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);\r
- \r
+\r
if ((ProgInterface != PCI_IF_XHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {\r
goto Done;\r
}\r
// Get capability pointer from HCCPARAMS at offset 0x10\r
//\r
CapabilityPointer = Handle->XhciMmioBase + (MmioRead32 ((UINTN)(Handle->XhciMmioBase + XHC_HCCPARAMS_OFFSET)) >> 16) * 4;\r
- \r
+\r
//\r
// Search XHCI debug capability\r
//\r
EVENT_RING_SEG_TABLE_ENTRY *ERSTBase;\r
\r
ASSERT (EventRing != NULL);\r
- \r
+\r
//\r
// Allocate Event Ring\r
//\r
EventRing->TrbNumber = EVENT_RING_TRB_NUMBER;\r
EventRing->EventRingDequeue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0;\r
EventRing->EventRingEnqueue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0;\r
- \r
+\r
//\r
// Software maintains an Event Ring Consumer Cycle State (CCS) bit, initializing it to '1'\r
// and toggling it every time the Event Ring Dequeue Pointer wraps back to the beginning of the Event Ring.\r
{\r
VOID *Buf;\r
LINK_TRB *EndTrb;\r
- \r
+\r
Buf = AllocateAlignBuffer (sizeof (TRB_TEMPLATE) * TrbNum);\r
ASSERT (Buf != NULL);\r
ASSERT (((UINTN) Buf & 0xF) == 0);\r
UINT8 *ManufacturerStrDesc;\r
UINT8 *ProductStrDesc;\r
UINT8 *SerialNumberStrDesc;\r
- \r
+\r
//\r
// Allocate debug device context\r
//\r
ASSERT (Buf != NULL);\r
ASSERT (((UINTN) Buf & 0xF) == 0);\r
ZeroMem (Buf, sizeof (XHC_DC_CONTEXT));\r
- \r
+\r
DebugCapabilityContext = (XHC_DC_CONTEXT *)(UINTN) Buf;\r
Handle->DebugCapabilityContext = (EFI_PHYSICAL_ADDRESS)(UINTN) DebugCapabilityContext;\r
- \r
+\r
//\r
// Initialize DbcInfoContext.\r
//\r
DebugCapabilityContext->EpOutContext.EPType = ED_BULK_OUT;\r
DebugCapabilityContext->EpOutContext.MaxPacketSize = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;\r
DebugCapabilityContext->EpOutContext.AverageTRBLength = 0x1000;\r
- \r
+\r
//\r
// Initialize EpInContext.\r
//\r
DebugCapabilityContext->EpInContext.EPType = ED_BULK_IN;\r
DebugCapabilityContext->EpInContext.MaxPacketSize = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;\r
DebugCapabilityContext->EpInContext.AverageTRBLength = 0x1000;\r
- \r
+\r
//\r
// Update string descriptor address\r
//\r
ZeroMem (String0Desc, STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN);\r
CopyMem (String0Desc, mString0Desc, STRING0_DESC_LEN);\r
DebugCapabilityContext->DbcInfoContext.String0DescAddress = (UINT64)(UINTN)String0Desc;\r
- \r
+\r
ManufacturerStrDesc = String0Desc + STRING0_DESC_LEN;\r
CopyMem (ManufacturerStrDesc, mManufacturerStrDesc, MANU_DESC_LEN);\r
DebugCapabilityContext->DbcInfoContext.ManufacturerStrDescAddress = (UINT64)(UINTN)ManufacturerStrDesc;\r
- \r
+\r
ProductStrDesc = ManufacturerStrDesc + MANU_DESC_LEN;\r
CopyMem (ProductStrDesc, mProductStrDesc, PRODUCT_DESC_LEN);\r
DebugCapabilityContext->DbcInfoContext.ProductStrDescAddress = (UINT64)(UINTN)ProductStrDesc;\r
- \r
+\r
SerialNumberStrDesc = ProductStrDesc + PRODUCT_DESC_LEN;\r
CopyMem (SerialNumberStrDesc, mSerialNumberStrDesc, SERIAL_DESC_LEN);\r
DebugCapabilityContext->DbcInfoContext.SerialNumberStrDescAddress = (UINT64)(UINTN)SerialNumberStrDesc;\r
- \r
+\r
//\r
// Allocate and initialize the Transfer Ring for the Input Endpoint Context.\r
//\r
return EFI_DEVICE_ERROR;\r
}\r
//\r
- // If XHCI supports debug capability, hardware resource has been allocated, \r
+ // If XHCI supports debug capability, hardware resource has been allocated,\r
// but it has not been enabled, try to enable again.\r
//\r
goto Enable;\r
\r
//\r
// Reset port to get debug device discovered\r
- // \r
+ //\r
for (Index = 0; Index < TotalUsb3Port; Index++) {\r
XhcSetR32Bit ((UINTN)XhciOpRegister + XHC_PORTSC_OFFSET + Index * 0x10, BIT4);\r
MicroSecondDelay (10 * 1000);\r
Handle->UrbIn.Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer;\r
Handle->Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer + XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;\r
Handle->UrbOut.Data = Handle->UrbIn.Data + XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2;\r
- \r
+\r
//\r
// Initialize event ring\r
//\r
ZeroMem (&Handle->EventRing, sizeof (EVENT_RING));\r
Status = CreateEventRing (Handle, &Handle->EventRing);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
//\r
// Init IN and OUT endpoint context\r
//\r
Status = CreateDebugCapabilityContext (Handle);\r
ASSERT_EFI_ERROR (Status);\r
- \r
+\r
//\r
// Init DCDDI1 and DCDDI2\r
//\r
Handle,\r
XHC_DC_DCDDI1,\r
(UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL)\r
- ); \r
+ );\r
\r
XhcWriteDebugReg (\r
Handle,\r
Enable:\r
if ((Handle->Initialized == USB3DBG_NOT_ENABLED) && (!Handle->ChangePortPower)) {\r
//\r
- // If the first time detection is failed, turn port power off and on in order to \r
+ // If the first time detection is failed, turn port power off and on in order to\r
// reset port status this time, then try to check if debug device is ready again.\r
//\r
for (Index = 0; Index < TotalUsb3Port; Index++) {\r
// Set DCE bit and LSE bit to "1" in DCCTRL in first initialization\r
//\r
XhcSetDebugRegBit (Handle, XHC_DC_DCCTRL, BIT1|BIT31);\r
- \r
+\r
XhcDetectDebugCapabilityReady (Handle);\r
- \r
+\r
Status = RETURN_SUCCESS;\r
if (!Handle->Ready) {\r
Handle->Initialized = USB3DBG_NOT_ENABLED;\r
\r
@param[in] Instance Debug port instance.\r
\r
-**/ \r
+**/\r
VOID\r
SetUsb3DebugPortInstance (\r
IN USB3_DEBUG_PORT_HANDLE *Instance\r
/**\r
Return USB3 debug instance address.\r
\r
-**/ \r
+**/\r
USB3_DEBUG_PORT_HANDLE *\r
GetUsb3DebugPortInstance (\r
VOID\r
XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT);\r
Total += Sent;\r
}\r
- \r
+\r
return Total;\r
}\r
\r
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
\r
//\r
- // Validate the PCD PcdDebugPortHandleBufferSize value \r
+ // Validate the PCD PcdDebugPortHandleBufferSize value\r
//\r
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));\r
\r