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