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