1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/*
*
* Copyright (C) 2013 secunet Security Networks AG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <inttypes.h>
#include "xhci_private.h"
#ifdef XHCI_DUMPS
void
xhci_dump_slotctx(const slotctx_t *const sc)
{
xhci_debug("Slot Context (@%p):\n", sc);
usb_debug(" FIELD1\t0x%08"PRIx32"\n", sc->f1);
usb_debug(" FIELD2\t0x%08"PRIx32"\n", sc->f2);
usb_debug(" FIELD3\t0x%08"PRIx32"\n", sc->f3);
usb_debug(" FIELD4\t0x%08"PRIx32"\n", sc->f4);
SC_DUMP(ROUTE, sc);
SC_DUMP(SPEED1, sc);
SC_DUMP(MTT, sc);
SC_DUMP(HUB, sc);
SC_DUMP(CTXENT, sc);
SC_DUMP(RHPORT, sc);
SC_DUMP(NPORTS, sc);
SC_DUMP(TTID, sc);
SC_DUMP(TTPORT, sc);
SC_DUMP(TTT, sc);
SC_DUMP(UADDR, sc);
SC_DUMP(STATE, sc);
}
void
xhci_dump_epctx(const epctx_t *const ec)
{
xhci_debug("Endpoint Context (@%p):\n", ec);
usb_debug(" FIELD1\t0x%08"PRIx32"\n", ec->f1);
usb_debug(" FIELD2\t0x%08"PRIx32"\n", ec->f2);
usb_debug(" TRDQ_L\t0x%08"PRIx32"\n", ec->tr_dq_low);
usb_debug(" TRDQ_H\t0x%08"PRIx32"\n", ec->tr_dq_high);
usb_debug(" FIELD5\t0x%08"PRIx32"\n", ec->f5);
EC_DUMP(STATE, ec);
EC_DUMP(INTVAL, ec);
EC_DUMP(CERR, ec);
EC_DUMP(TYPE, ec);
EC_DUMP(MBS, ec);
EC_DUMP(MPS, ec);
EC_DUMP(DCS, ec);
EC_DUMP(AVRTRB, ec);
EC_DUMP(MXESIT, ec);
}
void
xhci_dump_devctx(const devctx_t *const dc, const u32 ctx_mask)
{
int i;
if (ctx_mask & 1)
xhci_dump_slotctx(dc->slot);
for (i = 1; i <= SC_GET(CTXENT, dc->slot); ++i) {
if (ctx_mask & (1 << i))
xhci_dump_epctx(dc->ep[i]);
}
}
void
xhci_dump_inputctx(const inputctx_t *const ic)
{
xhci_debug("Input Control add: 0x%08"PRIx32"\n", *ic->add);
xhci_debug("Input Control drop: 0x%08"PRIx32"\n", *ic->drop);
xhci_dump_devctx(&ic->dev, *ic->add);
}
void
xhci_dump_transfer_trb(const trb_t *const cur)
{
xhci_debug("Transfer TRB (@%p):\n", cur);
usb_debug(" PTR_L\t0x%08"PRIx32"\n", cur->ptr_low);
usb_debug(" PTR_H\t0x%08"PRIx32"\n", cur->ptr_high);
usb_debug(" STATUS\t0x%08"PRIx32"\n", cur->status);
usb_debug(" CNTRL\t0x%08"PRIx32"\n", cur->control);
TRB_DUMP(TL, cur);
TRB_DUMP(TDS, cur);
TRB_DUMP(C, cur);
TRB_DUMP(ISP, cur);
TRB_DUMP(CH, cur);
TRB_DUMP(IOC, cur);
TRB_DUMP(IDT, cur);
TRB_DUMP(TT, cur);
TRB_DUMP(DIR, cur);
}
static const trb_t *
xhci_next_trb(const trb_t *const cur)
{
if (TRB_GET(TT, cur) == TRB_LINK)
return (!cur->ptr_low) ? NULL : phys_to_virt(cur->ptr_low);
else
return cur + 1;
}
void
xhci_dump_transfer_trbs(const trb_t *const first, const trb_t *const last)
{
const trb_t *cur;
for (cur = first; cur; cur = xhci_next_trb(cur)) {
xhci_dump_transfer_trb(cur);
if (cur == last)
break;
}
}
#endif
|