]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
MdeModulePkg/EhciDxe: Use BaseLib linked list iteration macros
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / EhciDebug.c
CommitLineData
913cb9dc 1/** @file\r
2\r
78c2ffb5 3 This file provides the information dump support for EHCI when in debug mode.\r
4\r
f87bc6e5 5Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
e33d3e7f 6Copyright (c) Microsoft Corporation.<BR>\r
9d510e61 7SPDX-License-Identifier: BSD-2-Clause-Patent\r
913cb9dc 8\r
913cb9dc 9**/\r
10\r
11\r
12#include "Ehci.h"\r
13\r
913cb9dc 14/**\r
78c2ffb5 15 Dump the status byte in QTD/QH to a more friendly format.\r
913cb9dc 16\r
78c2ffb5 17 @param State The state in the QTD/QH.\r
913cb9dc 18\r
913cb9dc 19**/\r
913cb9dc 20VOID\r
21EhcDumpStatus (\r
1c619535 22 IN UINT32 State\r
913cb9dc 23 )\r
24{\r
25 if (EHC_BIT_IS_SET (State, QTD_STAT_DO_PING)) {\r
f87bc6e5 26 DEBUG ((EFI_D_VERBOSE, " Do_Ping"));\r
913cb9dc 27 } else {\r
f87bc6e5 28 DEBUG ((EFI_D_VERBOSE, " Do_Out"));\r
913cb9dc 29 }\r
30\r
31 if (EHC_BIT_IS_SET (State, QTD_STAT_DO_CS)) {\r
f87bc6e5 32 DEBUG ((EFI_D_VERBOSE, " Do_CS"));\r
913cb9dc 33 } else {\r
f87bc6e5 34 DEBUG ((EFI_D_VERBOSE, " Do_SS"));\r
913cb9dc 35 }\r
36\r
37 if (EHC_BIT_IS_SET (State, QTD_STAT_TRANS_ERR)) {\r
f87bc6e5 38 DEBUG ((EFI_D_VERBOSE, " Transfer_Error"));\r
913cb9dc 39 }\r
40\r
41 if (EHC_BIT_IS_SET (State, QTD_STAT_BABBLE_ERR)) {\r
f87bc6e5 42 DEBUG ((EFI_D_VERBOSE, " Babble_Error"));\r
913cb9dc 43 }\r
44\r
45 if (EHC_BIT_IS_SET (State, QTD_STAT_BUFF_ERR)) {\r
f87bc6e5 46 DEBUG ((EFI_D_VERBOSE, " Buffer_Error"));\r
913cb9dc 47 }\r
48\r
49 if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) {\r
f87bc6e5 50 DEBUG ((EFI_D_VERBOSE, " Halted"));\r
913cb9dc 51 }\r
52\r
53 if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) {\r
f87bc6e5 54 DEBUG ((EFI_D_VERBOSE, " Active"));\r
913cb9dc 55 }\r
56\r
f87bc6e5 57 DEBUG ((EFI_D_VERBOSE, "\n"));\r
913cb9dc 58}\r
59\r
60\r
61/**\r
78c2ffb5 62 Dump the fields of a QTD.\r
913cb9dc 63\r
78c2ffb5 64 @param Qtd The QTD to dump.\r
65 @param Msg The message to print before the dump.\r
913cb9dc 66\r
913cb9dc 67**/\r
68VOID\r
69EhcDumpQtd (\r
70 IN EHC_QTD *Qtd,\r
1c619535 71 IN CHAR8 *Msg\r
913cb9dc 72 )\r
73{\r
74 QTD_HW *QtdHw;\r
75 UINTN Index;\r
913cb9dc 76\r
77 if (Msg != NULL) {\r
f87bc6e5 78 DEBUG ((EFI_D_VERBOSE, Msg));\r
913cb9dc 79 }\r
80\r
f87bc6e5 81 DEBUG ((EFI_D_VERBOSE, "Queue TD @ 0x%p, data length %d\n", Qtd, (UINT32)Qtd->DataLen));\r
913cb9dc 82\r
83 QtdHw = &Qtd->QtdHw;\r
84\r
f87bc6e5
FT
85 DEBUG ((EFI_D_VERBOSE, "Next QTD : %x\n", QtdHw->NextQtd));\r
86 DEBUG ((EFI_D_VERBOSE, "AltNext QTD : %x\n", QtdHw->AltNext));\r
87 DEBUG ((EFI_D_VERBOSE, "Status : %x\n", QtdHw->Status));\r
1c619535 88 EhcDumpStatus (QtdHw->Status);\r
913cb9dc 89\r
90 if (QtdHw->Pid == QTD_PID_SETUP) {\r
f87bc6e5 91 DEBUG ((EFI_D_VERBOSE, "PID : Setup\n"));\r
913cb9dc 92\r
93 } else if (QtdHw->Pid == QTD_PID_INPUT) {\r
f87bc6e5 94 DEBUG ((EFI_D_VERBOSE, "PID : IN\n"));\r
913cb9dc 95\r
96 } else if (QtdHw->Pid == QTD_PID_OUTPUT) {\r
f87bc6e5 97 DEBUG ((EFI_D_VERBOSE, "PID : OUT\n"));\r
913cb9dc 98\r
99 }\r
100\r
f87bc6e5
FT
101 DEBUG ((EFI_D_VERBOSE, "Error Count : %d\n", QtdHw->ErrCnt));\r
102 DEBUG ((EFI_D_VERBOSE, "Current Page : %d\n", QtdHw->CurPage));\r
103 DEBUG ((EFI_D_VERBOSE, "IOC : %d\n", QtdHw->Ioc));\r
104 DEBUG ((EFI_D_VERBOSE, "Total Bytes : %d\n", QtdHw->TotalBytes));\r
105 DEBUG ((EFI_D_VERBOSE, "Data Toggle : %d\n", QtdHw->DataToggle));\r
913cb9dc 106\r
107 for (Index = 0; Index < 5; Index++) {\r
f87bc6e5 108 DEBUG ((EFI_D_VERBOSE, "Page[%d] : 0x%x\n", (UINT32)Index, QtdHw->Page[Index]));\r
913cb9dc 109 }\r
110}\r
111\r
112\r
113/**\r
78c2ffb5 114 Dump the queue head.\r
913cb9dc 115\r
78c2ffb5 116 @param Qh The queue head to dump.\r
117 @param Msg The message to print before the dump.\r
118 @param DumpBuf Whether to dump the memory buffer of the associated QTD.\r
913cb9dc 119\r
913cb9dc 120**/\r
121VOID\r
122EhcDumpQh (\r
123 IN EHC_QH *Qh,\r
1c619535 124 IN CHAR8 *Msg,\r
913cb9dc 125 IN BOOLEAN DumpBuf\r
126 )\r
127{\r
128 EHC_QTD *Qtd;\r
129 QH_HW *QhHw;\r
130 LIST_ENTRY *Entry;\r
131 UINTN Index;\r
913cb9dc 132\r
133 if (Msg != NULL) {\r
f87bc6e5 134 DEBUG ((EFI_D_VERBOSE, Msg));\r
913cb9dc 135 }\r
136\r
f87bc6e5 137 DEBUG ((EFI_D_VERBOSE, "Queue head @ 0x%p, interval %ld, next qh %p\n",\r
7df7393f 138 Qh, (UINT64)Qh->Interval, Qh->NextQh));\r
913cb9dc 139\r
140 QhHw = &Qh->QhHw;\r
141\r
f87bc6e5
FT
142 DEBUG ((EFI_D_VERBOSE, "Hoziontal link: %x\n", QhHw->HorizonLink));\r
143 DEBUG ((EFI_D_VERBOSE, "Device address: %d\n", QhHw->DeviceAddr));\r
144 DEBUG ((EFI_D_VERBOSE, "Inactive : %d\n", QhHw->Inactive));\r
145 DEBUG ((EFI_D_VERBOSE, "EP number : %d\n", QhHw->EpNum));\r
146 DEBUG ((EFI_D_VERBOSE, "EP speed : %d\n", QhHw->EpSpeed));\r
147 DEBUG ((EFI_D_VERBOSE, "DT control : %d\n", QhHw->DtCtrl));\r
148 DEBUG ((EFI_D_VERBOSE, "Reclaim head : %d\n", QhHw->ReclaimHead));\r
149 DEBUG ((EFI_D_VERBOSE, "Max packet len: %d\n", QhHw->MaxPacketLen));\r
150 DEBUG ((EFI_D_VERBOSE, "Ctrl EP : %d\n", QhHw->CtrlEp));\r
151 DEBUG ((EFI_D_VERBOSE, "Nak reload : %d\n", QhHw->NakReload));\r
152\r
153 DEBUG ((EFI_D_VERBOSE, "SMask : %x\n", QhHw->SMask));\r
154 DEBUG ((EFI_D_VERBOSE, "CMask : %x\n", QhHw->CMask));\r
155 DEBUG ((EFI_D_VERBOSE, "Hub address : %d\n", QhHw->HubAddr));\r
156 DEBUG ((EFI_D_VERBOSE, "Hub port : %d\n", QhHw->PortNum));\r
157 DEBUG ((EFI_D_VERBOSE, "Multiplier : %d\n", QhHw->Multiplier));\r
158\r
159 DEBUG ((EFI_D_VERBOSE, "Cur QTD : %x\n", QhHw->CurQtd));\r
160\r
161 DEBUG ((EFI_D_VERBOSE, "Next QTD : %x\n", QhHw->NextQtd));\r
162 DEBUG ((EFI_D_VERBOSE, "AltNext QTD : %x\n", QhHw->AltQtd));\r
163 DEBUG ((EFI_D_VERBOSE, "Status : %x\n", QhHw->Status));\r
1c619535 164\r
165 EhcDumpStatus (QhHw->Status);\r
913cb9dc 166\r
167 if (QhHw->Pid == QTD_PID_SETUP) {\r
f87bc6e5 168 DEBUG ((EFI_D_VERBOSE, "PID : Setup\n"));\r
913cb9dc 169\r
170 } else if (QhHw->Pid == QTD_PID_INPUT) {\r
f87bc6e5 171 DEBUG ((EFI_D_VERBOSE, "PID : IN\n"));\r
913cb9dc 172\r
173 } else if (QhHw->Pid == QTD_PID_OUTPUT) {\r
f87bc6e5 174 DEBUG ((EFI_D_VERBOSE, "PID : OUT\n"));\r
913cb9dc 175 }\r
176\r
f87bc6e5
FT
177 DEBUG ((EFI_D_VERBOSE, "Error Count : %d\n", QhHw->ErrCnt));\r
178 DEBUG ((EFI_D_VERBOSE, "Current Page : %d\n", QhHw->CurPage));\r
179 DEBUG ((EFI_D_VERBOSE, "IOC : %d\n", QhHw->Ioc));\r
180 DEBUG ((EFI_D_VERBOSE, "Total Bytes : %d\n", QhHw->TotalBytes));\r
181 DEBUG ((EFI_D_VERBOSE, "Data Toggle : %d\n", QhHw->DataToggle));\r
913cb9dc 182\r
183 for (Index = 0; Index < 5; Index++) {\r
f87bc6e5 184 DEBUG ((EFI_D_VERBOSE, "Page[%d] : 0x%x\n", Index, QhHw->Page[Index]));\r
913cb9dc 185 }\r
186\r
f87bc6e5 187 DEBUG ((EFI_D_VERBOSE, "\n"));\r
913cb9dc 188\r
e33d3e7f 189 BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) {\r
913cb9dc 190 Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);\r
191 EhcDumpQtd (Qtd, NULL);\r
192\r
193 if (DumpBuf && (Qtd->DataLen != 0)) {\r
194 EhcDumpBuf (Qtd->Data, Qtd->DataLen);\r
195 }\r
196 }\r
197}\r
198\r
199\r
200/**\r
78c2ffb5 201 Dump the buffer in the form of hex.\r
913cb9dc 202\r
78c2ffb5 203 @param Buf The buffer to dump.\r
204 @param Len The length of buffer.\r
913cb9dc 205\r
913cb9dc 206**/\r
207VOID\r
208EhcDumpBuf (\r
209 IN UINT8 *Buf,\r
210 IN UINTN Len\r
211 )\r
212{\r
213 UINTN Index;\r
214\r
215 for (Index = 0; Index < Len; Index++) {\r
216 if (Index % 16 == 0) {\r
f87bc6e5 217 DEBUG ((EFI_D_VERBOSE,"\n"));\r
913cb9dc 218 }\r
219\r
f87bc6e5 220 DEBUG ((EFI_D_VERBOSE, "%02x ", Buf[Index]));\r
913cb9dc 221 }\r
222\r
f87bc6e5 223 DEBUG ((EFI_D_VERBOSE, "\n"));\r
913cb9dc 224}\r
d03171ef 225\r
d03171ef 226\r