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