summaryrefslogtreecommitdiffstats
path: root/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:15 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitc1e126b1196de75e0a4cda21e4551ea9bb05e059 (patch)
treeda0e06602097dc7bb7e5a97a270d1834b6cf76e7 /SourceLevelDebugPkg/Library/DebugCommunicationLibUsb
parentb87864896714cf3062a7bc6d577d8fbd62d105e5 (diff)
downloadedk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.tar.gz
edk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.tar.bz2
edk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.zip
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>
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugCommunicationLibUsb')
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c520
1 files changed, 271 insertions, 249 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
index cc156baaa0..479757f5ba 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
@@ -18,144 +18,144 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
-#define SETUP_PID 0x2D
-#define INPUT_PID 0x69
-#define OUTPUT_PID 0xE1
-#define ERROR_PID 0x55
-#define DATA0_PID 0xC3
-#define DATA1_PID 0x4B
-#define DATA2_PID 0x87
-#define MDATA_PID 0x0F
-#define ACK_PID 0xD2
-#define NAK_PID 0x5A
-#define STALL_PID 0x1E
-#define NYET_PID 0x96
-
-#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
-#define USB_DEBUG_PORT_MAX_PACKET_SIZE 0x08
-
-#define USB_DEBUG_PORT_IN_USE BIT10
-#define USB_DEBUG_PORT_ENABLE BIT28
-#define USB_DEBUG_PORT_OWNER BIT30
-
-#define USB_PORT_LINE_STATUS_LS 0x400
-#define USB_PORT_LINE_STATUS_MASK 0xC00
+#define SETUP_PID 0x2D
+#define INPUT_PID 0x69
+#define OUTPUT_PID 0xE1
+#define ERROR_PID 0x55
+#define DATA0_PID 0xC3
+#define DATA1_PID 0x4B
+#define DATA2_PID 0x87
+#define MDATA_PID 0x0F
+#define ACK_PID 0xD2
+#define NAK_PID 0x5A
+#define STALL_PID 0x1E
+#define NYET_PID 0x96
+
+#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
+#define USB_DEBUG_PORT_MAX_PACKET_SIZE 0x08
+
+#define USB_DEBUG_PORT_IN_USE BIT10
+#define USB_DEBUG_PORT_ENABLE BIT28
+#define USB_DEBUG_PORT_OWNER BIT30
+
+#define USB_PORT_LINE_STATUS_LS 0x400
+#define USB_PORT_LINE_STATUS_MASK 0xC00
//
// Usb debug device descriptor, which is defined at
// USB2 Debug Device Specification.
//
typedef struct _USB_DEBUG_PORT_DESCRIPTOR {
- UINT8 Length;
- UINT8 DescriptorType;
- UINT8 DebugInEndpoint;
- UINT8 DebugOutEndpoint;
-}USB_DEBUG_PORT_DESCRIPTOR;
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT8 DebugInEndpoint;
+ UINT8 DebugOutEndpoint;
+} USB_DEBUG_PORT_DESCRIPTOR;
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbGetDebugDescriptor = {
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbGetDebugDescriptor = {
0x80,
USB_REQ_GET_DESCRIPTOR,
(UINT16)(0x0A << 8),
0x0000,
- sizeof(USB_DEBUG_PORT_DESCRIPTOR)
- };
+ sizeof (USB_DEBUG_PORT_DESCRIPTOR)
+};
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugFeature = {
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugFeature = {
0x0,
USB_REQ_SET_FEATURE,
(UINT16)(0x06),
0x0000,
0x0
- };
+};
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugAddress = {
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugAddress = {
0x0,
USB_REQ_SET_ADDRESS,
(UINT16)(0x7F),
0x0000,
0x0
- };
+};
//
// Usb debug port register file, which is defined at
// EHCI Specification.
//
typedef struct _USB_DEBUG_PORT_REGISTER {
- UINT32 ControlStatus;
- UINT8 TokenPid;
- UINT8 SendPid;
- UINT8 ReceivedPid;
- UINT8 Reserved1;
- UINT8 DataBuffer[8];
- UINT8 UsbEndPoint;
- UINT8 UsbAddress;
- UINT8 Reserved2;
- UINT8 Reserved3;
-}USB_DEBUG_PORT_REGISTER;
+ UINT32 ControlStatus;
+ UINT8 TokenPid;
+ UINT8 SendPid;
+ UINT8 ReceivedPid;
+ UINT8 Reserved1;
+ UINT8 DataBuffer[8];
+ UINT8 UsbEndPoint;
+ UINT8 UsbAddress;
+ UINT8 Reserved2;
+ UINT8 Reserved3;
+} USB_DEBUG_PORT_REGISTER;
//
// The state machine of usb debug port
//
-#define USBDBG_NO_DEV 0 // No device present at debug port
-#define USBDBG_NO_DBG_CAB 1 // The device attached is not usb debug cable
-#define USBDBG_DBG_CAB 2 // The device attached is usb debug cable
-#define USBDBG_INIT_DONE 4 // The usb debug cable device is initialized
-#define USBDBG_RESET 8 // The system is reset
+#define USBDBG_NO_DEV 0 // No device present at debug port
+#define USBDBG_NO_DBG_CAB 1 // The device attached is not usb debug cable
+#define USBDBG_DBG_CAB 2 // The device attached is usb debug cable
+#define USBDBG_INIT_DONE 4 // The usb debug cable device is initialized
+#define USBDBG_RESET 8 // The system is reset
#pragma pack(1)
//
// The internal data structure of DEBUG_PORT_HANDLE, which stores some
// important datum which are used across various phases.
//
-typedef struct _USB_DEBUG_PORT_HANDLE{
+typedef struct _USB_DEBUG_PORT_HANDLE {
//
// The usb debug port memory BAR number in EHCI configuration space.
//
- UINT8 DebugPortBarNumber;
- UINT8 Initialized;
+ UINT8 DebugPortBarNumber;
+ UINT8 Initialized;
//
// The offset of usb debug port registers in EHCI memory range.
//
- UINT16 DebugPortOffset;
+ UINT16 DebugPortOffset;
//
// The usb debug port memory BAR address.
//
- UINT32 UsbDebugPortMemoryBase;
+ UINT32 UsbDebugPortMemoryBase;
//
// The EHCI memory BAR address.
//
- UINT32 EhciMemoryBase;
+ UINT32 EhciMemoryBase;
//
// The usb debug device In endpoint.
//
- UINT8 InEndpoint;
+ UINT8 InEndpoint;
//
// The usb debug device Out endpoint.
//
- UINT8 OutEndpoint;
+ UINT8 OutEndpoint;
//
// The Bulk In endpoint toggle bit.
//
- UINT8 BulkInToggle;
+ UINT8 BulkInToggle;
//
// The Bulk Out endpoint toggle bit.
//
- UINT8 BulkOutToggle;
+ UINT8 BulkOutToggle;
//
// The available data length in the following data buffer.
//
- UINT8 DataCount;
+ UINT8 DataCount;
//
// The data buffer. Maximum length is 8 bytes.
//
- UINT8 Data[8];
+ UINT8 Data[8];
} USB_DEBUG_PORT_HANDLE;
#pragma pack()
//
// The global variable which can be used after memory is ready.
//
-USB_DEBUG_PORT_HANDLE mDebugCommunicationLibUsbDebugPortHandle;
+USB_DEBUG_PORT_HANDLE mDebugCommunicationLibUsbDebugPortHandle;
/**
Calculate the usb debug port bar address.
@@ -170,29 +170,29 @@ USB_DEBUG_PORT_HANDLE mDebugCommunicationLibUsbDebugPortHandle;
RETURN_STATUS
EFIAPI
CalculateUsbDebugPortBar (
- OUT UINT16 *DebugPortOffset,
- OUT UINT8 *DebugPortBarNumbar
- )
+ OUT UINT16 *DebugPortOffset,
+ OUT UINT8 *DebugPortBarNumbar
+ )
{
- UINT16 PciStatus;
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT8 ProgInterface;
- UINT8 SubClassCode;
- UINT8 BaseCode;
- UINT8 CapabilityPtr;
- UINT8 CapabilityId;
-
- VendorId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);
- DeviceId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);
+ UINT16 PciStatus;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 ProgInterface;
+ UINT8 SubClassCode;
+ UINT8 BaseCode;
+ UINT8 CapabilityPtr;
+ UINT8 CapabilityId;
+
+ VendorId = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);
+ DeviceId = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);
if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {
return RETURN_UNSUPPORTED;
}
- ProgInterface = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);
- SubClassCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);
- BaseCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);
+ ProgInterface = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);
+ SubClassCode = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);
+ BaseCode = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);
if ((ProgInterface != PCI_IF_EHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {
return RETURN_UNSUPPORTED;
@@ -201,7 +201,7 @@ CalculateUsbDebugPortBar (
//
// Enable Ehci Host Controller MMIO Space.
//
- PciStatus = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_PRIMARY_STATUS_OFFSET);
+ PciStatus = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_PRIMARY_STATUS_OFFSET);
if ((PciStatus & EFI_PCI_STATUS_CAPABILITY) == 0) {
//
@@ -213,17 +213,18 @@ CalculateUsbDebugPortBar (
//
// Get Pointer To Capability List
//
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + PCI_CAPBILITY_POINTER_OFFSET);
+ CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CAPBILITY_POINTER_OFFSET);
//
// Find Capability ID 0xA, Which Is For Debug Port
//
while (CapabilityPtr != 0) {
- CapabilityId = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr);
+ CapabilityId = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr);
if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {
break;
}
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 1);
+
+ CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 1);
}
//
@@ -236,8 +237,8 @@ CalculateUsbDebugPortBar (
//
// Get The Base Address Of Debug Port Register In Debug Port Capability Register
//
- *DebugPortOffset = (UINT16)(PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) & 0x1FFF);
- *DebugPortBarNumbar = (UINT8)((PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) >> 13) - 1);
+ *DebugPortOffset = (UINT16)(PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 2) & 0x1FFF);
+ *DebugPortBarNumbar = (UINT8)((PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 2) >> 13) - 1);
return RETURN_SUCCESS;
}
@@ -261,20 +262,21 @@ CalculateUsbDebugPortBar (
RETURN_STATUS
EFIAPI
UsbDebugPortIn (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN OUT UINT8 *Buffer,
- OUT UINT8 *Length,
- IN UINT8 Token,
- IN UINT8 Addr,
- IN UINT8 Ep,
- IN UINT8 DataToggle
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
+ IN OUT UINT8 *Buffer,
+ OUT UINT8 *Length,
+ IN UINT8 Token,
+ IN UINT8 Addr,
+ IN UINT8 Ep,
+ IN UINT8 DataToggle
)
{
- UINTN Index;
+ UINTN Index;
if (Length == NULL) {
return RETURN_INVALID_PARAMETER;
}
+
*Length = 0;
DebugPortRegister->TokenPid = Token;
@@ -290,19 +292,20 @@ UsbDebugPortIn (
//
// Clearing W/R bit to indicate it's a READ operation
//
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~BIT4);
+ MmioAnd32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32) ~BIT4);
//
// Setting GO bit as well as clearing DONE bit
//
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)BIT5);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32)BIT5);
//
// Wait for completing the request
//
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
+ while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ {
return RETURN_DEVICE_ERROR;
}
}
@@ -310,23 +313,23 @@ UsbDebugPortIn (
//
// Clearing DONE bit by writing 1
//
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT16);
//
// Check if the request is executed successfully or not.
//
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
return RETURN_DEVICE_ERROR;
}
//
// Make sure the received data are not beyond the allowable maximum length - 8 byte
//
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
+ if (((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
return RETURN_DEVICE_ERROR;
}
- *Length = (UINT8)(MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & 0xF);
+ *Length = (UINT8)(MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & 0xF);
if (*Length > 8) {
return RETURN_DEVICE_ERROR;
}
@@ -334,6 +337,7 @@ UsbDebugPortIn (
for (Index = 0; Index < *Length; Index++) {
Buffer[Index] = DebugPortRegister->DataBuffer[Index];
}
+
return RETURN_SUCCESS;
}
@@ -356,16 +360,16 @@ UsbDebugPortIn (
RETURN_STATUS
EFIAPI
UsbDebugPortOut (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN UINT8 *Buffer,
- IN UINT8 Length,
- IN UINT8 Token,
- IN UINT8 Addr,
- IN UINT8 Ep,
- IN UINT8 DataToggle
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
+ IN UINT8 *Buffer,
+ IN UINT8 Length,
+ IN UINT8 Token,
+ IN UINT8 Addr,
+ IN UINT8 Ep,
+ IN UINT8 DataToggle
)
{
- UINT8 Index;
+ UINT8 Index;
if (Length > 8) {
return RETURN_INVALID_PARAMETER;
@@ -377,14 +381,15 @@ UsbDebugPortOut (
} else {
DebugPortRegister->SendPid = DATA0_PID;
}
+
DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
//
// Fill in the data length and corresponding data.
//
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~0xF);
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, Length & 0xF);
+ MmioAnd32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32) ~0xF);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, Length & 0xF);
for (Index = 0; Index < Length; Index++) {
DebugPortRegister->DataBuffer[Index] = Buffer[Index];
}
@@ -392,18 +397,19 @@ UsbDebugPortOut (
//
// Setting W/R bit to indicate it's a WRITE operation
//
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT4);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT4);
//
// Setting GO bit as well as clearing DONE bit
//
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT5);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT5);
//
// Wait for completing the request
//
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
+ while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ {
return RETURN_DEVICE_ERROR;
}
}
@@ -411,19 +417,19 @@ UsbDebugPortOut (
//
// Clearing DONE bit by writing 1
//
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT16);
//
// Check if the request is executed successfully or not.
//
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
return RETURN_DEVICE_ERROR;
}
//
// Make sure the sent data are not beyond the allowable maximum length - 8 byte
//
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
+ if (((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
return RETURN_DEVICE_ERROR;
}
@@ -448,23 +454,23 @@ UsbDebugPortOut (
RETURN_STATUS
EFIAPI
UsbDebugPortControlTransfer (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN USB_DEVICE_REQUEST *SetupPacket,
- IN UINT8 Addr,
- IN UINT8 Ep,
- OUT UINT8 *Data,
- IN OUT UINT8 *DataLength
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
+ IN USB_DEVICE_REQUEST *SetupPacket,
+ IN UINT8 Addr,
+ IN UINT8 Ep,
+ OUT UINT8 *Data,
+ IN OUT UINT8 *DataLength
)
{
- RETURN_STATUS Status;
- UINT8 Temp;
- UINT8 ReturnStatus[8];
+ RETURN_STATUS Status;
+ UINT8 Temp;
+ UINT8 ReturnStatus[8];
//
// Setup Phase
//
- Status = UsbDebugPortOut(DebugPortRegister, (UINT8 *)SetupPacket, (UINT8)sizeof(USB_DEVICE_REQUEST), SETUP_PID, Addr, Ep, 0);
- if (RETURN_ERROR(Status)) {
+ Status = UsbDebugPortOut (DebugPortRegister, (UINT8 *)SetupPacket, (UINT8)sizeof (USB_DEVICE_REQUEST), SETUP_PID, Addr, Ep, 0);
+ if (RETURN_ERROR (Status)) {
return Status;
}
@@ -476,16 +482,16 @@ UsbDebugPortControlTransfer (
//
// Get Data From Device
//
- Status = UsbDebugPortIn(DebugPortRegister, Data, DataLength, INPUT_PID, Addr, Ep, 1);
- if (RETURN_ERROR(Status)) {
+ Status = UsbDebugPortIn (DebugPortRegister, Data, DataLength, INPUT_PID, Addr, Ep, 1);
+ if (RETURN_ERROR (Status)) {
return Status;
}
} else {
//
// Send Data To Device
//
- Status = UsbDebugPortOut(DebugPortRegister, Data, *DataLength, OUTPUT_PID, Addr, Ep, 1);
- if (RETURN_ERROR(Status)) {
+ Status = UsbDebugPortOut (DebugPortRegister, Data, *DataLength, OUTPUT_PID, Addr, Ep, 1);
+ if (RETURN_ERROR (Status)) {
return Status;
}
}
@@ -498,12 +504,12 @@ UsbDebugPortControlTransfer (
//
// For READ operation, Data Toggle in Status Phase Should be 1.
//
- Status = UsbDebugPortOut(DebugPortRegister, NULL, 0, OUTPUT_PID, Addr, Ep, 1);
+ Status = UsbDebugPortOut (DebugPortRegister, NULL, 0, OUTPUT_PID, Addr, Ep, 1);
} else {
//
// For WRITE operation, Data Toggle in Status Phase Should be 1.
//
- Status = UsbDebugPortIn(DebugPortRegister, ReturnStatus, &Temp, INPUT_PID, Addr, Ep, 1);
+ Status = UsbDebugPortIn (DebugPortRegister, ReturnStatus, &Temp, INPUT_PID, Addr, Ep, 1);
}
return Status;
@@ -524,37 +530,37 @@ UsbDebugPortControlTransfer (
**/
BOOLEAN
EFIAPI
-NeedReinitializeHardware(
- IN USB_DEBUG_PORT_HANDLE *Handle
+NeedReinitializeHardware (
+ IN USB_DEBUG_PORT_HANDLE *Handle
)
{
- UINT16 PciCmd;
- UINT32 UsbDebugPortMemoryBase;
- UINT32 EhciMemoryBase;
- BOOLEAN Status;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
+ UINT16 PciCmd;
+ UINT32 UsbDebugPortMemoryBase;
+ UINT32 EhciMemoryBase;
+ BOOLEAN Status;
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
Status = FALSE;
- EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
+ EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
if (EhciMemoryBase != Handle->EhciMemoryBase) {
Handle->EhciMemoryBase = EhciMemoryBase;
- Status = TRUE;
+ Status = TRUE;
}
- UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle->DebugPortBarNumber * 4);
+ UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle->DebugPortBarNumber * 4);
if (UsbDebugPortMemoryBase != Handle->UsbDebugPortMemoryBase) {
Handle->UsbDebugPortMemoryBase = UsbDebugPortMemoryBase;
- Status = TRUE;
+ Status = TRUE;
}
//
// Enable Ehci Memory Space Access
//
- PciCmd = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET);
+ PciCmd = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + 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(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);
+ PciWrite16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);
Status = TRUE;
}
@@ -562,8 +568,9 @@ NeedReinitializeHardware(
// If the owner and in_use bit is not set, it means system is doing cold/warm boot or EHCI host controller is reset by system software.
//
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE)) {
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
+ {
Status = TRUE;
}
@@ -572,6 +579,7 @@ NeedReinitializeHardware(
} else if (Handle->Initialized != USBDBG_INIT_DONE) {
Status = TRUE;
}
+
return Status;
}
@@ -593,88 +601,94 @@ NeedReinitializeHardware(
RETURN_STATUS
EFIAPI
InitializeUsbDebugHardware (
- IN USB_DEBUG_PORT_HANDLE *Handle
-)
+ IN USB_DEBUG_PORT_HANDLE *Handle
+ )
{
- RETURN_STATUS Status;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- USB_DEBUG_PORT_DESCRIPTOR UsbDebugPortDescriptor;
- UINT32 *PortStatus;
- UINT32 *UsbCmd;
- UINT32 *UsbStatus;
- UINT32 *UsbHCSParam;
- UINT8 DebugPortNumber;
- UINT8 Length;
+ RETURN_STATUS Status;
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
+ USB_DEBUG_PORT_DESCRIPTOR UsbDebugPortDescriptor;
+ UINT32 *PortStatus;
+ UINT32 *UsbCmd;
+ UINT32 *UsbStatus;
+ UINT32 *UsbHCSParam;
+ UINT8 DebugPortNumber;
+ UINT8 Length;
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
- UsbHCSParam = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x04);
- UsbCmd = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x20);
- UsbStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x24);
+ UsbHCSParam = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x04);
+ UsbCmd = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x20);
+ UsbStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x24);
//
// Check if the debug port is enabled and owned by myself.
//
- if (((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET)) {
+ if (((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET))
+ {
DEBUG ((
DEBUG_INFO,
"UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",
- MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)
+ MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus)
));
//
// If the host controller is halted, then reset and restart it.
//
- if ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0) {
+ if ((MmioRead32 ((UINTN)UsbStatus) & BIT12) != 0) {
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the host controller.\n"));
//
// reset the host controller.
//
- MmioOr32((UINTN)UsbCmd, BIT1);
+ MmioOr32 ((UINTN)UsbCmd, BIT1);
//
// ensure that the host controller is reset.
//
- while ((MmioRead32((UINTN)UsbCmd) & BIT1) != 0);
+ while ((MmioRead32 ((UINTN)UsbCmd) & BIT1) != 0) {
+ }
- MmioOr32((UINTN)UsbCmd, BIT0);
+ MmioOr32 ((UINTN)UsbCmd, BIT0);
// ensure that the host controller is started (HALTED bit must be cleared)
- while ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0);
+ while ((MmioRead32 ((UINTN)UsbStatus) & BIT12) != 0) {
+ }
}
//
// First get the ownership of port 0.
//
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE);
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE);
MicroSecondDelay (200000);
}
+
//
// Find out which port is used as debug port.
//
- DebugPortNumber = (UINT8)((MmioRead32((UINTN)UsbHCSParam) & 0x00F00000) >> 20);
+ DebugPortNumber = (UINT8)((MmioRead32 ((UINTN)UsbHCSParam) & 0x00F00000) >> 20);
//
// Should find a device is connected at debug port
//
PortStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x64 + (DebugPortNumber - 1) * 4);
- if (!(MmioRead32((UINTN)PortStatus) & BIT0)) {
+ if (!(MmioRead32 ((UINTN)PortStatus) & BIT0)) {
Handle->Initialized = USBDBG_NO_DEV;
return RETURN_NOT_FOUND;
}
- if (Handle->Initialized != USBDBG_INIT_DONE ||
- (MmioRead32 ((UINTN) &UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0) {
+ if ((Handle->Initialized != USBDBG_INIT_DONE) ||
+ ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0))
+ {
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the debug port.\n"));
//
// Reset the debug port
//
- MmioOr32((UINTN)PortStatus, BIT8);
+ MmioOr32 ((UINTN)PortStatus, BIT8);
MicroSecondDelay (500000);
- MmioAnd32((UINTN)PortStatus, (UINT32)~BIT8);
- while (MmioRead32((UINTN)PortStatus) & BIT8);
+ MmioAnd32 ((UINTN)PortStatus, (UINT32) ~BIT8);
+ while (MmioRead32 ((UINTN)PortStatus) & BIT8) {
+ }
//
// The port enabled bit should be set by HW.
//
- if ((MmioRead32((UINTN)PortStatus) & BIT2) == 0) {
+ if ((MmioRead32 ((UINTN)PortStatus) & BIT2) == 0) {
Handle->Initialized = USBDBG_NO_DBG_CAB;
return RETURN_DEVICE_ERROR;
}
@@ -682,7 +696,7 @@ InitializeUsbDebugHardware (
//
// Enable Usb Debug Port Capability
//
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_ENABLE);
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_ENABLE);
//
// initialize the data toggle used by bulk in/out endpoint.
@@ -694,7 +708,7 @@ InitializeUsbDebugHardware (
// set usb debug device address as 0x7F.
//
Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbSetDebugAddress, 0x0, 0x0, NULL, NULL);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
//
// The device can not work well.
//
@@ -710,8 +724,8 @@ InitializeUsbDebugHardware (
//
// Get debug descriptor.
//
- Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbGetDebugDescriptor, 0x7F, 0x0, (UINT8*)&UsbDebugPortDescriptor, &Length);
- if (RETURN_ERROR(Status)) {
+ Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbGetDebugDescriptor, 0x7F, 0x0, (UINT8 *)&UsbDebugPortDescriptor, &Length);
+ if (RETURN_ERROR (Status)) {
//
// The device is not a usb debug device.
//
@@ -719,7 +733,7 @@ InitializeUsbDebugHardware (
return Status;
}
- if (Length != sizeof(USB_DEBUG_PORT_DESCRIPTOR)) {
+ if (Length != sizeof (USB_DEBUG_PORT_DESCRIPTOR)) {
Handle->Initialized = USBDBG_NO_DBG_CAB;
return RETURN_DEVICE_ERROR;
}
@@ -734,7 +748,7 @@ InitializeUsbDebugHardware (
// enable the usb debug feature.
//
Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbSetDebugFeature, 0x7F, 0x0, NULL, NULL);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
//
// The device can not work well.
//
@@ -773,17 +787,17 @@ InitializeUsbDebugHardware (
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
)
{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- RETURN_STATUS Status;
- UINT8 Index;
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
+ RETURN_STATUS Status;
+ UINT8 Index;
- if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
+ if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
return 0;
}
@@ -797,9 +811,9 @@ DebugPortReadBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
return 0;
}
}
@@ -815,8 +829,10 @@ DebugPortReadBuffer (
if ((Index + 1) >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {
return 0;
}
+
UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Index + 1];
}
+
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
return 1;
}
@@ -842,19 +858,19 @@ 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
)
{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- RETURN_STATUS Status;
- UINT8 Sent;
- UINTN Total;
- UINT8 ReceivedPid;
-
- if (NumberOfBytes == 0 || Buffer == NULL) {
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
+ RETURN_STATUS Status;
+ UINT8 Sent;
+ UINTN Total;
+ UINT8 ReceivedPid;
+
+ if ((NumberOfBytes == 0) || (Buffer == NULL)) {
return 0;
}
@@ -871,9 +887,9 @@ DebugPortWriteBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
return 0;
}
}
@@ -887,13 +903,13 @@ DebugPortWriteBuffer (
Sent = (UINT8)(NumberOfBytes - Total);
}
- Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle);
+ Status = UsbDebugPortOut (UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
return Total;
}
- ReceivedPid = (MmioRead8((UINTN)&UsbDebugPortRegister->ReceivedPid));
+ ReceivedPid = (MmioRead8 ((UINTN)&UsbDebugPortRegister->ReceivedPid));
//
// If received a NAK_PID on write transaction, it means the usb debug device is busy and can not handle this transaction.
// should send the packet again.
@@ -903,8 +919,10 @@ DebugPortWriteBuffer (
} else {
UsbDebugPortHandle->BulkOutToggle ^= 1;
}
+
Total += Sent;
}
+
return Total;
}
@@ -924,14 +942,14 @@ DebugPortWriteBuffer (
BOOLEAN
EFIAPI
DebugPortPollBuffer (
- IN DEBUG_PORT_HANDLE Handle
+ IN DEBUG_PORT_HANDLE Handle
)
{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- UINT8 Length;
- UINT8 Index;
- RETURN_STATUS Status;
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
+ UINT8 Length;
+ UINT8 Index;
+ RETURN_STATUS Status;
//
// If Handle is NULL, it means memory is ready for use.
@@ -943,9 +961,9 @@ DebugPortPollBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
- Status = InitializeUsbDebugHardware(UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {
+ Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
+ if (RETURN_ERROR (Status)) {
return FALSE;
}
}
@@ -962,37 +980,39 @@ DebugPortPollBuffer (
UsbDebugPortRegister->TokenPid = INPUT_PID;
if (UsbDebugPortHandle->BulkInToggle == 0) {
- UsbDebugPortRegister->SendPid = DATA0_PID;
+ UsbDebugPortRegister->SendPid = DATA0_PID;
} else {
- UsbDebugPortRegister->SendPid = DATA1_PID;
+ UsbDebugPortRegister->SendPid = DATA1_PID;
}
+
UsbDebugPortRegister->UsbAddress = 0x7F;
UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;
//
// Clearing W/R bit to indicate it's a READ operation
//
- MmioAnd32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)~BIT4);
+ MmioAnd32 ((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32) ~BIT4);
//
// Setting GO bit as well as clearing DONE bit
//
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)BIT5);
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)BIT5);
//
// Wait for completing the request
//
- while ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
+ while ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
+ {
return FALSE;
}
}
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)) & BIT6) {
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus)) & BIT6) {
return FALSE;
}
- Length = (UINT8)(MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & 0xF);
+ Length = (UINT8)(MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & 0xF);
if (Length > 8) {
return FALSE;
@@ -1007,6 +1027,7 @@ DebugPortPollBuffer (
for (Index = 0; Index < Length; Index++) {
UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];
}
+
UsbDebugPortHandle->DataCount = Length;
return TRUE;
@@ -1043,51 +1064,52 @@ DebugPortInitialize (
IN DEBUG_PORT_CONTINUE Function
)
{
- RETURN_STATUS Status;
- USB_DEBUG_PORT_HANDLE Handle;
+ RETURN_STATUS Status;
+ USB_DEBUG_PORT_HANDLE Handle;
//
// Validate the PCD PcdDebugPortHandleBufferSize value
//
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB_DEBUG_PORT_HANDLE));
- if (Function == NULL && Context != NULL) {
- return (DEBUG_PORT_HANDLE *) Context;
+ if ((Function == NULL) && (Context != NULL)) {
+ return (DEBUG_PORT_HANDLE *)Context;
}
- ZeroMem(&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
- Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
+ ZeroMem (&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
+
+ Status = CalculateUsbDebugPortBar (&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
if (RETURN_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "UsbDbg: the pci device pointed by PcdUsbEhciPciAddress is not EHCI host controller or does not support debug port capability!\n"));
goto Exit;
}
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
+ Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
if (Handle.EhciMemoryBase == 0) {
//
// Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero
//
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, PcdGet32(PcdUsbEhciMemorySpaceBase));
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
+ PciWrite32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, PcdGet32 (PcdUsbEhciMemorySpaceBase));
+ Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
}
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
+ Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
if (Handle.UsbDebugPortMemoryBase == 0) {
//
// Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero
//
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4, PcdGet32(PcdUsbDebugPortMemorySpaceBase));
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
+ PciWrite32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4, PcdGet32 (PcdUsbDebugPortMemorySpaceBase));
+ Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
}
Handle.Initialized = USBDBG_RESET;
- if (NeedReinitializeHardware(&Handle)) {
+ if (NeedReinitializeHardware (&Handle)) {
DEBUG ((DEBUG_ERROR, "UsbDbg: Start EHCI debug port initialization!\n"));
Status = InitializeUsbDebugHardware (&Handle);
- if (RETURN_ERROR(Status)) {
+ if (RETURN_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "UsbDbg: Failed, please check if USB debug cable is plugged into EHCI debug port correctly!\n"));
goto Exit;
}
@@ -1098,7 +1120,7 @@ Exit:
if (Function != NULL) {
Function (Context, &Handle);
} else {
- CopyMem(&mDebugCommunicationLibUsbDebugPortHandle, &Handle, sizeof (USB_DEBUG_PORT_HANDLE));
+ CopyMem (&mDebugCommunicationLibUsbDebugPortHandle, &Handle, sizeof (USB_DEBUG_PORT_HANDLE));
}
return (DEBUG_PORT_HANDLE)(UINTN)&mDebugCommunicationLibUsbDebugPortHandle;