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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? short.c

?? linux設(shè)備驅(qū)動編程第三版書籍的所有實例
?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩午夜电影在线观看| 午夜欧美2019年伦理| 久久色在线视频| 精品国产91洋老外米糕| 精品国产乱码久久久久久1区2区| 91精品国产欧美一区二区18| 欧美一区三区二区| 欧美高清性hdvideosex| 9191精品国产综合久久久久久| 欧美年轻男男videosbes| 欧美色欧美亚洲另类二区| 欧美在线观看一区| 欧美日韩精品福利| 欧美精品乱码久久久久久按摩 | 色综合久久88色综合天天| 成人av网站在线观看| 91视频免费看| 欧美日韩精品二区第二页| 宅男在线国产精品| 精品国产百合女同互慰| 久久精品视频网| 中文字幕日韩一区| 亚洲成人av中文| 精品亚洲成a人在线观看 | 欧美日韩精品一区二区三区| 9191国产精品| 久久精品男人天堂av| 综合中文字幕亚洲| 亚洲福利一二三区| 久久99最新地址| 成人av在线资源网站| 欧美午夜不卡视频| 久久伊人蜜桃av一区二区| 专区另类欧美日韩| 日本女人一区二区三区| 国产成人综合精品三级| 91久久精品日日躁夜夜躁欧美| 91麻豆精品国产自产在线观看一区 | 成人久久视频在线观看| 日本韩国一区二区| 欧美成人艳星乳罩| 国产精品乱子久久久久| 三级影片在线观看欧美日韩一区二区 | 视频一区视频二区中文字幕| 久久99国产乱子伦精品免费| av在线不卡免费看| 日韩你懂的电影在线观看| 国产精品国产三级国产有无不卡| 亚洲18色成人| 成人亚洲一区二区一| 在线不卡欧美精品一区二区三区| 国产色产综合色产在线视频 | 岛国av在线一区| 欧美日韩国产小视频| 久久久久久夜精品精品免费| 亚洲欧美欧美一区二区三区| 极品瑜伽女神91| 欧美在线综合视频| 亚洲国产精品国自产拍av| 婷婷夜色潮精品综合在线| 成人sese在线| 精品福利一二区| 亚洲成av人综合在线观看| 高清国产一区二区| 日韩欧美一级二级| 一区二区三区久久久| 国产成人在线影院| 日韩欧美区一区二| 亚洲高清免费在线| 色综合一个色综合| 国产欧美精品日韩区二区麻豆天美| 天堂在线亚洲视频| 99精品黄色片免费大全| 久久久久久麻豆| 免费在线观看日韩欧美| 欧洲生活片亚洲生活在线观看| 欧美激情在线一区二区三区| 六月丁香婷婷色狠狠久久| 欧美视频三区在线播放| 国产精品妹子av| 国产一区二区三区综合| 欧美一卡二卡三卡| 图片区小说区区亚洲影院| 色综合天天综合给合国产| 久久精品视频一区| 国产精品一二三四区| 精品毛片乱码1区2区3区| 日韩中文字幕1| 欧美日韩黄色影视| 亚洲一区免费视频| 色婷婷久久久久swag精品| 中文字幕一区二区三| 成人一级片在线观看| 国产欧美日韩在线视频| 国产精品99久久久久久久女警 | 国产色一区二区| 国产白丝网站精品污在线入口| 日韩精品自拍偷拍| 麻豆一区二区三区| 日韩视频一区二区三区在线播放| 日韩成人一级片| 日韩一区二区三区视频| 日本欧美一区二区| 欧美大片在线观看| 久久不见久久见免费视频1| 欧美一级艳片视频免费观看| 三级在线观看一区二区| 欧美一区二区三区免费视频| 日韩高清不卡在线| 欧美xxx久久| 国产精品123| 国产精品美女久久久久久2018| 成人深夜视频在线观看| 国产精品久久福利| 色综合久久中文综合久久牛| 一区二区免费看| 欧美精品亚洲二区| 韩国在线一区二区| 亚洲国产高清不卡| 91在线国产观看| 亚洲电影一级黄| 精品国产乱码久久久久久闺蜜 | xf在线a精品一区二区视频网站| 久久不见久久见中文字幕免费| 国产偷v国产偷v亚洲高清| 99久久精品一区二区| 亚洲国产精品麻豆| 日韩欧美一区电影| 成人一级片网址| 亚洲一区免费观看| 欧美α欧美αv大片| 99久久免费精品| 丝袜脚交一区二区| 国产午夜精品福利| 欧美在线视频全部完| 精品一区二区三区视频| 最新热久久免费视频| 欧美日韩国产片| 国产电影精品久久禁18| 一区二区日韩av| 久久无码av三级| 日本久久一区二区| 毛片不卡一区二区| 亚洲女子a中天字幕| 欧美一区二区三区精品| 国产精品乡下勾搭老头1| 亚洲精品视频在线| 欧美电影免费观看高清完整版在| 9i在线看片成人免费| 日产国产欧美视频一区精品| 欧美国产日本视频| 制服视频三区第一页精品| 懂色av一区二区三区蜜臀| 亚洲国产中文字幕| 久久久久久久综合| 6080午夜不卡| 91免费国产视频网站| 精品一区二区三区在线播放视频 | 久久精品国产久精国产爱| 亚洲欧洲日韩在线| 日韩片之四级片| 色噜噜偷拍精品综合在线| 精品一区二区三区久久久| 一区二区三区四区av| 久久久电影一区二区三区| 日本久久一区二区三区| 国产69精品久久777的优势| 日韩高清一区在线| 天堂va蜜桃一区二区三区漫画版| 亚洲国产激情av| 精品成人佐山爱一区二区| 欧美伊人久久大香线蕉综合69| 国产精品亚洲午夜一区二区三区| 亚洲福利视频导航| 亚洲人午夜精品天堂一二香蕉| 亚洲精品一线二线三线无人区| 欧洲人成人精品| av在线综合网| 国产福利一区二区三区视频 | 日本道精品一区二区三区| 国产成人免费在线观看| 日本成人超碰在线观看| 尤物在线观看一区| 国产精品私人自拍| 精品国产一区二区精华| 777色狠狠一区二区三区| 91官网在线免费观看| 91美女片黄在线| 成人午夜电影久久影院| 国产乱码精品一区二区三区忘忧草| 婷婷中文字幕综合| 午夜不卡在线视频| 一级精品视频在线观看宜春院| 中文字幕一区二区三区不卡| 国产欧美日韩综合| 欧美激情在线一区二区| 国产欧美精品区一区二区三区| 国产视频一区二区三区在线观看| 久久久久久9999| 久久影院午夜论|