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