/*++ Copyright (c) 1999 Microsoft Corporation Module Name: usbohci.c Abstract: WinDbg Extension Api implements !_ehcitd !_ehciqh !_ehciep Author: jd Environment: User Mode. Revision History: --*/ #include "precomp.h" #include "usb.h" #include "usbhcdi.h" #include "..\miniport\usbehci\ehci.h" #include "..\miniport\usbehci\usbehci.h" #include "usbhcdkd.h" VOID DumpEHCI_qTD( PHW_QUEUE_ELEMENT_TD qTd ) { ULONG i; dprintf("\t qTD\n"); dprintf("\t Next_qTD: %08.8x\n", qTd->Next_qTD); dprintf("\t AltNext_qTD: %08.8x\n", qTd->AltNext_qTD); dprintf("\t Token: 0x%08.8x\n", qTd->Token.ul); dprintf("\t\t PingState: 0x%x\n", qTd->Token.PingState); dprintf("\t\t SplitXstate: 0x%x\n", qTd->Token.SplitXstate); dprintf("\t\t MissedMicroFrame: 0x%x\n", qTd->Token.MissedMicroFrame); dprintf("\t\t XactErr: 0x%x\n", qTd->Token.XactErr); dprintf("\t\t BabbleDetected: 0x%x\n", qTd->Token.BabbleDetected); dprintf("\t\t DataBufferError: 0x%x\n", qTd->Token.DataBufferError); dprintf("\t\t Halted: 0x%x\n", qTd->Token.Halted); dprintf("\t\t Active: 0x%x\n", qTd->Token.Active); dprintf("\t\t Pid: 0x%x - ", qTd->Token.Pid); switch(qTd->Token.Pid) { case HcTOK_Out: dprintf("HcTOK_Out\n"); break; case HcTOK_In: dprintf("HcTOK_In\n"); break; case HcTOK_Setup: dprintf("HcTOK_Setup\n"); break; case HcTOK_Reserved: dprintf("HcTOK_Reserved\n"); break; } dprintf("\t\t ErrorCounter: 0x%x\n", qTd->Token.ErrorCounter); dprintf("\t\t C_Page: 0x%x\n", qTd->Token.C_Page); dprintf("\t\t InterruptOnComplete: 0x%x\n", qTd->Token.InterruptOnComplete); dprintf("\t\t BytesToTransfer: 0x%x\n", qTd->Token.BytesToTransfer); dprintf("\t\t DataToggle: 0x%x\n", qTd->Token.DataToggle); for (i=0; i<5; i++) { dprintf("\t BufferPage[%d]: 0x %05.5x-%03.3x %08.8x\n", i, qTd->BufferPage[i].BufferPointer, qTd->BufferPage[i].CurrentOffset, qTd->BufferPage[i].ul); } } VOID DumpEHCI_Td( ULONG MemLoc ) { HCD_TRANSFER_DESCRIPTOR td; ULONG result; ULONG i; if (!ReadMemory (MemLoc, &td, sizeof(td), &result)) { BadMemLoc(MemLoc); return; } if (td.Sig != SIG_HCD_TD) { dprintf("%08.8x is not a TD\n", MemLoc); } dprintf("*USBEHCI TD %08.8x\n", MemLoc); Sig(td.Sig, ""); DumpEHCI_qTD(&td.HwTD); dprintf("Packet:"); for (i=0; i<8; i++) { dprintf("%02.2x ", td.Packet[i]); } dprintf("\n"); dprintf("PhysicalAddress: %08.8x\n",td.PhysicalAddress); dprintf("EndpointData: %08.8x\n",td.EndpointData); dprintf("TransferLength : %08.8x\n", td.TransferLength); dprintf("TransferContext: %08.8x\n",td.TransferContext); dprintf("Flags: %08.8x\n",td.Flags); if (td.Flags & TD_FLAG_BUSY) { dprintf("\tTD_FLAG_BUSY\n"); } if (td.Flags & TD_FLAG_XFER) { dprintf("\tTD_FLAG_XFER\n"); } if (td.Flags & TD_FLAG_DONE) { dprintf("\tTD_FLAG_DONE\n"); } if (td.Flags & TD_FLAG_SKIP) { dprintf("\tTD_FLAG_SKIP\n"); } if (td.Flags & TD_FLAG_DUMMY) { dprintf("\tTD_FLAG_DUMMY\n"); } dprintf("NextHcdTD: %08.8x\n",td.NextHcdTD); dprintf("AltNextHcdTD: %08.8x\n",td.AltNextHcdTD); } VOID DumpEHCI_SiTd( ULONG MemLoc ) { UCHAR cs[] = "usbehci!_HCD_SI_TRANSFER_DESCRIPTOR"; PrintfMemLoc("*USBEHCI ENDPOINT_DATA ", MemLoc, "\n"); Sig(UsbReadFieldUlong(MemLoc, cs, "Sig"), ""); dprintf("PhysicalAddress: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "PhysicalAddress")); dprintf("StartOffset: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "StartOffset")); PrintfMemLoc("Packet: ", UsbReadFieldPtr(MemLoc, cs, "Packet"), "\n"); PrintfMemLoc("Transfer: ", UsbReadFieldPtr(MemLoc, cs, "Transfer"), "\n"); PrintfMemLoc("NextLink: ", UsbReadFieldPtr(MemLoc, cs, "NextLink"), "\n"); dprintf("HwTD.NextLink: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.NextLink")); dprintf("HwTD.Caps: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.Caps")); dprintf("HwTD.Control: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.Control")); dprintf("HwTD.State: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.BufferPointer0")); dprintf("HwTD.State: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.BufferPointer1")); dprintf("HwTD.BackPointer: 0x%08.8x\n", UsbReadFieldUlong(MemLoc, cs, "HwTD.BackPointer")); // PrintfMemLoc("StaticEd: ", // UsbReadFieldPtr(MemLoc, cs, "StaticEd"), // "\n"); } VOID DumpEHCI_iTd( MEMLOC MemLoc ) { HCD_HSISO_TRANSFER_DESCRIPTOR td; ULONG i, cb; ULONG flags; UCHAR s[64]; UCHAR cs[] = "usbehci!_HCD_HSISO_TRANSFER_DESCRIPTOR"; STRUC_ENTRY t[] = { "Sig", FT_SIG, "PhysicalAddress", FT_ULONG, "HostFrame", FT_ULONG, "FirstPacket.Pointer", FT_PTR, "Transfer.Pointer", FT_PTR, "NextLink", FT_PTR, "ReservedMBNull", FT_PTR, }; ReadMemory(MemLoc, &td, sizeof(td), &cb); if (td.Sig != SIG_HCD_ITD) { dprintf("not a iTD\n"); } PrintfMemLoc("*USBEHCI iTD ", MemLoc, "\n"); UsbDumpStruc(MemLoc, cs, &t[0], sizeof(t)/sizeof(STRUC_ENTRY)); dprintf("\t NextLink %08.8x\n", td.HwTD.NextLink.HwAddress); dprintf("\t (%08.8x)BufferPointer0 %08.8x\n", td.HwTD.BufferPointer0.ul, td.HwTD.BufferPointer0.BufferPointer); dprintf("\t\t Dev x%x Ept x%x\n", td.HwTD.BufferPointer0.DeviceAddress, td.HwTD.BufferPointer0.EndpointNumber); dprintf("\t (%08.8x)BufferPointer1 %08.8x\n", td.HwTD.BufferPointer1.ul, td.HwTD.BufferPointer1.BufferPointer); dprintf("\t\t MaxPacketSize x%x\n", td.HwTD.BufferPointer1.MaxPacketSize); dprintf("\t (%08.8x)BufferPointer2 %08.8x\n", td.HwTD.BufferPointer2.ul, td.HwTD.BufferPointer2.BufferPointer); dprintf("\t\t Multi x%x\n", td.HwTD.BufferPointer2.Multi); dprintf("\t (%08.8x)BufferPointer3 %08.8x\n", td.HwTD.BufferPointer3.ul, td.HwTD.BufferPointer3.BufferPointer); dprintf("\t (%08.8x)BufferPointer4 %08.8x\n", td.HwTD.BufferPointer4.ul, td.HwTD.BufferPointer4.BufferPointer); dprintf("\t (%08.8x)BufferPointer5 %08.8x\n", td.HwTD.BufferPointer5.ul, td.HwTD.BufferPointer5.BufferPointer); dprintf("\t (%08.8x)BufferPointer6 %08.8x\n", td.HwTD.BufferPointer6.ul, td.HwTD.BufferPointer6.BufferPointer); for (i=0; i<8; i++) { dprintf("\t Transaction[%d](%08.8x)\n", i, td.HwTD.Transaction[i].ul); dprintf("\t Transaction[%d].Offset %08.8x\n", i, td.HwTD.Transaction[i].Offset); dprintf("\t Transaction[%d].PageSelect %d\n", i, td.HwTD.Transaction[i].PageSelect); dprintf("\t Transaction[%d].Length %08.8x\n", i, td.HwTD.Transaction[i].Length); dprintf("\t\t active %d ioc %d - xerr:%d babble:%d dataerr:%d\n", td.HwTD.Transaction[i].Active, td.HwTD.Transaction[i].InterruptOnComplete, td.HwTD.Transaction[i].XactError, td.HwTD.Transaction[i].BabbleDetect, td.HwTD.Transaction[i].DataBufferError ); } } VOID DumpEHCI_StaticQh( MEMLOC MemLoc ) { ULONG f; FLAG_TABLE qhFlags[] = { "EHCI_QH_FLAG_IN_SCHEDULE", EHCI_QH_FLAG_IN_SCHEDULE, "EHCI_QH_FLAG_QH_REMOVED", EHCI_QH_FLAG_QH_REMOVED, "EHCI_QH_FLAG_STATIC", EHCI_QH_FLAG_STATIC, "EHCI_QH_FLAG_HIGHSPEED", EHCI_QH_FLAG_HIGHSPEED, }; UCHAR cs[] = "_HCD_QUEUEHEAD_DESCRIPTOR"; SIG s; PrintfMemLoc("*USBEHCI Static QH ", MemLoc, "\n"); s.l = UsbReadFieldUlong(MemLoc, cs, "Sig"); Sig(s.l, ""); f = UsbReadFieldUlong(MemLoc, cs, "QhFlags"); dprintf("Flags: %08.8x\n", f); UsbDumpFlags(f, qhFlags, sizeof(qhFlags)/sizeof(FLAG_TABLE)); dprintf("\tPhysicalAddress: 0x%x\n", UsbReadFieldUlong(MemLoc, cs, "PhysicalAddress")); PrintfMemLoc("\tNextQh: ", UsbReadFieldPtr(MemLoc, cs, "NextQh"), "\n"); PrintfMemLoc("\tPrevQh: ", UsbReadFieldPtr(MemLoc, cs, "PrevQh"), "\n"); // now walk the regular queue heads MemLoc = UsbReadFieldPtr(MemLoc, cs, "NextQh"); while (MemLoc) { PrintfMemLoc("\t\t: ", MemLoc, " "); f = UsbReadFieldUlong(MemLoc, cs, "QhFlags"); if (f & EHCI_QH_FLAG_STATIC) { dprintf("STATIC\n"); } else { dprintf("\n"); } MemLoc = UsbReadFieldPtr(MemLoc, cs, "NextQh"); } } VOID DumpEHCI_HwQh( MEMLOC MemLoc ) { HW_QUEUEHEAD_DESCRIPTOR hwQH; ULONG cb; ReadMemory(MemLoc, &hwQH, sizeof(hwQH), &cb); PrintfMemLoc("*HwQH ", MemLoc, "\n"); dprintf("HwQH\n"); dprintf("\t HwQH.HLink %08.8x\n", hwQH.HLink.HwAddress); dprintf("\t HwQH.EpChars %08.8x\n", hwQH.EpChars.ul); dprintf("\t\t DeviceAddress: 0x%x\n", hwQH.EpChars.DeviceAddress); dprintf("\t\t EndpointNumber: 0x%x\n", hwQH.EpChars.EndpointNumber); dprintf("\t\t EndpointSpeed: 0x%x", hwQH.EpChars.EndpointSpeed); switch(hwQH.EpChars.EndpointSpeed) { case HcEPCHAR_FullSpeed: dprintf("HcEPCHAR_FullSpeed"); break; case HcEPCHAR_HighSpeed: dprintf("HcEPCHAR_HighSpeed"); break; case HcEPCHAR_LowSpeed: dprintf("HcEPCHAR_LowSpeed"); break; case HcEPCHAR_Reserved: dprintf("HcEPCHAR_Reserved"); break; } dprintf("\n"); dprintf("\t\t DataToggleControl: 0x%x\n", hwQH.EpChars.DataToggleControl); dprintf("\t\t HeadOfReclimationList: 0x%x\n", hwQH.EpChars.HeadOfReclimationList); dprintf("\t\t MaximumPacketLength: 0x%x - %d\n", hwQH.EpChars.MaximumPacketLength, hwQH.EpChars.MaximumPacketLength); dprintf("\t\t ControlEndpointFlag: %d\n", hwQH.EpChars.ControlEndpointFlag); dprintf("\t\t NakReloadCount: %d\n", hwQH.EpChars.NakReloadCount); dprintf("\t HwQH.EpCaps %08.8x\n", hwQH.EpCaps.ul); dprintf("\t\t InterruptScheduleMask: 0x%x\n", hwQH.EpCaps.InterruptScheduleMask); dprintf("\t\t SplitCompletionMask: 0x%x\n", hwQH.EpCaps.SplitCompletionMask); dprintf("\t\t HubAddress: 0x%x\n", hwQH.EpCaps.HubAddress); dprintf("\t\t PortNumber: 0x%x\n", hwQH.EpCaps.PortNumber); dprintf("\t\t HighBWPipeMultiplier: 0x%x\n", hwQH.EpCaps.HighBWPipeMultiplier); dprintf("\t HwQH.CurrentTD %08.8x\n", hwQH.CurrentTD.HwAddress); dprintf("\t HwQH.Overlay\n"); DumpEHCI_qTD((PHW_QUEUE_ELEMENT_TD)&hwQH.Overlay); } VOID DumpEHCI_Qh( MEMLOC MemLoc ) { UCHAR cs[] = "usbehci!_HCD_QUEUEHEAD_DESCRIPTOR"; ULONG f, s; STRUC_ENTRY t[] = { "PhysicalAddress", FT_ULONG, "Sig", FT_ULONG, "QhFlags", FT_ULONG, "Ordinal", FT_ULONG, "Period", FT_ULONG, "Reserved", FT_ULONG, "EndpointData", FT_PTR, "NextQh", FT_PTR, "PrevQh", FT_PTR, "NextLink", FT_PTR }; FLAG_TABLE qhFlags[] = { "EHCI_QH_FLAG_IN_SCHEDULE", EHCI_QH_FLAG_IN_SCHEDULE, "EHCI_QH_FLAG_QH_REMOVED", EHCI_QH_FLAG_QH_REMOVED, "EHCI_QH_FLAG_STATIC", EHCI_QH_FLAG_STATIC, "EHCI_QH_FLAG_HIGHSPEED", EHCI_QH_FLAG_HIGHSPEED, }; s = UsbReadFieldUlong(MemLoc, cs, "Sig"); f = UsbReadFieldUlong(MemLoc, cs, "Flags"); if (s != SIG_HCD_AQH && s != SIG_HCD_QH) { } PrintfMemLoc("*USBEHCI QH ", MemLoc, "\n"); UsbDumpStruc(MemLoc, cs, &t[0], sizeof(t)/sizeof(STRUC_ENTRY)); UsbDumpFlags(f, qhFlags, sizeof(qhFlags)/sizeof(FLAG_TABLE)); DumpEHCI_HwQh(MemLoc); } VOID DumpEHCI_EndpointData( MEMLOC MemLoc ) { UCHAR cs[] = "usbehci!_ENDPOINT_DATA"; UCHAR ts[] = "usbehci!_HCD_TRANSFER_DESCRIPTOR"; ULONG f, i=0; MEMLOC head, tail, m; STRUC_ENTRY t[] = { "Sig", FT_SIG, "QueueHead", FT_PTR, "PendingTransfers", FT_ULONG, "MaxPendingTransfers", FT_ULONG, "HcdTailP", FT_PTR, "HcdHeadP", FT_PTR, "StaticQH", FT_PTR, "PeriodTableEntry", FT_PTR, "TdList", FT_PTR, "SiTdList", FT_PTR, "HsIsoTdList", FT_PTR, "TdCount", FT_ULONG, "PrevEndpoint", FT_PTR, "NextEndpoint", FT_PTR, "DummyTd", FT_PTR, "LastFrame", FT_ULONG, "TransferList.Flink", FT_PTR, "TransferList.Blink", FT_PTR, //"MaxErrorCount", FT_ULONG, }; FLAG_TABLE epFlags[] = { "EHCI_EDFLAG_HALTED", EHCI_EDFLAG_HALTED, "EHCI_EDFLAG_NOHALT", EHCI_EDFLAG_NOHALT }; PrintfMemLoc("*USBEHCI ENDPOINT_DATA ", MemLoc, "\n"); UsbDumpStruc(MemLoc, cs, &t[0], sizeof(t)/sizeof(STRUC_ENTRY)); f = UsbReadFieldUlong(MemLoc, cs, "Flags"); dprintf("Flags: 0x%08.8x\n", f); UsbDumpFlags(f, epFlags, sizeof(epFlags)/sizeof(FLAG_TABLE)); DumpEndpointParameters(MemLoc + UsbFieldOffset(cs, "Parameters")); // dump the transfers head = UsbReadFieldPtr(MemLoc, cs, "HcdHeadP"); tail = UsbReadFieldPtr(MemLoc, cs, "HcdTailP"); PrintfMemLoc("
", head, "\n"); while (head != tail && i<32) { i++; dprintf("\t TD "); PrintfMemLoc("", head, " "); dprintf ("[%08.8x] ", UsbReadFieldUlong(head, ts, "PhysicalAddress")); m = UsbReadFieldPtr(head, ts, "TransferContext"); PrintfMemLoc("XFER ", m, "\n"); head = UsbReadFieldPtr(head, ts, "NextHcdTD"); } PrintfMemLoc("