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