Takahiro HAYASHI
2014-09-19 11:06:16 UTC
Hello,
This patch does NOT improve xhci.c at all but may (or not) help
people who try to read debugging hexdump even though they are not
familiar with it.
This patch is imcomplete, buggy, and does not support all requests.
For example, you can read TRB values in human-readable form like this:
Before:
xhci0: xhci_do_command: input: 0x000000000355e000 0x00000000 0x01002c00
xhci0: xhci_do_command: output: 0x00000000033aa010 0x01000000 0x01008401
After:
xhci0: xhci_do_command: input: 0x000000000355e000 0x00000000 0x01002c00
TYPE_ADDRESS_DEVICE(11) slot 1 bsr 0 ictx 000000000355e000 c 0
xhci0: xhci_do_command: output: 0x00000000033aa010 0x01000000 0x01008401
EVENT_CMD_COMPLETE(33) SUCCESS(1) slot 1 vf 0 c 1 param 0 cmd 00000000033aa010
by inserting xhci_dump_trb() to appropriate positions.
--- xhci.c.orig 2014-08-12 23:29:37.000000000 +0900
+++ xhci.c 2014-09-19 08:04:11.000000000 +0900
@@ -1734,6 +2451,7 @@ xhci_do_command(struct xhci_softc * cons
device_printf(sc->sc_dev, "%s input: "
"0x%016"PRIx64" 0x%08"PRIx32" 0x%08"PRIx32"\n", __func__,
trb->trb_0, trb->trb_2, trb->trb_3);
+ xhci_dump_trb(-1, trb);
mutex_enter(&sc->sc_lock);
@@ -1759,6 +2477,7 @@ xhci_do_command(struct xhci_softc * cons
device_printf(sc->sc_dev, "%s output: "
"0x%016"PRIx64" 0x%08"PRIx32" 0x%08"PRIx32"\n", __func__,
trb->trb_0, trb->trb_2, trb->trb_3);
+ xhci_dump_trb(-1, trb);
switch (XHCI_TRB_2_ERROR_GET(trb->trb_2)) {
case XHCI_TRB_ERROR_SUCCESS:
For example, you can see device request and reply in human-readable form
like this:
Before:
req: 80 06 0200 0000 0009
req: 80 06 0200 0000 001f
After:
req: GET_DESCRIPTOR(6) IN,STAND,DEV CONFIG(0x0200) idx 0000 len 9
getdesc: len 9: CONFIG(2) len 9<len 31 noiface 1 confval 1 iconf 0 attr e0 pwr 0>
req: GET_DESCRIPTOR(6) IN,STAND,DEV CONFIG(0x0200) idx 0000 len 31
getdesc: len 31: CONFIG(2) len 9<len 31 noiface 1 confval 1 iconf 0 attr e0 pwr 0>, INTERFACE(4) len 9<>, ENDPOINT(5) len 7<notyet>, SSEP_COMPANION(48) len 6<maxburst 0 attr 00 b/i 2>
by adding xhci_dump_{req,reply}().
--- xhci.c.orig 2014-08-12 23:29:37.000000000 +0900
+++ xhci.c 2014-09-19 08:04:11.000000000 +0900
@@ -1235,6 +1801,10 @@ xhci_handle_event(struct xhci_softc * co
}
xfer->status = err;
+ if (err == USBD_NORMAL_COMPLETION && (trb_0 & 0x3) == 0x3) {
+ xhci_dump_reply(0, xfer);
+ }
+
//mutex_enter(&sc->sc_lock); /* XXX ??? */
if ((trb_3 & XHCI_TRB_3_ED_BIT) != 0) {
if ((trb_0 & 0x3) == 0x0) {
@@ -2541,10 +3491,8 @@ xhci_device_ctrl_start(usbd_xfer_handle
uint32_t control;
u_int i;
- DPRINTF(("%s\n", __func__));
- DPRINTF(("req: %02x %02x %04x %04x %04x\n", req->bmRequestType,
- req->bRequest, UGETW(req->wValue), UGETW(req->wIndex),
- UGETW(req->wLength)));
+ DPRINTF(("req: ));
+ xhci_dump_req(0, req);
/* XXX */
if (tr->is_halted) {
Thanks,
This patch does NOT improve xhci.c at all but may (or not) help
people who try to read debugging hexdump even though they are not
familiar with it.
This patch is imcomplete, buggy, and does not support all requests.
For example, you can read TRB values in human-readable form like this:
Before:
xhci0: xhci_do_command: input: 0x000000000355e000 0x00000000 0x01002c00
xhci0: xhci_do_command: output: 0x00000000033aa010 0x01000000 0x01008401
After:
xhci0: xhci_do_command: input: 0x000000000355e000 0x00000000 0x01002c00
TYPE_ADDRESS_DEVICE(11) slot 1 bsr 0 ictx 000000000355e000 c 0
xhci0: xhci_do_command: output: 0x00000000033aa010 0x01000000 0x01008401
EVENT_CMD_COMPLETE(33) SUCCESS(1) slot 1 vf 0 c 1 param 0 cmd 00000000033aa010
by inserting xhci_dump_trb() to appropriate positions.
--- xhci.c.orig 2014-08-12 23:29:37.000000000 +0900
+++ xhci.c 2014-09-19 08:04:11.000000000 +0900
@@ -1734,6 +2451,7 @@ xhci_do_command(struct xhci_softc * cons
device_printf(sc->sc_dev, "%s input: "
"0x%016"PRIx64" 0x%08"PRIx32" 0x%08"PRIx32"\n", __func__,
trb->trb_0, trb->trb_2, trb->trb_3);
+ xhci_dump_trb(-1, trb);
mutex_enter(&sc->sc_lock);
@@ -1759,6 +2477,7 @@ xhci_do_command(struct xhci_softc * cons
device_printf(sc->sc_dev, "%s output: "
"0x%016"PRIx64" 0x%08"PRIx32" 0x%08"PRIx32"\n", __func__,
trb->trb_0, trb->trb_2, trb->trb_3);
+ xhci_dump_trb(-1, trb);
switch (XHCI_TRB_2_ERROR_GET(trb->trb_2)) {
case XHCI_TRB_ERROR_SUCCESS:
For example, you can see device request and reply in human-readable form
like this:
Before:
req: 80 06 0200 0000 0009
req: 80 06 0200 0000 001f
After:
req: GET_DESCRIPTOR(6) IN,STAND,DEV CONFIG(0x0200) idx 0000 len 9
getdesc: len 9: CONFIG(2) len 9<len 31 noiface 1 confval 1 iconf 0 attr e0 pwr 0>
req: GET_DESCRIPTOR(6) IN,STAND,DEV CONFIG(0x0200) idx 0000 len 31
getdesc: len 31: CONFIG(2) len 9<len 31 noiface 1 confval 1 iconf 0 attr e0 pwr 0>, INTERFACE(4) len 9<>, ENDPOINT(5) len 7<notyet>, SSEP_COMPANION(48) len 6<maxburst 0 attr 00 b/i 2>
by adding xhci_dump_{req,reply}().
--- xhci.c.orig 2014-08-12 23:29:37.000000000 +0900
+++ xhci.c 2014-09-19 08:04:11.000000000 +0900
@@ -1235,6 +1801,10 @@ xhci_handle_event(struct xhci_softc * co
}
xfer->status = err;
+ if (err == USBD_NORMAL_COMPLETION && (trb_0 & 0x3) == 0x3) {
+ xhci_dump_reply(0, xfer);
+ }
+
//mutex_enter(&sc->sc_lock); /* XXX ??? */
if ((trb_3 & XHCI_TRB_3_ED_BIT) != 0) {
if ((trb_0 & 0x3) == 0x0) {
@@ -2541,10 +3491,8 @@ xhci_device_ctrl_start(usbd_xfer_handle
uint32_t control;
u_int i;
- DPRINTF(("%s\n", __func__));
- DPRINTF(("req: %02x %02x %04x %04x %04x\n", req->bmRequestType,
- req->bRequest, UGETW(req->wValue), UGETW(req->wIndex),
- UGETW(req->wLength)));
+ DPRINTF(("req: ));
+ xhci_dump_req(0, req);
/* XXX */
if (tr->is_halted) {
Thanks,
--
t-hash
t-hash