📄 uhci-debug.c
字号:
/* * UHCI-specific debugging code. Invaluable when something * goes wrong, but don't get in my face. * * Kernel visible pointers are surrounded in []'s and bus * visible pointers are surrounded in ()'s * * (C) Copyright 1999 Linus Torvalds * (C) Copyright 1999-2001 Johannes Erdfelt */#include <linux/config.h>#include <linux/kernel.h>#include <linux/debugfs.h>#include <linux/smp_lock.h>#include <asm/io.h>#include "uhci-hcd.h"static struct dentry *uhci_debugfs_root = NULL;/* Handle REALLY large printk's so we don't overflow buffers */static inline void lprintk(char *buf){ char *p; /* Just write one line at a time */ while (buf) { p = strchr(buf, '\n'); if (p) *p = 0; rtdm_printk(KERN_DEBUG "%s\n", buf); buf = p; if (buf) buf++; }}static int uhci_show_td(struct uhci_td *td, char *buf, int len, int space){ char *out = buf; char *spid; u32 status, token; /* Try to make sure there's enough memory */ if (len < 160) return 0; status = td_status(td); out += sprintf(out, "%*s[%p] link (%08x) ", space, "", td, le32_to_cpu(td->link)); out += sprintf(out, "e%d %s%s%s%s%s%s%s%s%s%sLength=%x ", ((status >> 27) & 3), (status & TD_CTRL_SPD) ? "SPD " : "", (status & TD_CTRL_LS) ? "LS " : "", (status & TD_CTRL_IOC) ? "IOC " : "", (status & TD_CTRL_ACTIVE) ? "Active " : "", (status & TD_CTRL_STALLED) ? "Stalled " : "", (status & TD_CTRL_DBUFERR) ? "DataBufErr " : "", (status & TD_CTRL_BABBLE) ? "Babble " : "", (status & TD_CTRL_NAK) ? "NAK " : "", (status & TD_CTRL_CRCTIMEO) ? "CRC/Timeo " : "", (status & TD_CTRL_BITSTUFF) ? "BitStuff " : "", status & 0x7ff); token = td_token(td); switch (uhci_packetid(token)) { case USB_PID_SETUP: spid = "SETUP"; break; case USB_PID_OUT: spid = "OUT"; break; case USB_PID_IN: spid = "IN"; break; default: spid = "?"; break; } out += sprintf(out, "MaxLen=%x DT%d EndPt=%x Dev=%x, PID=%x(%s) ", token >> 21, ((token >> 19) & 1), (token >> 15) & 15, (token >> 8) & 127, (token & 0xff), spid); out += sprintf(out, "(buf=%08x)\n", le32_to_cpu(td->buffer)); return out - buf;}static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space){ char *out = buf; struct urb_priv *urbp; struct list_head *head, *tmp; struct uhci_td *td; int i = 0, checked = 0, prevactive = 0; __le32 element = qh_element(qh); /* Try to make sure there's enough memory */ if (len < 80 * 6) return 0; out += sprintf(out, "%*s[%p] link (%08x) element (%08x)\n", space, "", qh, le32_to_cpu(qh->link), le32_to_cpu(element)); if (element & UHCI_PTR_QH) out += sprintf(out, "%*s Element points to QH (bug?)\n", space, ""); if (element & UHCI_PTR_DEPTH) out += sprintf(out, "%*s Depth traverse\n", space, ""); if (element & cpu_to_le32(8)) out += sprintf(out, "%*s Bit 3 set (bug?)\n", space, ""); if (!(element & ~(UHCI_PTR_QH | UHCI_PTR_DEPTH))) out += sprintf(out, "%*s Element is NULL (bug?)\n", space, ""); if (!qh->urbp) { out += sprintf(out, "%*s urbp == NULL\n", space, ""); goto out; } urbp = qh->urbp; head = &urbp->td_list; tmp = head->next; td = list_entry(tmp, struct uhci_td, list); if (cpu_to_le32(td->dma_handle) != (element & ~UHCI_PTR_BITS)) out += sprintf(out, "%*s Element != First TD\n", space, ""); while (tmp != head) { struct uhci_td *td = list_entry(tmp, struct uhci_td, list); tmp = tmp->next; out += sprintf(out, "%*s%d: ", space + 2, "", i++); out += uhci_show_td(td, out, len - (out - buf), 0); if (i > 10 && !checked && prevactive && tmp != head && debug <= 2) { struct list_head *ntmp = tmp; struct uhci_td *ntd = td; int active = 1, ni = i; checked = 1; while (ntmp != head && ntmp->next != head && active) { ntd = list_entry(ntmp, struct uhci_td, list); ntmp = ntmp->next; active = td_status(ntd) & TD_CTRL_ACTIVE; ni++; } if (active && ni > i) { out += sprintf(out, "%*s[skipped %d active TD's]\n", space, "", ni - i); tmp = ntmp; td = ntd; i = ni; } } prevactive = td_status(td) & TD_CTRL_ACTIVE; } if (list_empty(&urbp->queue_list) || urbp->queued) goto out; out += sprintf(out, "%*sQueued QH's:\n", -space, "--"); head = &urbp->queue_list; tmp = head->next; while (tmp != head) { struct urb_priv *nurbp = list_entry(tmp, struct urb_priv, queue_list); tmp = tmp->next; out += uhci_show_qh(nurbp->qh, out, len - (out - buf), space); }out: return out - buf;}#define show_frame_num() \ if (!shown) { \ shown = 1; \ out += sprintf(out, "- Frame %d\n", i); \ }#define uhci_debug_operations (* (struct file_operations *) NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -