📄 usbohcidebug.c
字号:
/* usbOhciDebug.c - USB OHCI Debug Routines *//* Copyright 2004-2005 Wind River Systems, Inc. This software includes software licensed to Wind River Systems, Inc. by Wipro, Ltd. Wind River licensees may use this software according to the terms of their Wind River license agreement(s) applicable to this software.*//*modification history--------------------01d,28mar05,pdg non-PCI changes01c,11oct04,ami Apigen Changes01b,27jun03,nld Changing the code to WRS standards01a,17mar02,ssh Initial Version*//*DESCRIPTIONThis file contains functions for display the USB OHCI registers, memory, endpoint desriptor, transfer descriptor etc. This interfaces exposed from this file can used to debug the OHCI driver.INCLUDE FILES: usbOhci.h, usbOhciRegisterInfo.h, usbOhciTransferManagement.h*//* INTERNAL ****************************************************************************** * Filename : OHCI_Debug.c * * Copyright : * * THE COPYRIGHT IN THE CONTENTS OF THIS SOFTWARE VEST WITH WIPRO * LIMITED A COMPANY INCORPORATED UNDER THE LAWS OF INDIA AND HAVING * ITS REGISTERED OFFICE AT DODDAKANNELLI SARJAPUR ROAD BANGALORE * 560 035. DISTRIBUTION OR COPYING OF THIS SOFTWARE BY * ANY INDIVIDUAL OR ENTITY OTHER THAN THE ADDRESSEE IS STRICTLY * PROHIBITED AND MAY INCUR LEGAL LIABILITY. IF YOU ARE NOT THE * ADDRESSEE PLEASE NOTIFY US IMMEDIATELY BY PHONE OR BY RETURN EMAIL. * THE ADDRESSEE IS ADVISED TO MAINTAIN THE PROPRIETARY INTERESTS OF * THIS COPYRIGHT AS PER APPLICABLE LAWS. * * Author : Sadashivan M (sadashivan.manickam@wipro.com) * * Revision history : * * Version Date Author Description ID * ------- ---------- -------------- ------------------------------ -------- * 0.9 17/03/2002 Sadashivan Initial Version - * * Description : This file contains functions for display the OHCI * registers, memory, endpoint desriptor, transfer descriptor * etc. This interfaces exposed from this file can used to * debug the OHCI driver. * * FIX ME : None. * * TO DO : None. * ******************************************************************************//* includes */#include "usb2/usbOsal.h"#include "usb2/usbOhci.h"#include "usb2/usbOhciRegisterInfo.h"#include "usb2/usbOhciTransferManagement.h"BOOLEAN usbOhciDumpRegisters(UINT32 uHostControllerIndex);VOID usbOhciDumpMemory(UINT32 uAddress, UINT32 uLength, UINT32 uWidth);VOID usbOhciDumpEndpointDescriptor(PVOID pEndpointDescriptor);VOID usbOhciDumpPeriodicEndpointList(UINT8 uHostControllerIndex);VOID usbOhciDumpGeneralTransferDescriptor(PVOID pGeneralTransferDescriptor);VOID usbOhciDumpPendingTransfers(PVOID pEndpointDescriptor);VOID usbOhciInitializeModuleTestingFunctions(PUSBHST_HC_DRIVER_TEST pHCDriverTestEntryPoints);/****************** MODULE SPECIFIC FUNCTIONS DECLARATION *********************//* functions */LOCALVOID usbOhciPowerOnPorts(UINT32 uHostControllerIndex);LOCAL BOOLEAN usbOhciResetPort(UINT32 uHostControllerIndex, UINT8 uPortNumber);LOCAL BOOLEAN usbOhciWaitForConnection(UINT32 uHostControllerIndex, UINT8 uPortNumber);LOCAL UINT8 usbOhciGetDeviceSpeed(UINT32 uHostControllerIndex, UINT8 uPortNumber);/************************ GLOBAL FUNCTIONS DEFINITION *************************//***************************************************************************** usbOhciDumpRegisters - dump registers contents.** This function is used to dump the contents of the USB OHCI Host Controller * Registers.** PARAMETERS: <uHostControllerIndex (IN)> - Specifies the OHCI Host Controller* index.** RETURNS: TRUE if the host controller index specified is valid for the USB* OHCI controllers detected on the system, otherwise FALSE.** ERRNO:* None.*/BOOLEAN usbOhciDumpRegisters ( UINT32 uHostControllerIndex ) { /* To hold the base address of the OHCI Controller */ UINT32 uBaseAddress = 0; /* * To hold the number of OHCI Contorller Registers (excluding the * root hub port status registers. */ const UINT32 uNumberOfRegisters = 21; /* To hold the name of the OHCI Controller Registers */ UCHAR pRegisterName[][10] = { "HC_REV ", "HC_CON ", "HC_CMDST ", "HC_INTST ", "HC_INTEN ", "HC_INTDI ", "HC_HCCA ", "HC_PCED ", "HC_CHED ", "HC_CCED ", "HC_BHED ", "HC_BCED ", "HC_DONEH ", "HC_FMINT ", "HC_FMREM ", "HC_FMNUM ", "HC_PERST ", "HC_LSTHR ", "HC_RHDESA", "HC_RHDESB", "HC_RHSTA ", "HC_RHPS", }; /* To hold the offset of the OHCI Controller Registers */ UINT32 uRegisterOffset[] = { USB_OHCI_REVISION_REGISTER_OFFSET, USB_OHCI_CONTROL_REGISTER_OFFSET, USB_OHCI_COMMAND_STATUS_REGISTER_OFFSET, USB_OHCI_INTERRUPT_STATUS_REGISTER_OFFSET, USB_OHCI_INTERRUPT_ENABLE_REGISTER_OFFSET, USB_OHCI_INTERRUPT_DISABLE_REGISTER_OFFSET, USB_OHCI_HCCA_REGISTER_OFFSET, USB_OHCI_PERIOD_CURRENT_ED_REGISTER_OFFSET, USB_OHCI_CONTROL_HEAD_ED_REGISTER_OFFSET, USB_OHCI_CONTROL_CURRENT_ED_REGISTER_OFFSET, USB_OHCI_BULK_HEAD_ED_REGISTER_OFFSET, USB_OHCI_BULK_CURRENT_ED_REGISTER_OFFSET, USB_OHCI_DONE_HEAD_REGISTER_OFFSET, USB_OHCI_FM_INTERVAL_REGISTER_OFFSET, USB_OHCI_FM_REMAINING_REGISTER_OFFSET, USB_OHCI_FM_NUMBER_REGISTER_OFFSET, USB_OHCI_PERIODIC_START_REGISTER_OFFSET, USB_OHCI_LC_THRESHOLD_REGISTER_OFFSET, USB_OHCI_RH_DESCRIPTOR_A_REGISTER_OFFSET, USB_OHCI_RH_DESCRIPTOR_B_REGISTER_OFFSET, USB_OHCI_RH_STATUS_REGISTER_OFFSET, }; /* To hold the loop index */ UINT32 uIndex = 0; /* To hold the port number */ UINT16 uPortNumber = 1; /* To hold the downstream ports on the root hub */ UINT16 uNumberOfDownStreamPorts = 0; /* To hold the offset of the root hub port status register */ UINT8 uRootHubPortStatusRegisterOffset = 0; /* To hold the value read from the registers */ UINT32 uRegisterValue = 0; /* Check whether the OHCI Bus Number is valid */ if (uHostControllerIndex >= uNumberOfOhciControllers) { /* Invalid OHCI Bus Number */ return FALSE; } /* Obtain the base address */ uBaseAddress = usbOhciControllerInfo[uHostControllerIndex].uBaseAddress; /* Display new lines */ OS_PRINTF ("\n\n",0,0,0,0,0,0); /* Display the contents of the OHCI Controller registers */ for (uIndex = 0; uIndex < uNumberOfRegisters; uIndex++) { /* Display three registers per line */ if ((uIndex != 0) && ((uIndex % 3) == 0)) { OS_PRINTF("\n",0,0,0,0,0,0); } /* Display the contents of the register */ OS_PRINTF ("%s : 0x%08X ", pRegisterName[uIndex], USB_OHCI_REG_READ (uHostControllerIndex, uBaseAddress + uRegisterOffset[uIndex]), 0,0,0,0); } /* Obtain the number of downstream ports on the root hub */ uNumberOfDownStreamPorts = usbOhciControllerInfo[uHostControllerIndex].uNumberOfDownStreamPorts; /* Display the contents of the root hub port status register */ for (uPortNumber = 1; uPortNumber <= uNumberOfDownStreamPorts; uPortNumber++) { /* Obtain the offset of the root hub port status register */ uRootHubPortStatusRegisterOffset = USB_OHCI_RH_PORT_STATUS_REGISTER_OFFSET(uPortNumber); /* Read the contents of the port status register */ uRegisterValue = USB_OHCI_REG_READ(uHostControllerIndex, uBaseAddress + uRootHubPortStatusRegisterOffset); /* Display three registers per line */ if ((uIndex != 0) && ((uIndex % 3) == 0)) { OS_PRINTF("\n",0,0,0,0,0,0); } /* Display the contents of the register */ OS_PRINTF("%s%d : 0x%08X ", pRegisterName[uNumberOfRegisters], uPortNumber, uRegisterValue,0,0,0); /* Increment the index for formatting */ uIndex++; } /* Display new lines */ OS_PRINTF("\n\n",0,0,0,0,0,0); return TRUE; } /* End of function usbOhciDumpRegisters () *//***************************************************************************** usbOhciDumpMemory - dump memory contents** This function is used to dump the contents of the specified memory location.** PARAMETERS: <uAddress (IN)> - Specifies the address of memory location.** <uLength (IN)> - Specifies the length of memory to be dumped.** <uWidth (IN)> - Specifies the width of each entry in bytes. For example,* if this value is 1, the data will be displayed in bytes. If the value is 4,* the data will be displayed in DWORDS (4 bytes).** RETURNS: N/A** ERRNO:* None.*/VOID usbOhciDumpMemory ( UINT32 uAddress, UINT32 uLength, UINT32 uWidth ) { /* To hold the loop index */ UINT32 uIndex = 0; /* To hold the pointer to the memory location */ PUCHAR pBuffer = (PUCHAR) uAddress; /* Display the contents of the memory location */ for (uIndex = 0; uIndex < uLength / uWidth; uIndex++) { /* Display the memory address */ if ((uIndex % (8 / uWidth)) == 0) { OS_PRINTF("\n0x%08X: ", uAddress + uIndex * uWidth,0,0,0,0,0); } /* Display the contents of the memory */ switch (uWidth) { case 1: /* Display in bytes */ OS_PRINTF("0x%02X ", ((PUCHAR) pBuffer)[uIndex],0,0,0,0,0); break; case 4: OS_PRINTF("0x%08X ", ((PUINT32) pBuffer)[uIndex],0,0,0,0,0); break; default: OS_PRINTF("0x%X ", ((PUCHAR) pBuffer)[uIndex],0,0,0,0,0); break; }; } /* End of for (uIndex = 0; ...) */ return; } /* End of function usbOhciDumpMemory () *//***************************************************************************** usbOhciDumpEndpointDescriptor - dump endpoint descriptor contents** This function is used to dump the contents of the endpoint descriptor.** PARAMETERS: <pEndpointDescriptor (IN)> - Pointer to the endpoint descriptor to* be dumped.** RETURNS: N/A** ERRNO:* None.*/VOID usbOhciDumpEndpointDescriptor ( PVOID pEndpointDescriptor ) { /* To hold the pointer to the OHCI endpoint descriptor */ PUSB_OHCI_ENDPOINT_DESCRIPTOR pOhciEndpointDescriptor = NULL; /* To hold the pointer to the OHCI general transfer descriptor */ PUSB_OHCI_GENERAL_TRANSFER_DESCRIPTOR pOhciGeneralTransferDescriptor = NULL; /* To hold the pointer to the temporary OHCI general transfer descriptor */ PUSB_OHCI_GENERAL_TRANSFER_DESCRIPTOR pTempTransferDescriptor = NULL; /* Check whether the parameter is valid */ if (pEndpointDescriptor == NULL) { return; } /* Initialize the pointer to the OHCI endpoint descriptor */ pOhciEndpointDescriptor = (PUSB_OHCI_ENDPOINT_DESCRIPTOR) pEndpointDescriptor; /* Display the control information */ OS_PRINTF( "[0x%08X]->uControlInformation : 0x%08X\n", (UINT32) pOhciEndpointDescriptor, pOhciEndpointDescriptor->uControlInformation,0,0,0,0); /* Display the pointer to the tail of the transfer descriptor list */ OS_PRINTF(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -