Import EhciDxe and UhciDxe into MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UhciDxe / UhciDebug.c
1 /** @file
2
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
8
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.
11
12 Module Name:
13
14 UhciDebug.c
15
16 Abstract:
17
18 This file provides the information dump support for Uhci when in debug mode.
19 You can dynamically adjust the debug level by changing variable gEHCDebugLevel
20 and gEHCErrorLevel.
21
22 Revision History
23
24
25 **/
26
27 #include "Uhci.h"
28 #include "UhciDebug.h"
29
30 #ifdef EFI_DEBUG
31
32 UINTN mUhciDebugMask = USB_DEBUG_FORCE_OUTPUT;
33
34
35 /**
36 Debug debug print interface for UHCI
37
38 @param Format String to use for the print, followed by print arguments
39
40 @return None
41
42 **/
43 VOID
44 UhciDebug (
45 IN CHAR8 *Format,
46 ...
47 )
48 {
49 VA_LIST Marker;
50
51 VA_START (Marker, Format);
52 DebugVPrint (DEBUG_INFO, Format, Marker);
53 VA_END (Marker);
54 }
55
56
57 /**
58 Debug error print interface for UHCI
59
60 @param Format String to use for the print, followed by print arguments
61
62 @return None
63
64 **/
65 VOID
66 UhciError (
67 IN CHAR8 *Format,
68 ...
69 )
70 {
71 VA_LIST Marker;
72
73 VA_START (Marker, Format);
74 DebugVPrint (DEBUG_ERROR, Format, Marker);
75 VA_END (Marker);
76 }
77
78
79
80 /**
81 Debug print interface for UHCI
82
83 @param Level Level to control debug print
84 @param Format String to use for the print, followed by print arguments
85
86 @return None
87
88 **/
89 VOID
90 UhciDebugPrint (
91 IN UINTN Level,
92 IN CHAR8 *Format,
93 ...
94 )
95 {
96 VA_LIST Marker;
97
98 VA_START (Marker, Format);
99
100 if (Level & mUhciDebugMask) {
101 if (mUhciDebugMask & USB_DEBUG_FORCE_OUTPUT) {
102 DebugVPrint (DEBUG_ERROR, Format, Marker);
103 } else {
104 DebugVPrint (DEBUG_INFO, Format, Marker);
105 }
106 }
107
108 VA_END (Marker);
109 }
110
111
112 /**
113 Dump the content of QH structure
114
115 @param QhSw Pointer to software QH structure
116
117 @return None
118
119 **/
120 VOID
121 UhciDumpQh (
122 IN UHCI_QH_SW *QhSw
123 )
124 {
125 UINTN Level;
126
127 Level = UHCI_DEBUG_QH;
128
129 UhciDebugPrint (Level, "&QhSw @ 0x%x\n", QhSw);
130 UhciDebugPrint (Level, "QhSw.NextQh - 0x%x\n", QhSw->NextQh);
131 UhciDebugPrint (Level, "QhSw.TDs - 0x%x\n", QhSw->TDs);
132 UhciDebugPrint (Level, "QhSw.QhHw:\n");
133 UhciDebugPrint (Level, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink);
134 UhciDebugPrint (Level, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink);
135 }
136
137
138 /**
139 Dump the content of TD structure.
140
141 @param TdSw Pointer to software TD structure
142 @param IsCur Whether dump the whole list, or only dump the current TD
143
144 @return None
145
146 **/
147 VOID
148 UhciDumpTds (
149 IN UHCI_TD_SW *TdSw
150 )
151 {
152 UHCI_TD_SW *CurTdSw;
153 UINTN Level;
154
155 Level = UHCI_DEBUG_TD;
156 CurTdSw = TdSw;
157
158 while (CurTdSw != NULL) {
159 UhciDebugPrint (Level, "TdSw @ 0x%x\n", CurTdSw);
160 UhciDebugPrint (Level, "TdSw.NextTd - 0x%x\n", CurTdSw->NextTd);
161 UhciDebugPrint (Level, "TdSw.DataLen - %d\n", CurTdSw->DataLen);
162 UhciDebugPrint (Level, "TdSw.Data - 0x%x\n", CurTdSw->Data);
163 UhciDebugPrint (Level, "TdHw:\n");
164 UhciDebugPrint (Level, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink);
165 UhciDebugPrint (Level, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen);
166 UhciDebugPrint (Level, " Status - 0x%x\n", CurTdSw->TdHw.Status);
167 UhciDebugPrint (Level, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl);
168 UhciDebugPrint (Level, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch);
169 UhciDebugPrint (Level, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed);
170 UhciDebugPrint (Level, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount);
171 UhciDebugPrint (Level, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket);
172 UhciDebugPrint (Level, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode);
173 UhciDebugPrint (Level, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr);
174 UhciDebugPrint (Level, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint);
175 UhciDebugPrint (Level, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle);
176 UhciDebugPrint (Level, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen);
177 UhciDebugPrint (Level, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer);
178
179 CurTdSw = CurTdSw->NextTd;
180 }
181 }
182
183 #endif