亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? short.c

?? usb的驅動程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * short.c -- Simple Hardware Operations and Raw Tests * short.c -- also a brief example of interrupt handling ("short int") * * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet * Copyright (C) 2001 O'Reilly & Associates * * The source code in this file can be freely used, adapted, * and redistributed in source or binary form, so long as an * acknowledgment appears in derived source files.  The citation * should list that the code comes from the book "Linux Device * Drivers" by Alessandro Rubini and Jonathan Corbet, published * by O'Reilly & Associates.   No warranty is attached; * we cannot take responsibility for errors or fitness for use. * * $Id: short.c,v 1.16 2004/10/29 16:45:40 corbet Exp $ *//* * FIXME: this driver is not safe with concurrent readers or * writers. */#include <linux/config.h>#include <linux/module.h>#include <linux/moduleparam.h>#include <linux/init.h>#include <linux/sched.h>#include <linux/kernel.h>	/* printk() */#include <linux/fs.h>		/* everything... */#include <linux/errno.h>	/* error codes */#include <linux/delay.h>	/* udelay */#include <linux/kdev_t.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/ioport.h>#include <linux/interrupt.h>#include <linux/workqueue.h>#include <linux/poll.h>#include <linux/wait.h>#include <asm/io.h>#define SHORT_NR_PORTS	8	/* use 8 ports by default *//* * all of the parameters have no "short_" prefix, to save typing when * specifying them at load time */static int major = 0;	/* dynamic by default */module_param(major, int, 0);static int use_mem = 0;	/* default is I/O-mapped */module_param(use_mem, int, 0);/* default is the first printer port on PC's. "short_base" is there too   because it's what we want to use in the code */static unsigned long base = 0x378;unsigned long short_base = 0;module_param(base, long, 0);/* The interrupt line is undefined by default. "short_irq" is as above */static int irq = -1;volatile int short_irq = -1;module_param(irq, int, 0);static int probe = 0;	/* select at load time how to probe irq line */module_param(probe, int, 0);static int wq = 0;	/* select at load time whether a workqueue is used */module_param(wq, int, 0);static int tasklet = 0;	/* select whether a tasklet is used */module_param(tasklet, int, 0);static int share = 0;	/* select at load time whether install a shared irq */module_param(share, int, 0);MODULE_AUTHOR ("Alessandro Rubini");MODULE_LICENSE("Dual BSD/GPL");unsigned long short_buffer = 0;unsigned long volatile short_head;volatile unsigned long short_tail;DECLARE_WAIT_QUEUE_HEAD(short_queue);/* Set up our tasklet if we're doing that. */void short_do_tasklet(unsigned long);DECLARE_TASKLET(short_tasklet, short_do_tasklet, 0);/* * Atomicly increment an index into short_buffer */static inline void short_incr_bp(volatile unsigned long *index, int delta){	unsigned long new = *index + delta;	barrier();  /* Don't optimize these two together */	*index = (new >= (short_buffer + PAGE_SIZE)) ? short_buffer : new;}/* * The devices with low minor numbers write/read burst of data to/from * specific I/O ports (by default the parallel ones). *  * The device with 128 as minor number returns ascii strings telling * when interrupts have been received. Writing to the device toggles * 00/FF on the parallel data lines. If there is a loopback wire, this * generates interrupts.   */int short_open (struct inode *inode, struct file *filp){	extern struct file_operations short_i_fops;	if (iminor (inode) & 0x80)		filp->f_op = &short_i_fops; /* the interrupt-driven node */	return 0;}int short_release (struct inode *inode, struct file *filp){	return 0;}/* first, the port-oriented device */enum short_modes {SHORT_DEFAULT=0, SHORT_PAUSE, SHORT_STRING, SHORT_MEMORY};ssize_t do_short_read (struct inode *inode, struct file *filp, char __user *buf,		size_t count, loff_t *f_pos){	int retval = count, minor = iminor (inode);	unsigned long port = short_base + (minor&0x0f);	void *address = (void *) short_base + (minor&0x0f);	int mode = (minor&0x70) >> 4;	unsigned char *kbuf = kmalloc(count, GFP_KERNEL), *ptr;    	if (!kbuf)		return -ENOMEM;	ptr = kbuf;	if (use_mem)		mode = SHORT_MEMORY;		switch(mode) {	    case SHORT_STRING:		insb(port, ptr, count);		rmb();		break;	    case SHORT_DEFAULT:		while (count--) {			*(ptr++) = inb(port);			rmb();		}		break;	    case SHORT_MEMORY:		while (count--) {			*ptr++ = ioread8(address);			rmb();		}		break;	    case SHORT_PAUSE:		while (count--) {			*(ptr++) = inb_p(port);			rmb();		}		break;	    default: /* no more modes defined by now */		retval = -EINVAL;		break;	}	if ((retval > 0) && copy_to_user(buf, kbuf, retval))		retval = -EFAULT;	kfree(kbuf);	return retval;}/* * Version-specific methods for the fops structure.  FIXME don't need anymore. */ssize_t short_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos){	return do_short_read(filp->f_dentry->d_inode, filp, buf, count, f_pos);}ssize_t do_short_write (struct inode *inode, struct file *filp, const char __user *buf,		size_t count, loff_t *f_pos){	int retval = count, minor = iminor(inode);	unsigned long port = short_base + (minor&0x0f);	void *address = (void *) short_base + (minor&0x0f);	int mode = (minor&0x70) >> 4;	unsigned char *kbuf = kmalloc(count, GFP_KERNEL), *ptr;	if (!kbuf)		return -ENOMEM;	if (copy_from_user(kbuf, buf, count))		return -EFAULT;	ptr = kbuf;	if (use_mem)		mode = SHORT_MEMORY;	switch(mode) {	case SHORT_PAUSE:		while (count--) {			outb_p(*(ptr++), port);			wmb();		}		break;	case SHORT_STRING:		outsb(port, ptr, count);		wmb();		break;	case SHORT_DEFAULT:		while (count--) {			outb(*(ptr++), port);			wmb();		}		break;	case SHORT_MEMORY:		while (count--) {			iowrite8(*ptr++, address);			wmb();		}		break;	default: /* no more modes defined by now */		retval = -EINVAL;		break;	}	kfree(kbuf);	return retval;}ssize_t short_write(struct file *filp, const char __user *buf, size_t count,		loff_t *f_pos){	return do_short_write(filp->f_dentry->d_inode, filp, buf, count, f_pos);}unsigned int short_poll(struct file *filp, poll_table *wait){	return POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM;}struct file_operations short_fops = {	.owner	 = THIS_MODULE,	.read	 = short_read,	.write	 = short_write,	.poll	 = short_poll,	.open	 = short_open,	.release = short_release,};/* then,  the interrupt-related device */ssize_t short_i_read (struct file *filp, char __user *buf, size_t count, loff_t *f_pos){	int count0;	DEFINE_WAIT(wait);	while (short_head == short_tail) {		prepare_to_wait(&short_queue, &wait, TASK_INTERRUPTIBLE);		if (short_head == short_tail)			schedule();		finish_wait(&short_queue, &wait);		if (signal_pending (current))  /* a signal arrived */			return -ERESTARTSYS; /* tell the fs layer to handle it */	} 	/* count0 is the number of readable data bytes */	count0 = short_head - short_tail;	if (count0 < 0) /* wrapped */		count0 = short_buffer + PAGE_SIZE - short_tail;	if (count0 < count) count = count0;	if (copy_to_user(buf, (char *)short_tail, count))		return -EFAULT;	short_incr_bp (&short_tail, count);	return count;}ssize_t short_i_write (struct file *filp, const char __user *buf, size_t count,		loff_t *f_pos){	int written = 0, odd = *f_pos & 1;	unsigned long port = short_base; /* output to the parallel data latch */	void *address = (void *) short_base;	if (use_mem) {		while (written < count)			iowrite8(0xff * ((++written + odd) & 1), address);	} else {		while (written < count)			outb(0xff * ((++written + odd) & 1), port);	}	*f_pos += count;	return written;}struct file_operations short_i_fops = {	.owner	 = THIS_MODULE,	.read	 = short_i_read,	.write	 = short_i_write,	.open	 = short_open,	.release = short_release,};irqreturn_t short_interrupt(int irq, void *dev_id, struct pt_regs *regs){	struct timeval tv;	int written;	do_gettimeofday(&tv);	    /* Write a 16 byte record. Assume PAGE_SIZE is a multiple of 16 */	written = sprintf((char *)short_head,"%08u.%06u\n",			(int)(tv.tv_sec % 100000000), (int)(tv.tv_usec));	BUG_ON(written != 16);	short_incr_bp(&short_head, written);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本韩国欧美一区| 色综合一区二区三区| 亚洲一区二区成人在线观看| 国产亚洲精品超碰| 久久久国产精品麻豆| 精品国产免费视频| 国产色一区二区| 国产情人综合久久777777| 国产情人综合久久777777| 欧美国产一区视频在线观看| 国产三级久久久| 综合分类小说区另类春色亚洲小说欧美 | 欧美精品1区2区| 欧美色电影在线| 日韩精品一区二区在线观看| 欧美日韩国产小视频在线观看| 亚洲午夜国产一区99re久久| 日韩码欧中文字| 亚洲综合在线电影| 另类的小说在线视频另类成人小视频在线| 国产欧美精品区一区二区三区| 在线视频你懂得一区| 欧美老肥妇做.爰bbww| 日韩一区二区视频| 国产欧美日韩在线| 综合色中文字幕| 免费成人在线网站| 国产69精品久久777的优势| 97久久超碰国产精品| 欧美一级在线观看| 日韩美女视频19| 蜜臀av性久久久久蜜臀aⅴ流畅 | 亚洲一区成人在线| 免费成人美女在线观看| 成人app在线观看| 在线不卡免费欧美| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美日韩国产乱码电影| 欧美大白屁股肥臀xxxxxx| 久久免费午夜影院| 亚洲美女屁股眼交3| 国产精品一线二线三线| 欧美在线免费播放| 日本一区免费视频| 麻豆久久久久久| 欧美日韩国产一区二区三区地区| 欧美在线一二三| 欧美激情中文字幕一区二区| 日韩国产欧美在线播放| 99re亚洲国产精品| 精品久久久久久久久久久久久久久| 欧美乱妇一区二区三区不卡视频| 91国偷自产一区二区三区观看| 99久久夜色精品国产网站| 欧美一区二区视频免费观看| 亚洲少妇中出一区| 成人免费毛片高清视频| 久久网站最新地址| 日av在线不卡| 欧美一级理论片| 偷窥少妇高潮呻吟av久久免费| 亚洲va欧美va天堂v国产综合| 亚洲国产精品久久人人爱| 国产a级毛片一区| 欧美大胆人体bbbb| 日本一不卡视频| 欧美精品乱码久久久久久| 亚洲精品一二三| 色视频欧美一区二区三区| 亚洲三级在线免费观看| jizz一区二区| 中文字幕一区二区三区蜜月| 丰满岳乱妇一区二区三区| 中文字幕免费不卡在线| 成人91在线观看| 亚洲人成网站影音先锋播放| av男人天堂一区| 亚洲欧美一区二区三区久本道91| 午夜日韩在线电影| 欧美人狂配大交3d怪物一区| 亚洲成在线观看| 91精品国产91久久久久久最新毛片| 久久先锋资源网| 精品亚洲成a人在线观看| 久久一区二区三区国产精品| 国产精品 欧美精品| 国产婷婷色一区二区三区四区| 亚洲欧美视频在线观看视频| 色综合激情久久| 首页综合国产亚洲丝袜| 3d成人h动漫网站入口| 久久99久久99精品免视看婷婷| 成人小视频免费观看| 国产精品毛片久久久久久久| 91在线免费播放| 亚洲国产人成综合网站| 欧美电影免费观看高清完整版在 | 97久久精品人人做人人爽| 亚洲九九爱视频| 欧美丰满少妇xxxxx高潮对白| 欧美国产1区2区| 欧洲另类一二三四区| 免费精品视频最新在线| 欧美激情艳妇裸体舞| 在线免费视频一区二区| 久久福利视频一区二区| 亚洲色图.com| 精品三级在线观看| 91麻豆.com| 美国毛片一区二区| 亚洲免费伊人电影| 亚洲精品一区二区三区影院| av亚洲精华国产精华精华| 免费看精品久久片| 亚洲免费在线看| 久久久久国产精品免费免费搜索| 免费在线观看一区二区三区| 欧美国产禁国产网站cc| 欧美福利电影网| 色综合中文字幕国产 | 欧美在线看片a免费观看| 黄色日韩三级电影| 亚洲电影在线免费观看| 亚洲国产精品精华液2区45| 6080午夜不卡| 色哟哟国产精品免费观看| 国产精品一区二区在线观看网站| 51精品国自产在线| 99久久精品一区二区| 久久 天天综合| 亚洲影视在线播放| 中文字幕一区二区三区不卡 | 欧美日韩成人在线一区| 国产老妇另类xxxxx| 香蕉加勒比综合久久| 日韩毛片视频在线看| 国产欧美精品一区二区三区四区 | 中文字幕在线观看不卡| 亚洲精品在线一区二区| 91麻豆精品国产91久久久久| 成人app网站| 成人免费视频一区| 国产大陆a不卡| 国产一区二区女| 国产真实乱子伦精品视频| 免费人成在线不卡| 麻豆成人91精品二区三区| 视频一区欧美精品| 午夜精品一区二区三区免费视频| 日韩一区二区三区四区五区六区| 奇米精品一区二区三区四区| 亚洲国产婷婷综合在线精品| 一区二区免费看| 亚洲一区免费在线观看| 亚洲午夜在线电影| 五月婷婷激情综合网| 亚洲第一激情av| 日本中文字幕一区二区视频| 日本va欧美va精品发布| 精品一区二区三区视频在线观看 | 国产精品中文欧美| 国内成人免费视频| 国产在线播放一区二区三区| 国产在线精品一区在线观看麻豆| 亚洲欧美国产高清| 亚洲美女电影在线| 天天色天天爱天天射综合| 久久精品国产成人一区二区三区| 国产精品私人自拍| 亚洲欧洲国产日本综合| 亚洲电影在线免费观看| 精品亚洲免费视频| 成人三级伦理片| 欧美在线视频你懂得| 欧美一区二区三区视频在线| 亚洲精品在线免费观看视频| 国产精品女主播在线观看| 一区二区日韩电影| 激情另类小说区图片区视频区| 亚洲一区免费在线观看| 麻豆91精品91久久久的内涵| 国产成人啪午夜精品网站男同| 五月婷婷综合网| 国产ts人妖一区二区| 色婷婷久久一区二区三区麻豆| 国产在线视频一区二区| 成人国产视频在线观看| 欧美日韩一级二级| 国产日韩欧美一区二区三区综合| 欧美一区二区三区啪啪| 国产精品天干天干在线综合| 亚洲成av人在线观看| 国产成人免费高清| 欧美日韩成人一区二区| 国产欧美精品一区二区色综合| 久久久99免费| 亚洲美女视频在线| 国产成人自拍网| 欧美一区三区四区| 亚洲免费观看在线观看|