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

📄 setup.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include <u.h>#include <libc.h>#include <thread.h>#include "usb.h"#include "dat.h"#include "fns.h"voiddevspeed(Device *d, int ls){	if(fprint(d->ctl, "speed %d", !ls) < 0)		sysfatal("devspeed: write error: %r");	if(debug)		fprint(2, "usbd: %D: set speed %s\n", d, ls?"low":"high");}voidsetup0(Device *d, int type, int req, int value, int index, int count){	if(setupreq(d->ep[0], type, req, value, index, count) < 0)		sysfatal("usbd: %D: transaction error", d);}voidsetconfig(Device *d, int n){	setup0(d, RH2D|Rstandard|Rdevice, SET_CONFIGURATION, n, 0, 0);	d->state = Configured;}intgetmaxpkt(Device *d){	DDevice *dd;	byte buf[8];	int nr = -1;	if (setupreq(d->ep[0], RD2H|Rstandard|Rdevice, GET_DESCRIPTOR, (DEVICE<<8)|0, 0, sizeof(buf)) < 0 ||	   (nr = setupreply(d->ep[0], buf, sizeof(buf))) < sizeof(buf)) {		fprint(2, "usbd: getmaxpkt: error reading device descriptor for %D, got %d of %d\n", d, nr, sizeof(buf));		return -1;	}	dd = (DDevice*)buf;	return dd->bMaxPacketSize0;}intsetaddress(Device *d, int id){	if (setupreq(d->ep[0], RH2D, SET_ADDRESS, id, 0, 0) < 0) {		fprint(2, "usbd: set address %D <- %d failed\n", d, id);		return -1;	}	return 0;}

⌨️ 快捷键说明

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