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