#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
\r
-#define SETUP_PID 0x2D\r
-#define INPUT_PID 0x69\r
-#define OUTPUT_PID 0xE1\r
-#define ERROR_PID 0x55\r
-#define DATA0_PID 0xC3\r
-#define DATA1_PID 0x4B\r
-#define DATA2_PID 0x87\r
-#define MDATA_PID 0x0F\r
-#define ACK_PID 0xD2\r
-#define NAK_PID 0x5A\r
-#define STALL_PID 0x1E\r
-#define NYET_PID 0x96\r
-\r
-#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A\r
-#define USB_DEBUG_PORT_MAX_PACKET_SIZE 0x08\r
-\r
-#define USB_DEBUG_PORT_IN_USE BIT10\r
-#define USB_DEBUG_PORT_ENABLE BIT28\r
-#define USB_DEBUG_PORT_OWNER BIT30\r
-\r
-#define USB_PORT_LINE_STATUS_LS 0x400\r
-#define USB_PORT_LINE_STATUS_MASK 0xC00\r
+#define SETUP_PID 0x2D\r
+#define INPUT_PID 0x69\r
+#define OUTPUT_PID 0xE1\r
+#define ERROR_PID 0x55\r
+#define DATA0_PID 0xC3\r
+#define DATA1_PID 0x4B\r
+#define DATA2_PID 0x87\r
+#define MDATA_PID 0x0F\r
+#define ACK_PID 0xD2\r
+#define NAK_PID 0x5A\r
+#define STALL_PID 0x1E\r
+#define NYET_PID 0x96\r
+\r
+#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A\r
+#define USB_DEBUG_PORT_MAX_PACKET_SIZE 0x08\r
+\r
+#define USB_DEBUG_PORT_IN_USE BIT10\r
+#define USB_DEBUG_PORT_ENABLE BIT28\r
+#define USB_DEBUG_PORT_OWNER BIT30\r
+\r
+#define USB_PORT_LINE_STATUS_LS 0x400\r
+#define USB_PORT_LINE_STATUS_MASK 0xC00\r
\r
//\r
// Usb debug device descriptor, which is defined at\r
// USB2 Debug Device Specification.\r
//\r
typedef struct _USB_DEBUG_PORT_DESCRIPTOR {\r
- UINT8 Length;\r
- UINT8 DescriptorType;\r
- UINT8 DebugInEndpoint;\r
- UINT8 DebugOutEndpoint;\r
-}USB_DEBUG_PORT_DESCRIPTOR;\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ UINT8 DebugInEndpoint;\r
+ UINT8 DebugOutEndpoint;\r
+} USB_DEBUG_PORT_DESCRIPTOR;\r
\r
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbGetDebugDescriptor = {\r
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbGetDebugDescriptor = {\r
0x80,\r
USB_REQ_GET_DESCRIPTOR,\r
(UINT16)(0x0A << 8),\r
0x0000,\r
- sizeof(USB_DEBUG_PORT_DESCRIPTOR)\r
- };\r
+ sizeof (USB_DEBUG_PORT_DESCRIPTOR)\r
+};\r
\r
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugFeature = {\r
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugFeature = {\r
0x0,\r
USB_REQ_SET_FEATURE,\r
(UINT16)(0x06),\r
0x0000,\r
0x0\r
- };\r
+};\r
\r
-USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugAddress = {\r
+USB_DEVICE_REQUEST mDebugCommunicationLibUsbSetDebugAddress = {\r
0x0,\r
USB_REQ_SET_ADDRESS,\r
(UINT16)(0x7F),\r
0x0000,\r
0x0\r
- };\r
+};\r
\r
//\r
// Usb debug port register file, which is defined at\r
// EHCI Specification.\r
//\r
typedef struct _USB_DEBUG_PORT_REGISTER {\r
- UINT32 ControlStatus;\r
- UINT8 TokenPid;\r
- UINT8 SendPid;\r
- UINT8 ReceivedPid;\r
- UINT8 Reserved1;\r
- UINT8 DataBuffer[8];\r
- UINT8 UsbEndPoint;\r
- UINT8 UsbAddress;\r
- UINT8 Reserved2;\r
- UINT8 Reserved3;\r
-}USB_DEBUG_PORT_REGISTER;\r
+ UINT32 ControlStatus;\r
+ UINT8 TokenPid;\r
+ UINT8 SendPid;\r
+ UINT8 ReceivedPid;\r
+ UINT8 Reserved1;\r
+ UINT8 DataBuffer[8];\r
+ UINT8 UsbEndPoint;\r
+ UINT8 UsbAddress;\r
+ UINT8 Reserved2;\r
+ UINT8 Reserved3;\r
+} USB_DEBUG_PORT_REGISTER;\r
\r
//\r
// The state machine of usb debug port\r
//\r
-#define USBDBG_NO_DEV 0 // No device present at debug port\r
-#define USBDBG_NO_DBG_CAB 1 // The device attached is not usb debug cable\r
-#define USBDBG_DBG_CAB 2 // The device attached is usb debug cable\r
-#define USBDBG_INIT_DONE 4 // The usb debug cable device is initialized\r
-#define USBDBG_RESET 8 // The system is reset\r
+#define USBDBG_NO_DEV 0 // No device present at debug port\r
+#define USBDBG_NO_DBG_CAB 1 // The device attached is not usb debug cable\r
+#define USBDBG_DBG_CAB 2 // The device attached is usb debug cable\r
+#define USBDBG_INIT_DONE 4 // The usb debug cable device is initialized\r
+#define USBDBG_RESET 8 // The system is reset\r
\r
#pragma pack(1)\r
//\r
// The internal data structure of DEBUG_PORT_HANDLE, which stores some\r
// important datum which are used across various phases.\r
//\r
-typedef struct _USB_DEBUG_PORT_HANDLE{\r
+typedef struct _USB_DEBUG_PORT_HANDLE {\r
//\r
// The usb debug port memory BAR number in EHCI configuration space.\r
//\r
- UINT8 DebugPortBarNumber;\r
- UINT8 Initialized;\r
+ UINT8 DebugPortBarNumber;\r
+ UINT8 Initialized;\r
//\r
// The offset of usb debug port registers in EHCI memory range.\r
//\r
- UINT16 DebugPortOffset;\r
+ UINT16 DebugPortOffset;\r
//\r
// The usb debug port memory BAR address.\r
//\r
- UINT32 UsbDebugPortMemoryBase;\r
+ UINT32 UsbDebugPortMemoryBase;\r
//\r
// The EHCI memory BAR address.\r
//\r
- UINT32 EhciMemoryBase;\r
+ UINT32 EhciMemoryBase;\r
//\r
// The usb debug device In endpoint.\r
//\r
- UINT8 InEndpoint;\r
+ UINT8 InEndpoint;\r
//\r
// The usb debug device Out endpoint.\r
//\r
- UINT8 OutEndpoint;\r
+ UINT8 OutEndpoint;\r
//\r
// The Bulk In endpoint toggle bit.\r
//\r
- UINT8 BulkInToggle;\r
+ UINT8 BulkInToggle;\r
//\r
// The Bulk Out endpoint toggle bit.\r
//\r
- UINT8 BulkOutToggle;\r
+ UINT8 BulkOutToggle;\r
//\r
// The available data length in the following data buffer.\r
//\r
- UINT8 DataCount;\r
+ UINT8 DataCount;\r
//\r
// The data buffer. Maximum length is 8 bytes.\r
//\r
- UINT8 Data[8];\r
+ UINT8 Data[8];\r
} USB_DEBUG_PORT_HANDLE;\r
#pragma pack()\r
\r
//\r
// The global variable which can be used after memory is ready.\r
//\r
-USB_DEBUG_PORT_HANDLE mDebugCommunicationLibUsbDebugPortHandle;\r
+USB_DEBUG_PORT_HANDLE mDebugCommunicationLibUsbDebugPortHandle;\r
\r
/**\r
Calculate the usb debug port bar address.\r
RETURN_STATUS\r
EFIAPI\r
CalculateUsbDebugPortBar (\r
- OUT UINT16 *DebugPortOffset,\r
- OUT UINT8 *DebugPortBarNumbar\r
- )\r
+ OUT UINT16 *DebugPortOffset,\r
+ OUT UINT8 *DebugPortBarNumbar\r
+ )\r
{\r
- UINT16 PciStatus;\r
- UINT16 VendorId;\r
- UINT16 DeviceId;\r
- UINT8 ProgInterface;\r
- UINT8 SubClassCode;\r
- UINT8 BaseCode;\r
- UINT8 CapabilityPtr;\r
- UINT8 CapabilityId;\r
-\r
- VendorId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);\r
- DeviceId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);\r
+ UINT16 PciStatus;\r
+ UINT16 VendorId;\r
+ UINT16 DeviceId;\r
+ UINT8 ProgInterface;\r
+ UINT8 SubClassCode;\r
+ UINT8 BaseCode;\r
+ UINT8 CapabilityPtr;\r
+ UINT8 CapabilityId;\r
+\r
+ VendorId = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);\r
+ DeviceId = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);\r
\r
if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {\r
return RETURN_UNSUPPORTED;\r
}\r
\r
- ProgInterface = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);\r
- SubClassCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);\r
- BaseCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);\r
+ ProgInterface = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);\r
+ SubClassCode = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);\r
+ BaseCode = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);\r
\r
if ((ProgInterface != PCI_IF_EHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {\r
return RETURN_UNSUPPORTED;\r
//\r
// Enable Ehci Host Controller MMIO Space.\r
//\r
- PciStatus = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_PRIMARY_STATUS_OFFSET);\r
+ PciStatus = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_PRIMARY_STATUS_OFFSET);\r
\r
if ((PciStatus & EFI_PCI_STATUS_CAPABILITY) == 0) {\r
//\r
//\r
// Get Pointer To Capability List\r
//\r
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + PCI_CAPBILITY_POINTER_OFFSET);\r
+ CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_CAPBILITY_POINTER_OFFSET);\r
\r
//\r
// Find Capability ID 0xA, Which Is For Debug Port\r
//\r
while (CapabilityPtr != 0) {\r
- CapabilityId = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr);\r
+ CapabilityId = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr);\r
if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {\r
break;\r
}\r
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 1);\r
+\r
+ CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 1);\r
}\r
\r
//\r
//\r
// Get The Base Address Of Debug Port Register In Debug Port Capability Register\r
//\r
- *DebugPortOffset = (UINT16)(PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) & 0x1FFF);\r
- *DebugPortBarNumbar = (UINT8)((PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) >> 13) - 1);\r
+ *DebugPortOffset = (UINT16)(PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 2) & 0x1FFF);\r
+ *DebugPortBarNumbar = (UINT8)((PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 2) >> 13) - 1);\r
\r
return RETURN_SUCCESS;\r
}\r
RETURN_STATUS\r
EFIAPI\r
UsbDebugPortIn (\r
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
- IN OUT UINT8 *Buffer,\r
- OUT UINT8 *Length,\r
- IN UINT8 Token,\r
- IN UINT8 Addr,\r
- IN UINT8 Ep,\r
- IN UINT8 DataToggle\r
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
+ IN OUT UINT8 *Buffer,\r
+ OUT UINT8 *Length,\r
+ IN UINT8 Token,\r
+ IN UINT8 Addr,\r
+ IN UINT8 Ep,\r
+ IN UINT8 DataToggle\r
)\r
{\r
- UINTN Index;\r
+ UINTN Index;\r
\r
if (Length == NULL) {\r
return RETURN_INVALID_PARAMETER;\r
}\r
+\r
*Length = 0;\r
\r
DebugPortRegister->TokenPid = Token;\r
//\r
// Clearing W/R bit to indicate it's a READ operation\r
//\r
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~BIT4);\r
+ MmioAnd32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32) ~BIT4);\r
\r
//\r
// Setting GO bit as well as clearing DONE bit\r
//\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)BIT5);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32)BIT5);\r
\r
//\r
// Wait for completing the request\r
//\r
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {\r
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {\r
+ while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {\r
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ {\r
return RETURN_DEVICE_ERROR;\r
}\r
}\r
//\r
// Clearing DONE bit by writing 1\r
//\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT16);\r
\r
//\r
// Check if the request is executed successfully or not.\r
//\r
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {\r
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {\r
return RETURN_DEVICE_ERROR;\r
}\r
\r
//\r
// Make sure the received data are not beyond the allowable maximum length - 8 byte\r
//\r
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {\r
+ if (((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {\r
return RETURN_DEVICE_ERROR;\r
}\r
\r
- *Length = (UINT8)(MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & 0xF);\r
+ *Length = (UINT8)(MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & 0xF);\r
if (*Length > 8) {\r
return RETURN_DEVICE_ERROR;\r
}\r
for (Index = 0; Index < *Length; Index++) {\r
Buffer[Index] = DebugPortRegister->DataBuffer[Index];\r
}\r
+\r
return RETURN_SUCCESS;\r
}\r
\r
RETURN_STATUS\r
EFIAPI\r
UsbDebugPortOut (\r
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
- IN UINT8 *Buffer,\r
- IN UINT8 Length,\r
- IN UINT8 Token,\r
- IN UINT8 Addr,\r
- IN UINT8 Ep,\r
- IN UINT8 DataToggle\r
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
+ IN UINT8 *Buffer,\r
+ IN UINT8 Length,\r
+ IN UINT8 Token,\r
+ IN UINT8 Addr,\r
+ IN UINT8 Ep,\r
+ IN UINT8 DataToggle\r
)\r
{\r
- UINT8 Index;\r
+ UINT8 Index;\r
\r
if (Length > 8) {\r
return RETURN_INVALID_PARAMETER;\r
} else {\r
DebugPortRegister->SendPid = DATA0_PID;\r
}\r
+\r
DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);\r
DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);\r
\r
//\r
// Fill in the data length and corresponding data.\r
//\r
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~0xF);\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, Length & 0xF);\r
+ MmioAnd32 ((UINTN)&DebugPortRegister->ControlStatus, (UINT32) ~0xF);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, Length & 0xF);\r
for (Index = 0; Index < Length; Index++) {\r
DebugPortRegister->DataBuffer[Index] = Buffer[Index];\r
}\r
//\r
// Setting W/R bit to indicate it's a WRITE operation\r
//\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT4);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT4);\r
//\r
// Setting GO bit as well as clearing DONE bit\r
//\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT5);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT5);\r
\r
//\r
// Wait for completing the request\r
//\r
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {\r
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {\r
+ while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {\r
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ {\r
return RETURN_DEVICE_ERROR;\r
}\r
}\r
//\r
// Clearing DONE bit by writing 1\r
//\r
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);\r
+ MmioOr32 ((UINTN)&DebugPortRegister->ControlStatus, BIT16);\r
\r
//\r
// Check if the request is executed successfully or not.\r
//\r
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {\r
+ if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {\r
return RETURN_DEVICE_ERROR;\r
}\r
\r
//\r
// Make sure the sent data are not beyond the allowable maximum length - 8 byte\r
//\r
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {\r
+ if (((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {\r
return RETURN_DEVICE_ERROR;\r
}\r
\r
RETURN_STATUS\r
EFIAPI\r
UsbDebugPortControlTransfer (\r
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
- IN USB_DEVICE_REQUEST *SetupPacket,\r
- IN UINT8 Addr,\r
- IN UINT8 Ep,\r
- OUT UINT8 *Data,\r
- IN OUT UINT8 *DataLength\r
+ IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,\r
+ IN USB_DEVICE_REQUEST *SetupPacket,\r
+ IN UINT8 Addr,\r
+ IN UINT8 Ep,\r
+ OUT UINT8 *Data,\r
+ IN OUT UINT8 *DataLength\r
)\r
{\r
- RETURN_STATUS Status;\r
- UINT8 Temp;\r
- UINT8 ReturnStatus[8];\r
+ RETURN_STATUS Status;\r
+ UINT8 Temp;\r
+ UINT8 ReturnStatus[8];\r
\r
//\r
// Setup Phase\r
//\r
- Status = UsbDebugPortOut(DebugPortRegister, (UINT8 *)SetupPacket, (UINT8)sizeof(USB_DEVICE_REQUEST), SETUP_PID, Addr, Ep, 0);\r
- if (RETURN_ERROR(Status)) {\r
+ Status = UsbDebugPortOut (DebugPortRegister, (UINT8 *)SetupPacket, (UINT8)sizeof (USB_DEVICE_REQUEST), SETUP_PID, Addr, Ep, 0);\r
+ if (RETURN_ERROR (Status)) {\r
return Status;\r
}\r
\r
//\r
// Get Data From Device\r
//\r
- Status = UsbDebugPortIn(DebugPortRegister, Data, DataLength, INPUT_PID, Addr, Ep, 1);\r
- if (RETURN_ERROR(Status)) {\r
+ Status = UsbDebugPortIn (DebugPortRegister, Data, DataLength, INPUT_PID, Addr, Ep, 1);\r
+ if (RETURN_ERROR (Status)) {\r
return Status;\r
}\r
} else {\r
//\r
// Send Data To Device\r
//\r
- Status = UsbDebugPortOut(DebugPortRegister, Data, *DataLength, OUTPUT_PID, Addr, Ep, 1);\r
- if (RETURN_ERROR(Status)) {\r
+ Status = UsbDebugPortOut (DebugPortRegister, Data, *DataLength, OUTPUT_PID, Addr, Ep, 1);\r
+ if (RETURN_ERROR (Status)) {\r
return Status;\r
}\r
}\r
//\r
// For READ operation, Data Toggle in Status Phase Should be 1.\r
//\r
- Status = UsbDebugPortOut(DebugPortRegister, NULL, 0, OUTPUT_PID, Addr, Ep, 1);\r
+ Status = UsbDebugPortOut (DebugPortRegister, NULL, 0, OUTPUT_PID, Addr, Ep, 1);\r
} else {\r
//\r
// For WRITE operation, Data Toggle in Status Phase Should be 1.\r
//\r
- Status = UsbDebugPortIn(DebugPortRegister, ReturnStatus, &Temp, INPUT_PID, Addr, Ep, 1);\r
+ Status = UsbDebugPortIn (DebugPortRegister, ReturnStatus, &Temp, INPUT_PID, Addr, Ep, 1);\r
}\r
\r
return Status;\r
**/\r
BOOLEAN\r
EFIAPI\r
-NeedReinitializeHardware(\r
- IN USB_DEBUG_PORT_HANDLE *Handle\r
+NeedReinitializeHardware (\r
+ IN USB_DEBUG_PORT_HANDLE *Handle\r
)\r
{\r
- UINT16 PciCmd;\r
- UINT32 UsbDebugPortMemoryBase;\r
- UINT32 EhciMemoryBase;\r
- BOOLEAN Status;\r
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
+ UINT16 PciCmd;\r
+ UINT32 UsbDebugPortMemoryBase;\r
+ UINT32 EhciMemoryBase;\r
+ BOOLEAN Status;\r
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
\r
Status = FALSE;\r
\r
- EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
+ EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
if (EhciMemoryBase != Handle->EhciMemoryBase) {\r
Handle->EhciMemoryBase = EhciMemoryBase;\r
- Status = TRUE;\r
+ Status = TRUE;\r
}\r
\r
- UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle->DebugPortBarNumber * 4);\r
+ UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle->DebugPortBarNumber * 4);\r
if (UsbDebugPortMemoryBase != Handle->UsbDebugPortMemoryBase) {\r
Handle->UsbDebugPortMemoryBase = UsbDebugPortMemoryBase;\r
- Status = TRUE;\r
+ Status = TRUE;\r
}\r
\r
//\r
// Enable Ehci Memory Space Access\r
//\r
- PciCmd = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET);\r
+ PciCmd = PciRead16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET);\r
if (((PciCmd & EFI_PCI_COMMAND_MEMORY_SPACE) == 0) || ((PciCmd & EFI_PCI_COMMAND_BUS_MASTER) == 0)) {\r
PciCmd |= EFI_PCI_COMMAND_MEMORY_SPACE | EFI_PCI_COMMAND_BUS_MASTER;\r
- PciWrite16(PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);\r
+ PciWrite16 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);\r
Status = TRUE;\r
}\r
\r
// 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.\r
//\r
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);\r
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))\r
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE)) {\r
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))\r
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))\r
+ {\r
Status = TRUE;\r
}\r
\r
} else if (Handle->Initialized != USBDBG_INIT_DONE) {\r
Status = TRUE;\r
}\r
+\r
return Status;\r
}\r
\r
RETURN_STATUS\r
EFIAPI\r
InitializeUsbDebugHardware (\r
- IN USB_DEBUG_PORT_HANDLE *Handle\r
-)\r
+ IN USB_DEBUG_PORT_HANDLE *Handle\r
+ )\r
{\r
- RETURN_STATUS Status;\r
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
- USB_DEBUG_PORT_DESCRIPTOR UsbDebugPortDescriptor;\r
- UINT32 *PortStatus;\r
- UINT32 *UsbCmd;\r
- UINT32 *UsbStatus;\r
- UINT32 *UsbHCSParam;\r
- UINT8 DebugPortNumber;\r
- UINT8 Length;\r
+ RETURN_STATUS Status;\r
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
+ USB_DEBUG_PORT_DESCRIPTOR UsbDebugPortDescriptor;\r
+ UINT32 *PortStatus;\r
+ UINT32 *UsbCmd;\r
+ UINT32 *UsbStatus;\r
+ UINT32 *UsbHCSParam;\r
+ UINT8 DebugPortNumber;\r
+ UINT8 Length;\r
\r
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);\r
- UsbHCSParam = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x04);\r
- UsbCmd = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x20);\r
- UsbStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x24);\r
+ UsbHCSParam = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x04);\r
+ UsbCmd = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x20);\r
+ UsbStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x24);\r
\r
//\r
// Check if the debug port is enabled and owned by myself.\r
//\r
- if (((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))\r
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET)) {\r
+ if (((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))\r
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET))\r
+ {\r
DEBUG ((\r
DEBUG_INFO,\r
"UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",\r
- MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)\r
+ MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus)\r
));\r
//\r
// If the host controller is halted, then reset and restart it.\r
//\r
- if ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0) {\r
+ if ((MmioRead32 ((UINTN)UsbStatus) & BIT12) != 0) {\r
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the host controller.\n"));\r
//\r
// reset the host controller.\r
//\r
- MmioOr32((UINTN)UsbCmd, BIT1);\r
+ MmioOr32 ((UINTN)UsbCmd, BIT1);\r
//\r
// ensure that the host controller is reset.\r
//\r
- while ((MmioRead32((UINTN)UsbCmd) & BIT1) != 0);\r
+ while ((MmioRead32 ((UINTN)UsbCmd) & BIT1) != 0) {\r
+ }\r
\r
- MmioOr32((UINTN)UsbCmd, BIT0);\r
+ MmioOr32 ((UINTN)UsbCmd, BIT0);\r
// ensure that the host controller is started (HALTED bit must be cleared)\r
- while ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0);\r
+ while ((MmioRead32 ((UINTN)UsbStatus) & BIT12) != 0) {\r
+ }\r
}\r
\r
//\r
// First get the ownership of port 0.\r
//\r
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE);\r
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE);\r
\r
MicroSecondDelay (200000);\r
}\r
+\r
//\r
// Find out which port is used as debug port.\r
//\r
- DebugPortNumber = (UINT8)((MmioRead32((UINTN)UsbHCSParam) & 0x00F00000) >> 20);\r
+ DebugPortNumber = (UINT8)((MmioRead32 ((UINTN)UsbHCSParam) & 0x00F00000) >> 20);\r
//\r
// Should find a device is connected at debug port\r
//\r
PortStatus = (UINT32 *)((UINTN)Handle->EhciMemoryBase + 0x64 + (DebugPortNumber - 1) * 4);\r
- if (!(MmioRead32((UINTN)PortStatus) & BIT0)) {\r
+ if (!(MmioRead32 ((UINTN)PortStatus) & BIT0)) {\r
Handle->Initialized = USBDBG_NO_DEV;\r
return RETURN_NOT_FOUND;\r
}\r
\r
- if (Handle->Initialized != USBDBG_INIT_DONE ||\r
- (MmioRead32 ((UINTN) &UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0) {\r
+ if ((Handle->Initialized != USBDBG_INIT_DONE) ||\r
+ ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0))\r
+ {\r
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the debug port.\n"));\r
//\r
// Reset the debug port\r
//\r
- MmioOr32((UINTN)PortStatus, BIT8);\r
+ MmioOr32 ((UINTN)PortStatus, BIT8);\r
MicroSecondDelay (500000);\r
- MmioAnd32((UINTN)PortStatus, (UINT32)~BIT8);\r
- while (MmioRead32((UINTN)PortStatus) & BIT8);\r
+ MmioAnd32 ((UINTN)PortStatus, (UINT32) ~BIT8);\r
+ while (MmioRead32 ((UINTN)PortStatus) & BIT8) {\r
+ }\r
\r
//\r
// The port enabled bit should be set by HW.\r
//\r
- if ((MmioRead32((UINTN)PortStatus) & BIT2) == 0) {\r
+ if ((MmioRead32 ((UINTN)PortStatus) & BIT2) == 0) {\r
Handle->Initialized = USBDBG_NO_DBG_CAB;\r
return RETURN_DEVICE_ERROR;\r
}\r
//\r
// Enable Usb Debug Port Capability\r
//\r
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_ENABLE);\r
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_ENABLE);\r
\r
//\r
// initialize the data toggle used by bulk in/out endpoint.\r
// set usb debug device address as 0x7F.\r
//\r
Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbSetDebugAddress, 0x0, 0x0, NULL, NULL);\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
//\r
// The device can not work well.\r
//\r
//\r
// Get debug descriptor.\r
//\r
- Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbGetDebugDescriptor, 0x7F, 0x0, (UINT8*)&UsbDebugPortDescriptor, &Length);\r
- if (RETURN_ERROR(Status)) {\r
+ Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbGetDebugDescriptor, 0x7F, 0x0, (UINT8 *)&UsbDebugPortDescriptor, &Length);\r
+ if (RETURN_ERROR (Status)) {\r
//\r
// The device is not a usb debug device.\r
//\r
return Status;\r
}\r
\r
- if (Length != sizeof(USB_DEBUG_PORT_DESCRIPTOR)) {\r
+ if (Length != sizeof (USB_DEBUG_PORT_DESCRIPTOR)) {\r
Handle->Initialized = USBDBG_NO_DBG_CAB;\r
return RETURN_DEVICE_ERROR;\r
}\r
// enable the usb debug feature.\r
//\r
Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mDebugCommunicationLibUsbSetDebugFeature, 0x7F, 0x0, NULL, NULL);\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
//\r
// The device can not work well.\r
//\r
UINTN\r
EFIAPI\r
DebugPortReadBuffer (\r
- IN DEBUG_PORT_HANDLE Handle,\r
- IN UINT8 *Buffer,\r
- IN UINTN NumberOfBytes,\r
- IN UINTN Timeout\r
+ IN DEBUG_PORT_HANDLE Handle,\r
+ IN UINT8 *Buffer,\r
+ IN UINTN NumberOfBytes,\r
+ IN UINTN Timeout\r
)\r
{\r
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
- RETURN_STATUS Status;\r
- UINT8 Index;\r
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
+ RETURN_STATUS Status;\r
+ UINT8 Index;\r
\r
- if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {\r
+ if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {\r
return 0;\r
}\r
\r
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;\r
}\r
\r
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {\r
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {\r
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
return 0;\r
}\r
}\r
if ((Index + 1) >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {\r
return 0;\r
}\r
+\r
UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Index + 1];\r
}\r
+\r
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);\r
return 1;\r
}\r
UINTN\r
EFIAPI\r
DebugPortWriteBuffer (\r
- IN DEBUG_PORT_HANDLE Handle,\r
- IN UINT8 *Buffer,\r
- IN UINTN NumberOfBytes\r
+ IN DEBUG_PORT_HANDLE Handle,\r
+ IN UINT8 *Buffer,\r
+ IN UINTN NumberOfBytes\r
)\r
{\r
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
- RETURN_STATUS Status;\r
- UINT8 Sent;\r
- UINTN Total;\r
- UINT8 ReceivedPid;\r
-\r
- if (NumberOfBytes == 0 || Buffer == NULL) {\r
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
+ RETURN_STATUS Status;\r
+ UINT8 Sent;\r
+ UINTN Total;\r
+ UINT8 ReceivedPid;\r
+\r
+ if ((NumberOfBytes == 0) || (Buffer == NULL)) {\r
return 0;\r
}\r
\r
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;\r
}\r
\r
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {\r
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {\r
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
return 0;\r
}\r
}\r
Sent = (UINT8)(NumberOfBytes - Total);\r
}\r
\r
- Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle);\r
+ Status = UsbDebugPortOut (UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, UsbDebugPortHandle->OutEndpoint, UsbDebugPortHandle->BulkOutToggle);\r
\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
return Total;\r
}\r
\r
- ReceivedPid = (MmioRead8((UINTN)&UsbDebugPortRegister->ReceivedPid));\r
+ ReceivedPid = (MmioRead8 ((UINTN)&UsbDebugPortRegister->ReceivedPid));\r
//\r
// If received a NAK_PID on write transaction, it means the usb debug device is busy and can not handle this transaction.\r
// should send the packet again.\r
} else {\r
UsbDebugPortHandle->BulkOutToggle ^= 1;\r
}\r
+\r
Total += Sent;\r
}\r
+\r
return Total;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
DebugPortPollBuffer (\r
- IN DEBUG_PORT_HANDLE Handle\r
+ IN DEBUG_PORT_HANDLE Handle\r
)\r
{\r
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
- UINT8 Length;\r
- UINT8 Index;\r
- RETURN_STATUS Status;\r
+ USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;\r
+ USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;\r
+ UINT8 Length;\r
+ UINT8 Index;\r
+ RETURN_STATUS Status;\r
\r
//\r
// If Handle is NULL, it means memory is ready for use.\r
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;\r
}\r
\r
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {\r
- Status = InitializeUsbDebugHardware(UsbDebugPortHandle);\r
- if (RETURN_ERROR(Status)) {\r
+ if (NeedReinitializeHardware (UsbDebugPortHandle)) {\r
+ Status = InitializeUsbDebugHardware (UsbDebugPortHandle);\r
+ if (RETURN_ERROR (Status)) {\r
return FALSE;\r
}\r
}\r
\r
UsbDebugPortRegister->TokenPid = INPUT_PID;\r
if (UsbDebugPortHandle->BulkInToggle == 0) {\r
- UsbDebugPortRegister->SendPid = DATA0_PID;\r
+ UsbDebugPortRegister->SendPid = DATA0_PID;\r
} else {\r
- UsbDebugPortRegister->SendPid = DATA1_PID;\r
+ UsbDebugPortRegister->SendPid = DATA1_PID;\r
}\r
+\r
UsbDebugPortRegister->UsbAddress = 0x7F;\r
UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;\r
\r
//\r
// Clearing W/R bit to indicate it's a READ operation\r
//\r
- MmioAnd32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)~BIT4);\r
+ MmioAnd32 ((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32) ~BIT4);\r
//\r
// Setting GO bit as well as clearing DONE bit\r
//\r
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)BIT5);\r
+ MmioOr32 ((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)BIT5);\r
\r
//\r
// Wait for completing the request\r
//\r
- while ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {\r
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {\r
+ while ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {\r
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))\r
+ {\r
return FALSE;\r
}\r
}\r
\r
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)) & BIT6) {\r
+ if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus)) & BIT6) {\r
return FALSE;\r
}\r
\r
- Length = (UINT8)(MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & 0xF);\r
+ Length = (UINT8)(MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & 0xF);\r
\r
if (Length > 8) {\r
return FALSE;\r
for (Index = 0; Index < Length; Index++) {\r
UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];\r
}\r
+\r
UsbDebugPortHandle->DataCount = Length;\r
\r
return TRUE;\r
IN DEBUG_PORT_CONTINUE Function\r
)\r
{\r
- RETURN_STATUS Status;\r
- USB_DEBUG_PORT_HANDLE Handle;\r
+ RETURN_STATUS Status;\r
+ USB_DEBUG_PORT_HANDLE Handle;\r
\r
//\r
// Validate the PCD PcdDebugPortHandleBufferSize value\r
//\r
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB_DEBUG_PORT_HANDLE));\r
\r
- if (Function == NULL && Context != NULL) {\r
- return (DEBUG_PORT_HANDLE *) Context;\r
+ if ((Function == NULL) && (Context != NULL)) {\r
+ return (DEBUG_PORT_HANDLE *)Context;\r
}\r
- ZeroMem(&Handle, sizeof (USB_DEBUG_PORT_HANDLE));\r
\r
- Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);\r
+ ZeroMem (&Handle, sizeof (USB_DEBUG_PORT_HANDLE));\r
+\r
+ Status = CalculateUsbDebugPortBar (&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);\r
if (RETURN_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "UsbDbg: the pci device pointed by PcdUsbEhciPciAddress is not EHCI host controller or does not support debug port capability!\n"));\r
goto Exit;\r
}\r
\r
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
+ Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
\r
if (Handle.EhciMemoryBase == 0) {\r
//\r
// Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero\r
//\r
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, PcdGet32(PcdUsbEhciMemorySpaceBase));\r
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
+ PciWrite32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, PcdGet32 (PcdUsbEhciMemorySpaceBase));\r
+ Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);\r
}\r
\r
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);\r
+ Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);\r
\r
if (Handle.UsbDebugPortMemoryBase == 0) {\r
//\r
// Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero\r
//\r
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4, PcdGet32(PcdUsbDebugPortMemorySpaceBase));\r
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);\r
+ PciWrite32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4, PcdGet32 (PcdUsbDebugPortMemorySpaceBase));\r
+ Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32 (PcdGet32 (PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);\r
}\r
\r
Handle.Initialized = USBDBG_RESET;\r
\r
- if (NeedReinitializeHardware(&Handle)) {\r
+ if (NeedReinitializeHardware (&Handle)) {\r
DEBUG ((DEBUG_ERROR, "UsbDbg: Start EHCI debug port initialization!\n"));\r
Status = InitializeUsbDebugHardware (&Handle);\r
- if (RETURN_ERROR(Status)) {\r
+ if (RETURN_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "UsbDbg: Failed, please check if USB debug cable is plugged into EHCI debug port correctly!\n"));\r
goto Exit;\r
}\r
if (Function != NULL) {\r
Function (Context, &Handle);\r
} else {\r
- CopyMem(&mDebugCommunicationLibUsbDebugPortHandle, &Handle, sizeof (USB_DEBUG_PORT_HANDLE));\r
+ CopyMem (&mDebugCommunicationLibUsbDebugPortHandle, &Handle, sizeof (USB_DEBUG_PORT_HANDLE));\r
}\r
\r
return (DEBUG_PORT_HANDLE)(UINTN)&mDebugCommunicationLibUsbDebugPortHandle;\r