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