SourceLevelDebugPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the SourceLevelDebugPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
b878648967
commit
c1e126b119
@ -8,27 +8,27 @@
|
||||
|
||||
#include "DebugCommunicationLibUsb3Internal.h"
|
||||
|
||||
UINT16 mString0Desc[] = {
|
||||
UINT16 mString0Desc[] = {
|
||||
// String Descriptor Type + Length
|
||||
( USB_DESC_TYPE_STRING << 8 ) + STRING0_DESC_LEN,
|
||||
(USB_DESC_TYPE_STRING << 8) + STRING0_DESC_LEN,
|
||||
0x0409
|
||||
};
|
||||
|
||||
UINT16 mManufacturerStrDesc[] = {
|
||||
UINT16 mManufacturerStrDesc[] = {
|
||||
// String Descriptor Type + Length
|
||||
( USB_DESC_TYPE_STRING << 8 ) + MANU_DESC_LEN,
|
||||
'I', 'n', 't', 'e', 'l'
|
||||
(USB_DESC_TYPE_STRING << 8) + MANU_DESC_LEN,
|
||||
'I', 'n','t', 'e', 'l'
|
||||
};
|
||||
|
||||
UINT16 mProductStrDesc[] = {
|
||||
UINT16 mProductStrDesc[] = {
|
||||
// String Descriptor Type + Length
|
||||
( USB_DESC_TYPE_STRING << 8 ) + PRODUCT_DESC_LEN,
|
||||
'U', 'S', 'B', ' ', '3', '.', '0', ' ', 'D', 'e', 'b', 'u', 'g', ' ', 'C', 'a', 'b', 'l', 'e'
|
||||
(USB_DESC_TYPE_STRING << 8) + PRODUCT_DESC_LEN,
|
||||
'U', 'S','B', ' ', '3', '.', '0', ' ', 'D', 'e', 'b', 'u', 'g', ' ', 'C', 'a', 'b', 'l', 'e'
|
||||
};
|
||||
|
||||
UINT16 mSerialNumberStrDesc[] = {
|
||||
UINT16 mSerialNumberStrDesc[] = {
|
||||
// String Descriptor Type + Length
|
||||
( USB_DESC_TYPE_STRING << 8 ) + SERIAL_DESC_LEN,
|
||||
(USB_DESC_TYPE_STRING << 8) + SERIAL_DESC_LEN,
|
||||
'1'
|
||||
};
|
||||
|
||||
@ -39,14 +39,14 @@ UINT16 mSerialNumberStrDesc[] = {
|
||||
@param[in] BitMask 32-bit mask
|
||||
**/
|
||||
VOID
|
||||
XhcSetR32Bit(
|
||||
IN OUT UINTN Register,
|
||||
IN UINT32 BitMask
|
||||
XhcSetR32Bit (
|
||||
IN OUT UINTN Register,
|
||||
IN UINT32 BitMask
|
||||
)
|
||||
{
|
||||
UINT32 RegisterValue;
|
||||
UINT32 RegisterValue;
|
||||
|
||||
RegisterValue = MmioRead32 (Register);
|
||||
RegisterValue = MmioRead32 (Register);
|
||||
RegisterValue |= (UINT32)(BitMask);
|
||||
MmioWrite32 (Register, RegisterValue);
|
||||
}
|
||||
@ -58,14 +58,14 @@ XhcSetR32Bit(
|
||||
@param[in] BitMask 32-bit mask
|
||||
**/
|
||||
VOID
|
||||
XhcClearR32Bit(
|
||||
IN OUT UINTN Register,
|
||||
IN UINT32 BitMask
|
||||
XhcClearR32Bit (
|
||||
IN OUT UINTN Register,
|
||||
IN UINT32 BitMask
|
||||
)
|
||||
{
|
||||
UINT32 RegisterValue;
|
||||
UINT32 RegisterValue;
|
||||
|
||||
RegisterValue = MmioRead32 (Register);
|
||||
RegisterValue = MmioRead32 (Register);
|
||||
RegisterValue &= ~BitMask;
|
||||
MmioWrite32 (Register, RegisterValue);
|
||||
}
|
||||
@ -104,15 +104,15 @@ XhcWriteDebugReg (
|
||||
**/
|
||||
UINT32
|
||||
XhcReadDebugReg (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
EFI_PHYSICAL_ADDRESS DebugCapabilityBase;
|
||||
UINT32 Data;
|
||||
EFI_PHYSICAL_ADDRESS DebugCapabilityBase;
|
||||
|
||||
DebugCapabilityBase = Handle->DebugCapabilityBase;
|
||||
Data = MmioRead32 ((UINTN)(DebugCapabilityBase + Offset));
|
||||
Data = MmioRead32 ((UINTN)(DebugCapabilityBase + Offset));
|
||||
|
||||
return Data;
|
||||
}
|
||||
@ -127,12 +127,12 @@ XhcReadDebugReg (
|
||||
**/
|
||||
VOID
|
||||
XhcSetDebugRegBit (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset,
|
||||
IN UINT32 Bit
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset,
|
||||
IN UINT32 Bit
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
UINT32 Data;
|
||||
|
||||
Data = XhcReadDebugReg (Handle, Offset);
|
||||
Data |= Bit;
|
||||
@ -149,15 +149,15 @@ XhcSetDebugRegBit (
|
||||
**/
|
||||
VOID
|
||||
XhcClearDebugRegBit (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset,
|
||||
IN UINT32 Bit
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 Offset,
|
||||
IN UINT32 Bit
|
||||
)
|
||||
{
|
||||
UINT32 Data;
|
||||
UINT32 Data;
|
||||
|
||||
Data = XhcReadDebugReg (Handle, Offset);
|
||||
Data &= ~Bit;
|
||||
Data &= ~Bit;
|
||||
XhcWriteDebugReg (Handle, Offset, Data);
|
||||
}
|
||||
|
||||
@ -172,26 +172,26 @@ ProgramXhciBaseAddress (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT16 PciCmd;
|
||||
UINT32 Low;
|
||||
UINT32 High;
|
||||
EFI_PHYSICAL_ADDRESS XhciMmioBase;
|
||||
UINT16 PciCmd;
|
||||
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);
|
||||
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);
|
||||
XhciMmioBase &= XHCI_BASE_ADDRESS_64_BIT_MASK;
|
||||
|
||||
if ((XhciMmioBase == 0) || (XhciMmioBase == XHCI_BASE_ADDRESS_64_BIT_MASK)) {
|
||||
XhciMmioBase = PcdGet64(PcdUsbXhciMemorySpaceBase);
|
||||
PciWrite32(PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, XhciMmioBase & 0xFFFFFFFF);
|
||||
PciWrite32(PcdGet32(PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + 4, (RShiftU64 (XhciMmioBase, 32) & 0xFFFFFFFF));
|
||||
XhciMmioBase = PcdGet64 (PcdUsbXhciMemorySpaceBase);
|
||||
PciWrite32 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, XhciMmioBase & 0xFFFFFFFF);
|
||||
PciWrite32 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + 4, (RShiftU64 (XhciMmioBase, 32) & 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
PciCmd = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_COMMAND_OFFSET);
|
||||
PciCmd = PciRead16 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_COMMAND_OFFSET);
|
||||
if (((PciCmd & EFI_PCI_COMMAND_MEMORY_SPACE) == 0) || ((PciCmd & EFI_PCI_COMMAND_BUS_MASTER) == 0)) {
|
||||
PciCmd |= EFI_PCI_COMMAND_MEMORY_SPACE | EFI_PCI_COMMAND_BUS_MASTER;
|
||||
PciWrite16(PcdGet32(PcdUsbXhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);
|
||||
PciWrite16 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);
|
||||
}
|
||||
|
||||
return XhciMmioBase;
|
||||
@ -206,8 +206,8 @@ ProgramXhciBaseAddress (
|
||||
**/
|
||||
VOID
|
||||
UpdateXhcResource (
|
||||
IN OUT USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN EFI_PHYSICAL_ADDRESS XhciMmioBase
|
||||
IN OUT USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN EFI_PHYSICAL_ADDRESS XhciMmioBase
|
||||
)
|
||||
{
|
||||
if (Handle == NULL) {
|
||||
@ -234,18 +234,18 @@ UpdateXhcResource (
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
CalculateUsbDebugPortMmioBase (
|
||||
USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
UINT16 VendorId;
|
||||
UINT16 DeviceId;
|
||||
UINT8 ProgInterface;
|
||||
UINT8 SubClassCode;
|
||||
UINT8 BaseCode;
|
||||
BOOLEAN Flag;
|
||||
UINT32 Capability;
|
||||
EFI_PHYSICAL_ADDRESS CapabilityPointer;
|
||||
UINT8 CapLength;
|
||||
UINT16 VendorId;
|
||||
UINT16 DeviceId;
|
||||
UINT8 ProgInterface;
|
||||
UINT8 SubClassCode;
|
||||
UINT8 BaseCode;
|
||||
BOOLEAN Flag;
|
||||
UINT32 Capability;
|
||||
EFI_PHYSICAL_ADDRESS CapabilityPointer;
|
||||
UINT8 CapLength;
|
||||
|
||||
if (Handle->Initialized != USB3DBG_UNINITIALIZED) {
|
||||
if (Handle->Initialized == USB3DBG_NO_DBG_CAB) {
|
||||
@ -255,22 +255,22 @@ CalculateUsbDebugPortMmioBase (
|
||||
}
|
||||
}
|
||||
|
||||
VendorId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_VENDOR_ID_OFFSET);
|
||||
DeviceId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) + PCI_DEVICE_ID_OFFSET);
|
||||
VendorId = PciRead16 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_VENDOR_ID_OFFSET);
|
||||
DeviceId = PciRead16 (PcdGet32 (PcdUsbXhciPciAddress) + PCI_DEVICE_ID_OFFSET);
|
||||
|
||||
if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
ProgInterface = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET);
|
||||
SubClassCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);
|
||||
BaseCode = PciRead8 (PcdGet32(PcdUsbXhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);
|
||||
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;
|
||||
}
|
||||
|
||||
CapLength = MmioRead8 ((UINTN) Handle->XhciMmioBase);
|
||||
CapLength = MmioRead8 ((UINTN)Handle->XhciMmioBase);
|
||||
|
||||
//
|
||||
// Get capability pointer from HCCPARAMS at offset 0x10
|
||||
@ -280,21 +280,23 @@ CalculateUsbDebugPortMmioBase (
|
||||
//
|
||||
// Search XHCI debug capability
|
||||
//
|
||||
Flag = FALSE;
|
||||
Flag = FALSE;
|
||||
Capability = MmioRead32 ((UINTN)CapabilityPointer);
|
||||
while (TRUE) {
|
||||
if ((Capability & XHC_CAPABILITY_ID_MASK) == PCI_CAPABILITY_ID_DEBUG_PORT) {
|
||||
Flag = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) & XHC_CAPABILITY_ID_MASK) == 0) {
|
||||
//
|
||||
// Reach the end of capability list, quit
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
CapabilityPointer += ((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) * 4;
|
||||
Capability = MmioRead32 ((UINTN)CapabilityPointer);
|
||||
Capability = MmioRead32 ((UINTN)CapabilityPointer);
|
||||
}
|
||||
|
||||
if (!Flag) {
|
||||
@ -307,8 +309,8 @@ CalculateUsbDebugPortMmioBase (
|
||||
Handle->DebugCapabilityBase = CapabilityPointer;
|
||||
Handle->DebugCapabilityOffset = CapabilityPointer - Handle->XhciMmioBase;
|
||||
Handle->XhciOpRegister = Handle->XhciMmioBase + CapLength;
|
||||
Handle->DebugSupport = TRUE;
|
||||
Handle->Initialized = USB3DBG_DBG_CAB;
|
||||
Handle->DebugSupport = TRUE;
|
||||
Handle->Initialized = USB3DBG_DBG_CAB;
|
||||
return RETURN_SUCCESS;
|
||||
|
||||
Done:
|
||||
@ -331,12 +333,12 @@ Done:
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
NeedReinitializeHardware(
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
NeedReinitializeHardware (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
volatile UINT32 Dcctrl;
|
||||
BOOLEAN Result;
|
||||
volatile UINT32 Dcctrl;
|
||||
|
||||
Result = FALSE;
|
||||
|
||||
@ -347,7 +349,7 @@ NeedReinitializeHardware(
|
||||
if ((Dcctrl & BIT0) == 0) {
|
||||
Result = TRUE;
|
||||
} else if (!Handle->Ready) {
|
||||
Handle->Ready = TRUE;
|
||||
Handle->Ready = TRUE;
|
||||
Handle->Initialized = USB3DBG_ENABLED;
|
||||
}
|
||||
|
||||
@ -363,8 +365,8 @@ NeedReinitializeHardware(
|
||||
**/
|
||||
EFI_STATUS
|
||||
CreateEventRing (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
OUT EVENT_RING *EventRing
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
OUT EVENT_RING *EventRing
|
||||
)
|
||||
{
|
||||
VOID *Buf;
|
||||
@ -377,13 +379,13 @@ CreateEventRing (
|
||||
//
|
||||
Buf = AllocateAlignBuffer (sizeof (TRB_TEMPLATE) * EVENT_RING_TRB_NUMBER);
|
||||
ASSERT (Buf != NULL);
|
||||
ASSERT (((UINTN) Buf & 0x3F) == 0);
|
||||
ASSERT (((UINTN)Buf & 0x3F) == 0);
|
||||
ZeroMem (Buf, sizeof (TRB_TEMPLATE) * EVENT_RING_TRB_NUMBER);
|
||||
|
||||
EventRing->EventRingSeg0 = (EFI_PHYSICAL_ADDRESS)(UINTN) Buf;
|
||||
EventRing->EventRingSeg0 = (EFI_PHYSICAL_ADDRESS)(UINTN)Buf;
|
||||
EventRing->TrbNumber = EVENT_RING_TRB_NUMBER;
|
||||
EventRing->EventRingDequeue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0;
|
||||
EventRing->EventRingEnqueue = (EFI_PHYSICAL_ADDRESS)(UINTN) EventRing->EventRingSeg0;
|
||||
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'
|
||||
@ -396,11 +398,11 @@ CreateEventRing (
|
||||
//
|
||||
Buf = AllocateAlignBuffer (sizeof (EVENT_RING_SEG_TABLE_ENTRY) * ERST_NUMBER);
|
||||
ASSERT (Buf != NULL);
|
||||
ASSERT (((UINTN) Buf & 0x3F) == 0);
|
||||
ASSERT (((UINTN)Buf & 0x3F) == 0);
|
||||
ZeroMem (Buf, sizeof (EVENT_RING_SEG_TABLE_ENTRY) * ERST_NUMBER);
|
||||
|
||||
ERSTBase = (EVENT_RING_SEG_TABLE_ENTRY *) Buf;
|
||||
EventRing->ERSTBase = (EFI_PHYSICAL_ADDRESS)(UINTN) ERSTBase;
|
||||
ERSTBase = (EVENT_RING_SEG_TABLE_ENTRY *)Buf;
|
||||
EventRing->ERSTBase = (EFI_PHYSICAL_ADDRESS)(UINTN)ERSTBase;
|
||||
|
||||
//
|
||||
// Fill Event Segment address
|
||||
@ -415,13 +417,13 @@ CreateEventRing (
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCERDP,
|
||||
XHC_LOW_32BIT((UINT64)(UINTN)EventRing->EventRingDequeue)
|
||||
XHC_LOW_32BIT ((UINT64)(UINTN)EventRing->EventRingDequeue)
|
||||
);
|
||||
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCERDP + 4,
|
||||
XHC_HIGH_32BIT((UINT64)(UINTN)EventRing->EventRingDequeue)
|
||||
XHC_HIGH_32BIT ((UINT64)(UINTN)EventRing->EventRingDequeue)
|
||||
);
|
||||
|
||||
//
|
||||
@ -430,13 +432,13 @@ CreateEventRing (
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCERSTBA,
|
||||
XHC_LOW_32BIT((UINT64)(UINTN)ERSTBase)
|
||||
XHC_LOW_32BIT ((UINT64)(UINTN)ERSTBase)
|
||||
);
|
||||
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCERSTBA + 4,
|
||||
XHC_HIGH_32BIT((UINT64)(UINTN)ERSTBase)
|
||||
XHC_HIGH_32BIT ((UINT64)(UINTN)ERSTBase)
|
||||
);
|
||||
|
||||
//
|
||||
@ -460,37 +462,37 @@ CreateEventRing (
|
||||
**/
|
||||
VOID
|
||||
CreateTransferRing (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 TrbNum,
|
||||
OUT TRANSFER_RING *TransferRing
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle,
|
||||
IN UINT32 TrbNum,
|
||||
OUT TRANSFER_RING *TransferRing
|
||||
)
|
||||
{
|
||||
VOID *Buf;
|
||||
LINK_TRB *EndTrb;
|
||||
VOID *Buf;
|
||||
LINK_TRB *EndTrb;
|
||||
|
||||
Buf = AllocateAlignBuffer (sizeof (TRB_TEMPLATE) * TrbNum);
|
||||
ASSERT (Buf != NULL);
|
||||
ASSERT (((UINTN) Buf & 0xF) == 0);
|
||||
ASSERT (((UINTN)Buf & 0xF) == 0);
|
||||
ZeroMem (Buf, sizeof (TRB_TEMPLATE) * TrbNum);
|
||||
|
||||
TransferRing->RingSeg0 = (EFI_PHYSICAL_ADDRESS)(UINTN) Buf;
|
||||
TransferRing->TrbNumber = TrbNum;
|
||||
TransferRing->RingEnqueue = TransferRing->RingSeg0;
|
||||
TransferRing->RingDequeue = TransferRing->RingSeg0;
|
||||
TransferRing->RingPCS = 1;
|
||||
TransferRing->RingSeg0 = (EFI_PHYSICAL_ADDRESS)(UINTN)Buf;
|
||||
TransferRing->TrbNumber = TrbNum;
|
||||
TransferRing->RingEnqueue = TransferRing->RingSeg0;
|
||||
TransferRing->RingDequeue = TransferRing->RingSeg0;
|
||||
TransferRing->RingPCS = 1;
|
||||
//
|
||||
// 4.9.2 Transfer Ring Management
|
||||
// To form a ring (or circular queue) a Link TRB may be inserted at the end of a ring to
|
||||
// point to the first TRB in the ring.
|
||||
//
|
||||
EndTrb = (LINK_TRB *) ((UINTN)Buf + sizeof (TRB_TEMPLATE) * (TrbNum - 1));
|
||||
EndTrb = (LINK_TRB *)((UINTN)Buf + sizeof (TRB_TEMPLATE) * (TrbNum - 1));
|
||||
EndTrb->Type = TRB_TYPE_LINK;
|
||||
EndTrb->PtrLo = XHC_LOW_32BIT (Buf);
|
||||
EndTrb->PtrHi = XHC_HIGH_32BIT (Buf);
|
||||
//
|
||||
// Toggle Cycle (TC). When set to '1', the xHC shall toggle its interpretation of the Cycle bit.
|
||||
//
|
||||
EndTrb->TC = 1;
|
||||
EndTrb->TC = 1;
|
||||
//
|
||||
// Set Cycle bit as other TRB PCS init value
|
||||
//
|
||||
@ -508,26 +510,26 @@ CreateTransferRing (
|
||||
**/
|
||||
EFI_STATUS
|
||||
CreateDebugCapabilityContext (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
VOID *Buf;
|
||||
XHC_DC_CONTEXT *DebugCapabilityContext;
|
||||
UINT8 *String0Desc;
|
||||
UINT8 *ManufacturerStrDesc;
|
||||
UINT8 *ProductStrDesc;
|
||||
UINT8 *SerialNumberStrDesc;
|
||||
VOID *Buf;
|
||||
XHC_DC_CONTEXT *DebugCapabilityContext;
|
||||
UINT8 *String0Desc;
|
||||
UINT8 *ManufacturerStrDesc;
|
||||
UINT8 *ProductStrDesc;
|
||||
UINT8 *SerialNumberStrDesc;
|
||||
|
||||
//
|
||||
// Allocate debug device context
|
||||
//
|
||||
Buf = AllocateAlignBuffer (sizeof (XHC_DC_CONTEXT));
|
||||
ASSERT (Buf != NULL);
|
||||
ASSERT (((UINTN) Buf & 0xF) == 0);
|
||||
ASSERT (((UINTN)Buf & 0xF) == 0);
|
||||
ZeroMem (Buf, sizeof (XHC_DC_CONTEXT));
|
||||
|
||||
DebugCapabilityContext = (XHC_DC_CONTEXT *)(UINTN) Buf;
|
||||
Handle->DebugCapabilityContext = (EFI_PHYSICAL_ADDRESS)(UINTN) DebugCapabilityContext;
|
||||
DebugCapabilityContext = (XHC_DC_CONTEXT *)(UINTN)Buf;
|
||||
Handle->DebugCapabilityContext = (EFI_PHYSICAL_ADDRESS)(UINTN)DebugCapabilityContext;
|
||||
|
||||
//
|
||||
// Initialize DbcInfoContext.
|
||||
@ -556,7 +558,7 @@ CreateDebugCapabilityContext (
|
||||
//
|
||||
// Update string descriptor address
|
||||
//
|
||||
String0Desc = (UINT8 *) AllocateAlignBuffer (STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN);
|
||||
String0Desc = (UINT8 *)AllocateAlignBuffer (STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN);
|
||||
ASSERT (String0Desc != NULL);
|
||||
ZeroMem (String0Desc, STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN);
|
||||
CopyMem (String0Desc, mString0Desc, STRING0_DESC_LEN);
|
||||
@ -596,12 +598,12 @@ CreateDebugCapabilityContext (
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCCP,
|
||||
XHC_LOW_32BIT((UINT64)(UINTN)DebugCapabilityContext)
|
||||
XHC_LOW_32BIT ((UINT64)(UINTN)DebugCapabilityContext)
|
||||
);
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCCP + 4,
|
||||
XHC_HIGH_32BIT((UINT64)(UINTN)DebugCapabilityContext)
|
||||
XHC_HIGH_32BIT ((UINT64)(UINTN)DebugCapabilityContext)
|
||||
);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -614,11 +616,11 @@ CreateDebugCapabilityContext (
|
||||
**/
|
||||
VOID
|
||||
XhcDetectDebugCapabilityReady (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
UINT64 TimeOut;
|
||||
volatile UINT32 Dcctrl;
|
||||
UINT64 TimeOut;
|
||||
volatile UINT32 Dcctrl;
|
||||
|
||||
TimeOut = 1;
|
||||
if (Handle->Initialized == USB3DBG_DBG_CAB) {
|
||||
@ -642,6 +644,7 @@ XhcDetectDebugCapabilityReady (
|
||||
Handle->Ready = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
MicroSecondDelay (XHC_POLL_DELAY);
|
||||
TimeOut--;
|
||||
} while (TimeOut != 0);
|
||||
@ -659,27 +662,28 @@ XhcDetectDebugCapabilityReady (
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
InitializeUsbDebugHardware (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
UINT8 *Buffer;
|
||||
UINTN Index;
|
||||
UINT8 TotalUsb3Port;
|
||||
EFI_PHYSICAL_ADDRESS XhciOpRegister;
|
||||
UINT32 Dcddi1;
|
||||
RETURN_STATUS Status;
|
||||
UINT8 *Buffer;
|
||||
UINTN Index;
|
||||
UINT8 TotalUsb3Port;
|
||||
EFI_PHYSICAL_ADDRESS XhciOpRegister;
|
||||
UINT32 Dcddi1;
|
||||
|
||||
XhciOpRegister = Handle->XhciOpRegister;
|
||||
TotalUsb3Port = MmioRead32 (((UINTN) Handle->XhciMmioBase + XHC_HCSPARAMS1_OFFSET)) >> 24;
|
||||
TotalUsb3Port = MmioRead32 (((UINTN)Handle->XhciMmioBase + XHC_HCSPARAMS1_OFFSET)) >> 24;
|
||||
|
||||
if (Handle->Initialized == USB3DBG_NOT_ENABLED) {
|
||||
Dcddi1 = XhcReadDebugReg (Handle,XHC_DC_DCDDI1);
|
||||
Dcddi1 = XhcReadDebugReg (Handle, XHC_DC_DCDDI1);
|
||||
if (Dcddi1 != (UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL)) {
|
||||
//
|
||||
// The debug capability has been reset by other code, return device error.
|
||||
//
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// If XHCI supports debug capability, hardware resource has been allocated,
|
||||
// but it has not been enabled, try to enable again.
|
||||
@ -718,8 +722,8 @@ InitializeUsbDebugHardware (
|
||||
//
|
||||
// Construct the buffer for read, poll and write.
|
||||
//
|
||||
Handle->UrbIn.Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer;
|
||||
Handle->Data = (EFI_PHYSICAL_ADDRESS)(UINTN) Buffer + XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;
|
||||
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;
|
||||
|
||||
//
|
||||
@ -739,16 +743,16 @@ InitializeUsbDebugHardware (
|
||||
// Init DCDDI1 and DCDDI2
|
||||
//
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCDDI1,
|
||||
(UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL)
|
||||
);
|
||||
Handle,
|
||||
XHC_DC_DCDDI1,
|
||||
(UINT32)((XHCI_DEBUG_DEVICE_VENDOR_ID << 16) | XHCI_DEBUG_DEVICE_PROTOCOL)
|
||||
);
|
||||
|
||||
XhcWriteDebugReg (
|
||||
Handle,
|
||||
XHC_DC_DCDDI2,
|
||||
(UINT32)((XHCI_DEBUG_DEVICE_REVISION << 16) | XHCI_DEBUG_DEVICE_PRODUCT_ID)
|
||||
);
|
||||
Handle,
|
||||
XHC_DC_DCDDI2,
|
||||
(UINT32)((XHCI_DEBUG_DEVICE_REVISION << 16) | XHCI_DEBUG_DEVICE_PRODUCT_ID)
|
||||
);
|
||||
|
||||
Enable:
|
||||
if ((Handle->Initialized == USB3DBG_NOT_ENABLED) && (!Handle->ChangePortPower)) {
|
||||
@ -775,7 +779,7 @@ Enable:
|
||||
Status = RETURN_SUCCESS;
|
||||
if (!Handle->Ready) {
|
||||
Handle->Initialized = USB3DBG_NOT_ENABLED;
|
||||
Status = RETURN_NOT_READY;
|
||||
Status = RETURN_NOT_READY;
|
||||
} else {
|
||||
Handle->Initialized = USB3DBG_ENABLED;
|
||||
}
|
||||
@ -791,16 +795,16 @@ Enable:
|
||||
**/
|
||||
VOID
|
||||
DiscoverInitializeUsbDebugPort (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
IN USB3_DEBUG_PORT_HANDLE *Handle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS XhciMmioBase;
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS XhciMmioBase;
|
||||
|
||||
//
|
||||
// Read 64-bit MMIO base address
|
||||
//
|
||||
XhciMmioBase = ProgramXhciBaseAddress ();
|
||||
XhciMmioBase = ProgramXhciBaseAddress ();
|
||||
Handle->XhciMmioBase = XhciMmioBase;
|
||||
|
||||
Status = CalculateUsbDebugPortMmioBase (Handle);
|
||||
@ -820,14 +824,14 @@ DiscoverInitializeUsbDebugPort (
|
||||
**/
|
||||
VOID
|
||||
SetUsb3DebugPortInstance (
|
||||
IN USB3_DEBUG_PORT_HANDLE *Instance
|
||||
IN USB3_DEBUG_PORT_HANDLE *Instance
|
||||
)
|
||||
{
|
||||
EFI_PHYSICAL_ADDRESS *AddrPtr;
|
||||
EFI_PHYSICAL_ADDRESS *AddrPtr;
|
||||
|
||||
AddrPtr = GetUsb3DebugPortInstanceAddrPtr ();
|
||||
ASSERT (AddrPtr != NULL);
|
||||
*AddrPtr = (EFI_PHYSICAL_ADDRESS) (UINTN) Instance;
|
||||
*AddrPtr = (EFI_PHYSICAL_ADDRESS)(UINTN)Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -839,13 +843,13 @@ GetUsb3DebugPortInstance (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_PHYSICAL_ADDRESS *AddrPtr;
|
||||
USB3_DEBUG_PORT_HANDLE *Instance;
|
||||
EFI_PHYSICAL_ADDRESS *AddrPtr;
|
||||
USB3_DEBUG_PORT_HANDLE *Instance;
|
||||
|
||||
AddrPtr = GetUsb3DebugPortInstanceAddrPtr ();
|
||||
ASSERT (AddrPtr != NULL);
|
||||
|
||||
Instance = (USB3_DEBUG_PORT_HANDLE *) (UINTN) *AddrPtr;
|
||||
Instance = (USB3_DEBUG_PORT_HANDLE *)(UINTN)*AddrPtr;
|
||||
|
||||
return Instance;
|
||||
}
|
||||
@ -870,17 +874,17 @@ GetUsb3DebugPortInstance (
|
||||
UINTN
|
||||
EFIAPI
|
||||
DebugPortReadBuffer (
|
||||
IN DEBUG_PORT_HANDLE Handle,
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes,
|
||||
IN UINTN Timeout
|
||||
IN DEBUG_PORT_HANDLE Handle,
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes,
|
||||
IN UINTN Timeout
|
||||
)
|
||||
{
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINT8 Index;
|
||||
UINT8 *Data;
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINT8 Index;
|
||||
UINT8 *Data;
|
||||
|
||||
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
|
||||
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -889,11 +893,12 @@ DebugPortReadBuffer (
|
||||
// If Handle is not NULL, use it and set the instance.
|
||||
//
|
||||
if (Handle != NULL) {
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *)Handle;
|
||||
SetUsb3DebugPortInstance (UsbDebugPortHandle);
|
||||
} else {
|
||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||
}
|
||||
|
||||
if (UsbDebugPortHandle == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@ -922,8 +927,10 @@ DebugPortReadBuffer (
|
||||
if ((Index + 1) >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Data[Index] = Data[Index + 1];
|
||||
}
|
||||
|
||||
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
|
||||
return 1;
|
||||
}
|
||||
@ -949,16 +956,16 @@ DebugPortReadBuffer (
|
||||
UINTN
|
||||
EFIAPI
|
||||
DebugPortWriteBuffer (
|
||||
IN DEBUG_PORT_HANDLE Handle,
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN DEBUG_PORT_HANDLE Handle,
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINTN Sent;
|
||||
UINTN Total;
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINTN Sent;
|
||||
UINTN Total;
|
||||
|
||||
if (NumberOfBytes == 0 || Buffer == NULL) {
|
||||
if ((NumberOfBytes == 0) || (Buffer == NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -970,11 +977,12 @@ DebugPortWriteBuffer (
|
||||
// If Handle is not NULL, use it and set the instance.
|
||||
//
|
||||
if (Handle != NULL) {
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *)Handle;
|
||||
SetUsb3DebugPortInstance (UsbDebugPortHandle);
|
||||
} else {
|
||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||
}
|
||||
|
||||
if (UsbDebugPortHandle == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@ -1001,6 +1009,7 @@ DebugPortWriteBuffer (
|
||||
} else {
|
||||
Sent = (UINT8)(NumberOfBytes - Total);
|
||||
}
|
||||
|
||||
XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT);
|
||||
Total += Sent;
|
||||
}
|
||||
@ -1024,22 +1033,23 @@ DebugPortWriteBuffer (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
DebugPortPollBuffer (
|
||||
IN DEBUG_PORT_HANDLE Handle
|
||||
IN DEBUG_PORT_HANDLE Handle
|
||||
)
|
||||
{
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINTN Length;
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
UINTN Length;
|
||||
|
||||
//
|
||||
// If Handle is NULL, get own instance.
|
||||
// If Handle is not NULL, use it and set the instance.
|
||||
//
|
||||
if (Handle != NULL) {
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
|
||||
UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *)Handle;
|
||||
SetUsb3DebugPortInstance (UsbDebugPortHandle);
|
||||
} else {
|
||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||
}
|
||||
|
||||
if (UsbDebugPortHandle == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1079,7 +1089,7 @@ DebugPortPollBuffer (
|
||||
//
|
||||
// Store data into internal buffer for use later
|
||||
//
|
||||
UsbDebugPortHandle->DataCount = (UINT8) Length;
|
||||
UsbDebugPortHandle->DataCount = (UINT8)Length;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1114,17 +1124,18 @@ DebugPortInitialize (
|
||||
IN DEBUG_PORT_CONTINUE Function
|
||||
)
|
||||
{
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
USB3_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
|
||||
|
||||
//
|
||||
// Validate the PCD PcdDebugPortHandleBufferSize value
|
||||
//
|
||||
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));
|
||||
|
||||
if (Function == NULL && Context != NULL) {
|
||||
SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *) Context);
|
||||
return (DEBUG_PORT_HANDLE) Context;
|
||||
if ((Function == NULL) && (Context != NULL)) {
|
||||
SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *)Context);
|
||||
return (DEBUG_PORT_HANDLE)Context;
|
||||
}
|
||||
|
||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||
if (UsbDebugPortHandle == NULL) {
|
||||
return NULL;
|
||||
@ -1133,8 +1144,8 @@ DebugPortInitialize (
|
||||
DiscoverInitializeUsbDebugPort (UsbDebugPortHandle);
|
||||
|
||||
if (Function != NULL) {
|
||||
Function (Context, (DEBUG_PORT_HANDLE) UsbDebugPortHandle);
|
||||
Function (Context, (DEBUG_PORT_HANDLE)UsbDebugPortHandle);
|
||||
}
|
||||
|
||||
return (DEBUG_PORT_HANDLE) UsbDebugPortHandle;
|
||||
return (DEBUG_PORT_HANDLE)UsbDebugPortHandle;
|
||||
}
|
||||
|
Reference in New Issue
Block a user