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