⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ehci-dbg.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
		}		temp = snprintf (next, size,				"\n\t%p%c%s len=%d %08x urb %p",				td, mark, ({ char *tmp;				 switch ((scratch>>8)&0x03) {				 case 0: tmp = "out"; break;				 case 1: tmp = "in"; break;				 case 2: tmp = "setup"; break;				 default: tmp = "?"; break;				 } tmp;}),				(scratch >> 16) & 0x7fff,				scratch,				td->urb);		if (temp < 0)			temp = 0;		else if (size < temp)			temp = size;		size -= temp;		next += temp;		if (temp == size)			goto done;	}	temp = snprintf (next, size, "\n");	if (temp < 0)		temp = 0;	else if (size < temp)		temp = size;	size -= temp;	next += temp;done:	*sizep = size;	*nextp = next;}static ssize_tshow_async (struct class_device *class_dev, char *buf){	struct usb_bus		*bus;	struct usb_hcd		*hcd;	struct ehci_hcd		*ehci;	unsigned long		flags;	unsigned		temp, size;	char			*next;	struct ehci_qh		*qh;	*buf = 0;	bus = class_get_devdata(class_dev);	hcd = bus->hcpriv;	ehci = hcd_to_ehci (hcd);	next = buf;	size = PAGE_SIZE;	/* dumps a snapshot of the async schedule.	 * usually empty except for long-term bulk reads, or head.	 * one QH per line, and TDs we know about	 */	spin_lock_irqsave (&ehci->lock, flags);	for (qh = ehci->async->qh_next.qh; size > 0 && qh; qh = qh->qh_next.qh)		qh_lines (ehci, qh, &next, &size);	if (ehci->reclaim && size > 0) {		temp = scnprintf (next, size, "\nreclaim =\n");		size -= temp;		next += temp;		for (qh = ehci->reclaim; size > 0 && qh; qh = qh->reclaim)			qh_lines (ehci, qh, &next, &size);	}	spin_unlock_irqrestore (&ehci->lock, flags);	return strlen (buf);}static CLASS_DEVICE_ATTR (async, S_IRUGO, show_async, NULL);#define DBG_SCHED_LIMIT 64static ssize_tshow_periodic (struct class_device *class_dev, char *buf){	struct usb_bus		*bus;	struct usb_hcd		*hcd;	struct ehci_hcd		*ehci;	unsigned long		flags;	union ehci_shadow	p, *seen;	unsigned		temp, size, seen_count;	char			*next;	unsigned		i;	__le32			tag;	if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))		return 0;	seen_count = 0;	bus = class_get_devdata(class_dev);	hcd = bus->hcpriv;	ehci = hcd_to_ehci (hcd);	next = buf;	size = PAGE_SIZE;	temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);	size -= temp;	next += temp;	/* dump a snapshot of the periodic schedule.	 * iso changes, interrupt usually doesn't.	 */	spin_lock_irqsave (&ehci->lock, flags);	for (i = 0; i < ehci->periodic_size; i++) {		p = ehci->pshadow [i];		if (likely (!p.ptr))			continue;		tag = Q_NEXT_TYPE (ehci->periodic [i]);		temp = scnprintf (next, size, "%4d: ", i);		size -= temp;		next += temp;		do {			switch (tag) {			case Q_TYPE_QH:				temp = scnprintf (next, size, " qh%d-%04x/%p",						p.qh->period,						le32_to_cpup (&p.qh->hw_info2)							/* uframe masks */							& (QH_CMASK | QH_SMASK),						p.qh);				size -= temp;				next += temp;				/* don't repeat what follows this qh */				for (temp = 0; temp < seen_count; temp++) {					if (seen [temp].ptr != p.ptr)						continue;					if (p.qh->qh_next.ptr)						temp = scnprintf (next, size,							" ...");					p.ptr = NULL;					break;				}				/* show more info the first time around */				if (temp == seen_count && p.ptr) {					u32	scratch = le32_to_cpup (							&p.qh->hw_info1);					struct ehci_qtd	*qtd;					char		*type = "";					/* count tds, get ep direction */					temp = 0;					list_for_each_entry (qtd,							&p.qh->qtd_list,							qtd_list) {						temp++;						switch (0x03 & (le32_to_cpu (							qtd->hw_token) >> 8)) {						case 0: type = "out"; continue;						case 1: type = "in"; continue;						}					}					temp = scnprintf (next, size,						" (%c%d ep%d%s "						"[%d/%d] q%d p%d)",						speed_char (scratch),						scratch & 0x007f,						(scratch >> 8) & 0x000f, type,						p.qh->usecs, p.qh->c_usecs,						temp,						0x7ff & (scratch >> 16));					if (seen_count < DBG_SCHED_LIMIT)						seen [seen_count++].qh = p.qh;				} else					temp = 0;				if (p.qh) {					tag = Q_NEXT_TYPE (p.qh->hw_next);					p = p.qh->qh_next;				}				break;			case Q_TYPE_FSTN:				temp = scnprintf (next, size,					" fstn-%8x/%p", p.fstn->hw_prev,					p.fstn);				tag = Q_NEXT_TYPE (p.fstn->hw_next);				p = p.fstn->fstn_next;				break;			case Q_TYPE_ITD:				temp = scnprintf (next, size,					" itd/%p", p.itd);				tag = Q_NEXT_TYPE (p.itd->hw_next);				p = p.itd->itd_next;				break;			case Q_TYPE_SITD:				temp = scnprintf (next, size,					" sitd%d-%04x/%p",					p.sitd->stream->interval,					le32_to_cpup (&p.sitd->hw_uframe)						& 0x0000ffff,					p.sitd);				tag = Q_NEXT_TYPE (p.sitd->hw_next);				p = p.sitd->sitd_next;				break;			}			size -= temp;			next += temp;		} while (p.ptr);		temp = scnprintf (next, size, "\n");		size -= temp;		next += temp;	}	spin_unlock_irqrestore (&ehci->lock, flags);	kfree (seen);	return PAGE_SIZE - size;}static CLASS_DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);#undef DBG_SCHED_LIMITstatic ssize_tshow_registers (struct class_device *class_dev, char *buf){	struct usb_bus		*bus;	struct usb_hcd		*hcd;	struct ehci_hcd		*ehci;	unsigned long		flags;	unsigned		temp, size, i;	char			*next, scratch [80];	static char		fmt [] = "%*s\n";	static char		label [] = "";	bus = class_get_devdata(class_dev);	hcd = bus->hcpriv;	ehci = hcd_to_ehci (hcd);	next = buf;	size = PAGE_SIZE;	spin_lock_irqsave (&ehci->lock, flags);	if (bus->controller->power.power_state.event) {		size = scnprintf (next, size,			"bus %s, device %s (driver " DRIVER_VERSION ")\n"			"%s\n"			"SUSPENDED (no register access)\n",			hcd->self.controller->bus->name,			hcd->self.controller->bus_id,			hcd->product_desc);		goto done;	}	/* Capability Registers */	i = HC_VERSION(readl (&ehci->caps->hc_capbase));	temp = scnprintf (next, size,		"bus %s, device %s (driver " DRIVER_VERSION ")\n"		"%s\n"		"EHCI %x.%02x, hcd state %d\n",		hcd->self.controller->bus->name,		hcd->self.controller->bus_id,		hcd->product_desc,		i >> 8, i & 0x0ff, hcd->state);	size -= temp;	next += temp;#ifdef	CONFIG_PCI	/* EHCI 0.96 and later may have "extended capabilities" */	if (hcd->self.controller->bus == &pci_bus_type) {		struct pci_dev	*pdev;		u32		offset, cap, cap2;		unsigned	count = 256/4;		pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);		offset = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));		while (offset && count--) {			pci_read_config_dword (pdev, offset, &cap);			switch (cap & 0xff) {			case 1:				temp = scnprintf (next, size,					"ownership %08x%s%s\n", cap,					(cap & (1 << 24)) ? " linux" : "",					(cap & (1 << 16)) ? " firmware" : "");				size -= temp;				next += temp;				offset += 4;				pci_read_config_dword (pdev, offset, &cap2);				temp = scnprintf (next, size,					"SMI sts/enable 0x%08x\n", cap2);				size -= temp;				next += temp;				break;			case 0:		/* illegal reserved capability */				cap = 0;				/* FALLTHROUGH */			default:		/* unknown */				break;			}			temp = (cap >> 8) & 0xff;		}	}#endif	// FIXME interpret both types of params	i = readl (&ehci->caps->hcs_params);	temp = scnprintf (next, size, "structural params 0x%08x\n", i);	size -= temp;	next += temp;	i = readl (&ehci->caps->hcc_params);	temp = scnprintf (next, size, "capability params 0x%08x\n", i);	size -= temp;	next += temp;	/* Operational Registers */	temp = dbg_status_buf (scratch, sizeof scratch, label,			readl (&ehci->regs->status));	temp = scnprintf (next, size, fmt, temp, scratch);	size -= temp;	next += temp;	temp = dbg_command_buf (scratch, sizeof scratch, label,			readl (&ehci->regs->command));	temp = scnprintf (next, size, fmt, temp, scratch);	size -= temp;	next += temp;	temp = dbg_intr_buf (scratch, sizeof scratch, label,			readl (&ehci->regs->intr_enable));	temp = scnprintf (next, size, fmt, temp, scratch);	size -= temp;	next += temp;	temp = scnprintf (next, size, "uframe %04x\n",			readl (&ehci->regs->frame_index));	size -= temp;	next += temp;	for (i = 1; i <= HCS_N_PORTS (ehci->hcs_params); i++) {		temp = dbg_port_buf (scratch, sizeof scratch, label, i,				readl (&ehci->regs->port_status [i - 1]));		temp = scnprintf (next, size, fmt, temp, scratch);		size -= temp;		next += temp;		if (i == HCS_DEBUG_PORT(ehci->hcs_params) && ehci->debug) {			temp = scnprintf (next, size,					"    debug control %08x\n",					readl (&ehci->debug->control));			size -= temp;			next += temp;		}	}	if (ehci->reclaim) {		temp = scnprintf (next, size, "reclaim qh %p%s\n",				ehci->reclaim,				ehci->reclaim_ready ? " ready" : "");		size -= temp;		next += temp;	}#ifdef EHCI_STATS	temp = scnprintf (next, size,		"irq normal %ld err %ld reclaim %ld (lost %ld)\n",		ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,		ehci->stats.lost_iaa);	size -= temp;	next += temp;	temp = scnprintf (next, size, "complete %ld unlink %ld\n",		ehci->stats.complete, ehci->stats.unlink);	size -= temp;	next += temp;#endifdone:	spin_unlock_irqrestore (&ehci->lock, flags);	return PAGE_SIZE - size;}static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);static inline void create_debug_files (struct ehci_hcd *ehci){	struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;	class_device_create_file(cldev, &class_device_attr_async);	class_device_create_file(cldev, &class_device_attr_periodic);	class_device_create_file(cldev, &class_device_attr_registers);}static inline void remove_debug_files (struct ehci_hcd *ehci){	struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;	class_device_remove_file(cldev, &class_device_attr_async);	class_device_remove_file(cldev, &class_device_attr_periodic);	class_device_remove_file(cldev, &class_device_attr_registers);}#endif /* STUB_DEBUG_FILES */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -