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