]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
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
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.
17 This file provides the information dump support for EHCI when in debug mode.
18 You can dynamically adjust the debug level by changing variable mEhcDebugLevel
29 UINTN mEhcDebugMask
= USB_DEBUG_FORCE_OUTPUT
;
33 EHCI's debug output function. It determines whether
34 to output by the mask and level
36 @param Level The output level
37 @param Format The format parameters to the print
38 @param ... The variable length parameters after format
53 VA_START (Marker
, Format
);
55 if (Level
& mEhcDebugMask
) {
56 if (mEhcDebugMask
& USB_DEBUG_FORCE_OUTPUT
) {
57 DebugVPrint (DEBUG_ERROR
, Format
, Marker
);
59 DebugVPrint (DEBUG_INFO
, Format
, Marker
);
68 EHCI's debug output function. It determines whether
69 to output by the mask and level
71 @param Format The format parameters to the print
72 @param ... The variable length parameters after format
85 VA_START (Marker
, Format
);
86 DebugVPrint (DEBUG_INFO
, Format
, Marker
);
92 EHCI's error output function. It determines whether
93 to output by the mask and level
95 @param Format The format parameters to the print
96 @param ... The variable length parameters after format
110 VA_START (Marker
, Format
);
111 DebugVPrint (DEBUG_ERROR
, Format
, Marker
);
117 Dump the status byte in QTD/QH to a more friendly
120 @param State The state in the QTD/QH
121 @param Level The output level
133 if (EHC_BIT_IS_SET (State
, QTD_STAT_DO_PING
)) {
134 EhciDebugPrint (Level
, " Do_Ping");
136 EhciDebugPrint (Level
, " Do_Out");
139 if (EHC_BIT_IS_SET (State
, QTD_STAT_DO_CS
)) {
140 EhciDebugPrint (Level
, " Do_CS");
142 EhciDebugPrint (Level
, " Do_SS");
145 if (EHC_BIT_IS_SET (State
, QTD_STAT_TRANS_ERR
)) {
146 EhciDebugPrint (Level
, " Transfer_Error");
149 if (EHC_BIT_IS_SET (State
, QTD_STAT_BABBLE_ERR
)) {
150 EhciDebugPrint (Level
, " Babble_Error");
153 if (EHC_BIT_IS_SET (State
, QTD_STAT_BUFF_ERR
)) {
154 EhciDebugPrint (Level
, " Buffer_Error");
157 if (EHC_BIT_IS_SET (State
, QTD_STAT_HALTED
)) {
158 EhciDebugPrint (Level
, " Halted");
161 if (EHC_BIT_IS_SET (State
, QTD_STAT_ACTIVE
)) {
162 EhciDebugPrint (Level
, " Active");
165 EhciDebugPrint (Level
, "\n");
170 Dump the fields of a QTD
172 @param Qtd The QTD to dump
173 @param Msg The message to print before the dump
188 Level
= EHC_DEBUG_QTD
;
191 EhciDebugPrint (Level
, Msg
);
194 EhciDebugPrint (Level
, "Queue TD @ 0x%x, data length %d\n", Qtd
, Qtd
->DataLen
);
198 EhciDebugPrint (Level
, "Next QTD : %x\n", QtdHw
->NextQtd
);
199 EhciDebugPrint (Level
, "AltNext QTD : %x\n", QtdHw
->AltNext
);
200 EhciDebugPrint (Level
, "Status : %x\n", QtdHw
->Status
);
201 EhcDumpStatus (QtdHw
->Status
, Level
);
203 if (QtdHw
->Pid
== QTD_PID_SETUP
) {
204 EhciDebugPrint (Level
, "PID : Setup\n");
206 } else if (QtdHw
->Pid
== QTD_PID_INPUT
) {
207 EhciDebugPrint (Level
, "PID : IN\n");
209 } else if (QtdHw
->Pid
== QTD_PID_OUTPUT
) {
210 EhciDebugPrint (Level
, "PID : OUT\n");
214 EhciDebugPrint (Level
, "Error Count : %d\n", QtdHw
->ErrCnt
);
215 EhciDebugPrint (Level
, "Current Page : %d\n", QtdHw
->CurPage
);
216 EhciDebugPrint (Level
, "IOC : %d\n", QtdHw
->IOC
);
217 EhciDebugPrint (Level
, "Total Bytes : %d\n", QtdHw
->TotalBytes
);
218 EhciDebugPrint (Level
, "Data Toggle : %d\n", QtdHw
->DataToggle
);
220 for (Index
= 0; Index
< 5; Index
++) {
221 EhciDebugPrint (Level
, "Page[%d] : 0x%x\n", Index
, QtdHw
->Page
[Index
]);
229 @param Qh The queue head to dump
230 @param Msg The message to print before the dump
231 @param DumpBuf Whether to dump the memory buffer of the associated QTD
249 Level
= EHC_DEBUG_QH
;
252 EhciDebugPrint (Level
, Msg
);
255 EhciDebugPrint (Level
, "Queue head @ 0x%x, interval %d, next qh %x\n",
256 Qh
, Qh
->Interval
, Qh
->NextQh
);
260 EhciDebugPrint (Level
, "Hoziontal link: %x\n", QhHw
->HorizonLink
);
261 EhciDebugPrint (Level
, "Device address: %d\n", QhHw
->DeviceAddr
);
262 EhciDebugPrint (Level
, "Inactive : %d\n", QhHw
->Inactive
);
263 EhciDebugPrint (Level
, "EP number : %d\n", QhHw
->EpNum
);
264 EhciDebugPrint (Level
, "EP speed : %d\n", QhHw
->EpSpeed
);
265 EhciDebugPrint (Level
, "DT control : %d\n", QhHw
->DtCtrl
);
266 EhciDebugPrint (Level
, "Reclaim head : %d\n", QhHw
->ReclaimHead
);
267 EhciDebugPrint (Level
, "Max packet len: %d\n", QhHw
->MaxPacketLen
);
268 EhciDebugPrint (Level
, "Ctrl EP : %d\n", QhHw
->CtrlEp
);
269 EhciDebugPrint (Level
, "Nak reload : %d\n", QhHw
->NakReload
);
271 EhciDebugPrint (Level
, "SMask : %x\n", QhHw
->SMask
);
272 EhciDebugPrint (Level
, "CMask : %x\n", QhHw
->CMask
);
273 EhciDebugPrint (Level
, "Hub address : %d\n", QhHw
->HubAddr
);
274 EhciDebugPrint (Level
, "Hub port : %d\n", QhHw
->PortNum
);
275 EhciDebugPrint (Level
, "Multiplier : %d\n", QhHw
->Multiplier
);
277 EhciDebugPrint (Level
, "Cur QTD : %x\n", QhHw
->CurQtd
);
279 EhciDebugPrint (Level
, "Next QTD : %x\n", QhHw
->NextQtd
);
280 EhciDebugPrint (Level
, "AltNext QTD : %x\n", QhHw
->AltQtd
);
281 EhciDebugPrint (Level
, "Status : %x\n", QhHw
->Status
);
282 EhcDumpStatus (QhHw
->Status
, Level
);
284 if (QhHw
->Pid
== QTD_PID_SETUP
) {
285 EhciDebugPrint (Level
, "PID : Setup\n");
287 } else if (QhHw
->Pid
== QTD_PID_INPUT
) {
288 EhciDebugPrint (Level
, "PID : IN\n");
290 } else if (QhHw
->Pid
== QTD_PID_OUTPUT
) {
291 EhciDebugPrint (Level
, "PID : OUT\n");
294 EhciDebugPrint (Level
, "Error Count : %d\n", QhHw
->ErrCnt
);
295 EhciDebugPrint (Level
, "Current Page : %d\n", QhHw
->CurPage
);
296 EhciDebugPrint (Level
, "IOC : %d\n", QhHw
->IOC
);
297 EhciDebugPrint (Level
, "Total Bytes : %d\n", QhHw
->TotalBytes
);
298 EhciDebugPrint (Level
, "Data Toggle : %d\n", QhHw
->DataToggle
);
300 for (Index
= 0; Index
< 5; Index
++) {
301 EhciDebugPrint (Level
, "Page[%d] : 0x%x\n", Index
, QhHw
->Page
[Index
]);
304 EhciDebugPrint (Level
, "\n");
306 EFI_LIST_FOR_EACH (Entry
, &Qh
->Qtds
) {
307 Qtd
= EFI_LIST_CONTAINER (Entry
, EHC_QTD
, QtdList
);
308 EhcDumpQtd (Qtd
, NULL
);
310 if (DumpBuf
&& (Qtd
->DataLen
!= 0)) {
311 EhcDumpBuf (Qtd
->Data
, Qtd
->DataLen
);
318 Dump the buffer in the form of hex
320 @param Buf The buffer to dump
321 @param Len The length of buffer
334 for (Index
= 0; Index
< Len
; Index
++) {
335 if (Index
% 16 == 0) {
336 EhciDebugPrint (EHC_DEBUG_BUF
, "\n");
339 EhciDebugPrint (EHC_DEBUG_BUF
, "%02x ", Buf
[Index
]);
342 EhciDebugPrint (EHC_DEBUG_BUF
, "\n");