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

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

?? rt_com.c

?? rtlinux3.0 的源代碼
?? C
字號:
/** * rt_com * ====== * * RT-Linux kernel module for communication across serial lines. * * Copyright (C) 1997 Jens Michaelsen * Copyright (C) 1997-1999 Jochen K黳per * Copyright (C) 1999 Hua Mao <hmao@nmt.edu> * * POSIX IO and new init functions by Michael Barabanov */ /* define this to be a RT-Linux kernel module */#ifdef RTLINUX_V1#define __KERNEL__#define __RT__#define MODULE#endif#include <linux/config.h>#include <linux/errno.h>#include <linux/ioport.h>#include <linux/kernel.h>#include <linux/module.h>#include <linux/version.h>#include <asm/system.h>#include <asm/io.h>#ifdef RTLINUX_V1#include <asm/rt_irq.h>#include <asm/rt_time.h>#else#include <rtl_conf.h>#include <rtl_core.h>#include <rtl_sync.h>#endif#include "rt_com.h"#include "rt_comP.h"/** * Number and descriptions of serial ports to manage. * You also need to create an ISR ( rt_comN_isr() ) for each port. */#define RT_COM_CNT 1struct rt_com_struct rt_com_table[ RT_COM_CNT ] ={	{ 0, BASE_BAUD, 0x3f8, 4, STD_COM_FLAG, rt_com0_isr },};/** * Write data to a line. * @param com Port to use corresponding to internal numbering scheme. * @param ptr Address of data. * @param cnt Number of bytes to write. * * @author Jens Michaelsen, Jochen K黳per * @version 1999/07/20 */void rt_com_write( unsigned int com, char *ptr, int cnt ){	if( com < RT_COM_CNT ) {		struct rt_com_struct *p = &( rt_com_table[ com ] );		struct rt_buf_struct *b = &( p->obuf );		long state;		rt_com_irq_off( state );		while( --cnt >= 0 ) {			/* put byte into buffer, move pointers to next elements */			b->buf[ b->head++ ] = *ptr++;			/* if( head == RT_COM_BUF_SIZ ), wrap head to the first buffer element */			b->head &= ( RT_COM_BUF_SIZ - 1 );		}		p->ier |= 0x02;		outb( p->ier, p->port + RT_COM_IER );		rt_com_irq_on( state );	}}/** * Read data we got from a line. * @param com Port to use corresponding to internal numbering scheme. * @param ptr Address of data buffer. Needs to be of size > cnt ! * @param cnt Number of bytes to read. * @return Number of bytes actually read. * * @author Jens Michaelsen, Jochen K黳per * @version 1999/07/20 */int rt_com_read( unsigned int com, char *ptr, int cnt ){	int done = 0;	if( com < RT_COM_CNT ) {		struct rt_com_struct *p = &( rt_com_table[ com ] );		struct rt_buf_struct *b = &( p->ibuf );		long state;		rt_com_irq_off (state);		while( ( b->head != b->tail ) && ( --cnt >= 0 ) ) {			done++;			*ptr++ = b->buf[ b->tail++ ];			b->tail &= ( RT_COM_BUF_SIZ - 1 );		}		rt_com_irq_on (state);	}	return( done );}/** * Get first byte from the write buffer. * @param p rt_com_struct of the line we are writing to. * @param c Address to put the char in. * @return  Number of characters we actually got. *  * @author Jens Michaelsen, Jochen K黳per * @version 1999/07/20 */static inline int rt_com_irq_get( struct rt_com_struct *p, unsigned char *c ){	struct rt_buf_struct *b = &( p->obuf );	long state;	rt_com_irq_off(state);	if( b->head != b->tail ) {		*c = b->buf[ b->tail++ ];		b->tail &= ( RT_COM_BUF_SIZ - 1 );		rt_com_irq_on(state);		return( 1 );	}	rt_com_irq_on(state);	return( 0 );}/** * Concatenate a byte to the read buffer. * @param p  rt_com_struct of the line we are writing to. * @param ch Byte to put into buffer. * * @author Jens Michaelsen, Jochen K黳per * @version 1999/07/20 */static inline void rt_com_irq_put( struct rt_com_struct *p, unsigned char ch ){	struct rt_buf_struct *b = &( p->ibuf );	long state;	rt_com_irq_off(state);	b->buf[ b->head++ ] = ch;	b->head &= ( RT_COM_BUF_SIZ - 1 );	rt_com_irq_on(state);}/** * Registered interrupt handler. Calls the general interrupt handler for * the current line to do the work. * * @author Jens Michaelsen, Jochen K黳per, Hua Mao * @version 1999/07/26 */#ifdef RTLINUX_V1static void rt_com0_isr( void ){	rt_com_isr( 0 );}#elsestatic unsigned int rt_com0_isr( unsigned int num, struct pt_regs *r){	return rt_com_isr(0, NULL);}#endif/** * Real interrupt handler. * Called by the registered ISRs to do the actual work. * @param com Port to use corresponding to internal numbering scheme. * * @author Jens Michaelsen, Jochen K黳per, Hua Mao * @version 1999/07/26 */#ifdef RTLINUX_V1static inline void rt_com_isr( unsigned int com )#elseunsigned int rt_com_isr( unsigned int com, struct pt_regs *r )#endif{	struct rt_com_struct *p = &(rt_com_table[com]);	unsigned int B = p->port;	unsigned char data, isr, sta;	char loop = 4;  	do {		/* get available data from port */		sta = inb(B+RT_COM_LSR);		while(sta & DATA_READY) {			data = inb(B+RT_COM_RXB);			rt_com_irq_put(p,data);			sta = inb(B+RT_COM_LSR);		};		/* if possible, put data to port *//* 		sta = inb(B+RT_COM_MSR); *//* 		rtl_printf("%x\n", sta); */		if(sta & 0x20) {			/* Data Set Ready */			if( rt_com_irq_get( p, &data ) ) {				/* data in output buffer */				do {					outb(data,B+RT_COM_TXB);					sta = inb(B+RT_COM_LSR);				} while(--loop>0 && rt_com_irq_get(p,&data));			} else {				/* no data in output buffer, disable Transmitter Holding Register Empty Interrupt */				p->ier &= ~0x02;				outb( p->ier, B + RT_COM_IER );			}			sta = inb(B+RT_COM_LSR);		};		isr = inb(B+RT_COM_IIR) & 0x0F;		/* check the low nibble of IIR wether there is another pending interrupt */	} while( isr && ( --loop > 0 ) );#ifdef RTLINUX_V1	return;#else		rtl_hard_enable_irq(p->irq);	return 0;#endif}/** * Enable hardware fifo buffers. This requires an 16550A or better ! * @param base    Port base address to work on. * @param trigger Bytecount to buffer before an interrupt. * * @author Jochen K黳per * @version 1999/07/20 */static inline void enable_fifo( int base, int trigger ){	switch ( trigger ) {	case  0:		outb( 0x00, base + RT_COM_FCR );		break;	case  1:		outb( 0x01, base + RT_COM_FCR );		break;	case  4:		outb( 0x41, base + RT_COM_FCR );		break;	case  8:		outb( 0x81, base + RT_COM_FCR );		break;	case 14:		outb( 0xC1, base + RT_COM_FCR );		break;	default:		break;	}	return;}/** * Calls from init_module + cleanup_module have baud == 0; in these cases we * only do some cleanup. * * To allocate a port, give usefull setup parameter, to deallocate give negative * baud. * @param com        Number corresponding to internal port numbering scheme. *                   This is esp. the index of the rt_com_table to use. * @param baud       Data transmission rate to use [Byte/s]. * @param parity     Parity for transmission protocol. *                   (RT_COM_PARITY_EVEN, RT_COM_PARITY_ODD or RT_COM_PARITY_NONE) * @param stopbits   Number of stopbits to use. 1 gives you one stopbit, 2 *                   actually gives really two stopbits for wordlengths of *                   6 - 8 bit, but 1.5 stopbits for a wordlength of 5 bits. * @param wordlength Number of bits per word (5 - 8 bits). * * @author Jens Michaelsen, Jochen K黳per * @version 1999/07/20 */void rt_com_setup( unsigned int com, int baud, unsigned int parity,				   unsigned int stopbits, unsigned int wordlength ){	struct rt_com_struct  *p = &( rt_com_table[ com ] );	unsigned int base = p->port, divider, par = parity;	/* Stop everything, set DLAB */	outb( 0x00, base + RT_COM_IER );	outb( 0x80, base + RT_COM_LCR );	/* clear irq */	inb( base + RT_COM_IIR );	inb( base + RT_COM_LSR );	inb( base + RT_COM_RXB );	inb( base + RT_COM_MSR );	if( 0 == baud ) {		/* return */	} else if( 0 > baud ) {		MOD_DEC_USE_COUNT;	} else {		MOD_INC_USE_COUNT;		divider = p->baud_base / baud;		outb( divider % 256, base + RT_COM_DLL );		outb( divider / 256, base + RT_COM_DLM );		/* bits 3,4 + 5 determine parity */		if( par & 0xC7 )			par = RT_COM_PARITY_NONE;		/* set transmission parameters and clear DLAB */		outb( ( wordlength - 5 ) + ( ( stopbits - 1 ) << 2 ) + par, base + RT_COM_LCR );		outb( RT_COM_DTR + RT_COM_RTS +  RT_COM_Out1 + RT_COM_Out2, base + RT_COM_MCR );		p->ier = 0x01;		outb( p->ier, base + RT_COM_IER );		enable_fifo( base, FIFO_TRIGGER );	}	return;}#ifdef CONFIG_RTL_POSIX_IO#define RT_COM_MAJOR 4#include <rtl_posixio.h>static int rtl_rt_com_open (struct rtl_file *filp){	if (!(filp->f_flags & O_NONBLOCK)) {		return -EACCES; /* TODO: implement blocking IO */	}	if ((unsigned) RTL_MINOR_FROM_FILEPTR(filp) >= RT_COM_CNT) {		return -ENODEV;	}	return 0;}static int rtl_rt_com_release (struct rtl_file *filp){	return 0;}static ssize_t rtl_rt_com_write(struct rtl_file *filp, const char *buf, size_t count, loff_t* ppos){/*	if (rt_com_table[RTL_MINOR_FROM_FILEPTR(filp)].type == 0) {		return -ENODEV;	} */	rt_com_write(RTL_MINOR_FROM_FILEPTR(filp), (char *) buf, count);	return count;	}static ssize_t rtl_rt_com_read(struct rtl_file *filp, char *buf, size_t count, loff_t* ppos){/*	if (rt_com_table[RTL_MINOR_FROM_FILEPTR(filp)].type == 0) {		return -ENODEV;	} */	return rt_com_read(RTL_MINOR_FROM_FILEPTR(filp), buf, count);	}static struct rtl_file_operations rtl_rt_com_fops = {       	NULL,	rtl_rt_com_read,	rtl_rt_com_write,	NULL,	NULL,	NULL,	rtl_rt_com_open,	rtl_rt_com_release};#endif/** * Request port memory and register ISRs, if we cannot get the memory of all * ports, release all already requested ports and return an error. * @return Success status, zero on success. * * @author Jochen K黳per, Hua Mao * @version 1999/07/28 */int init_module( void ){	struct rt_com_struct *p;	int errorcode = 0, i, j;	for( i=0; i<RT_COM_CNT; i++ ) {		p = &( rt_com_table[ i ] );		if(-EBUSY == check_region( p->port, 8 ) ) {			errorcode = 1;			break;		}		request_region( p->port, 8, "rt_com" );#ifdef RTLINUX_V1		request_RTirq( p->irq,p->isr );#else		rtl_request_irq( p->irq, p->isr );		rtl_hard_enable_irq( p->irq );#endif		rt_com_setup( i, 0, 0, 0, 0 );	}	if( 0 == errorcode ) {		printk( KERN_INFO "rt_com sucessfully loaded.\n" );	} else {		printk( KERN_WARNING "rt_com: cannot request all port regions,\nrt_com: giving up.\n" );		for( j=0; j<i; j++ ) {#ifdef RTLINUX_V1			free_RTirq( p->irq );#else			rtl_free_irq(p->irq);#endif			release_region( p->port, 8 );		}	}#ifdef CONFIG_RTL_POSIX_IO	if (rtl_register_chrdev (RT_COM_MAJOR, "ttyS", &rtl_rt_com_fops)) {		printk ("RT-COM: unable to get RTL major %d\n", RT_COM_MAJOR);		return -EIO;	}#endif	return( errorcode );}/** * Unregister ISR and releases memory for all ports * * @author Jochen K黳per, Hua Mao * @version 1999/07/26 */ void cleanup_module( void ){	struct rt_com_struct *p;	int i;#ifdef CONFIG_RTL_POSIX_IO	rtl_unregister_chrdev(RT_COM_MAJOR, "ttyS");#endif	for( i=0; i<RT_COM_CNT; i++ ) {		p = &( rt_com_table[ i ] );#ifdef RTLINUX_V1		free_RTirq( p->irq );#else		rtl_free_global_irq(p->irq);#endif		rt_com_setup( i, 0, 0, 0, 0 );		release_region( p->port, 8 );	}	printk( KERN_INFO "rt_com unloaded.\n" );	return;}/** * Local Variables: * mode: C * c-file-style: "Stroustrup" * End: */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99久国产精品黄毛片色诱| 欧美性高清videossexo| 久久婷婷成人综合色| 美国十次综合导航| 精品999在线播放| 国内精品免费在线观看| 中文字幕国产精品一区二区| 国产a精品视频| 国产精品国产三级国产aⅴ中文 | 国产精品每日更新在线播放网址| 粉嫩绯色av一区二区在线观看| 国产精品国产三级国产有无不卡| 色综合天天狠狠| 日韩中文字幕亚洲一区二区va在线| 欧美一区二区三区喷汁尤物| 国产一区二区三区高清播放| 亚洲色图第一区| 制服丝袜在线91| 国产麻豆视频精品| 伊人一区二区三区| 日韩欧美中文字幕公布| 福利电影一区二区| 天天综合天天做天天综合| 久久天天做天天爱综合色| 色婷婷综合在线| 美女尤物国产一区| 日韩毛片视频在线看| 日韩视频免费观看高清完整版在线观看 | 国产精品久线在线观看| 在线精品国精品国产尤物884a| 免费国产亚洲视频| 最新久久zyz资源站| 欧美精品在线视频| 成人晚上爱看视频| 日韩**一区毛片| 亚洲少妇最新在线视频| 日韩欧美亚洲国产另类| 91一区一区三区| 精品在线视频一区| 一区二区三区影院| 中文成人av在线| 精品国产伦一区二区三区观看方式| 日本韩国欧美国产| 成人av资源在线| 另类小说一区二区三区| 中文字幕五月欧美| 久久久久久久国产精品影院| 欧美日韩亚洲另类| 91丨porny丨国产入口| 久久精品理论片| 天堂在线亚洲视频| 亚洲精品视频在线观看网站| 久久九九久精品国产免费直播| 欧美放荡的少妇| 欧美专区日韩专区| av一区二区不卡| 国产高清无密码一区二区三区| 亚洲地区一二三色| 亚洲一级不卡视频| 亚洲欧美日韩国产综合在线| 欧美激情综合五月色丁香| 日韩精品一区二区三区中文精品| 欧洲日韩一区二区三区| 91影院在线观看| 99免费精品视频| 成人ar影院免费观看视频| 国产成人在线影院| 国产成a人亚洲精品| 激情六月婷婷久久| 国产综合色产在线精品| 久久99蜜桃精品| 极品少妇一区二区| 国内精品在线播放| 精品一区二区三区在线播放| 久久99热狠狠色一区二区| 久久国产视频网| 久久精品久久综合| 国产一区二区不卡在线| 国产精品99久久久久| 国产一级精品在线| 国产不卡视频在线播放| 国产91精品一区二区麻豆网站 | 日本伊人精品一区二区三区观看方式| 午夜视频一区在线观看| 午夜激情久久久| 日韩国产高清影视| 黄色资源网久久资源365| 国产精品系列在线播放| 成人性生交大片免费看在线播放 | 日本国产一区二区| 欧美中文字幕不卡| 欧美久久久久久久久久| 精品国产91洋老外米糕| 国产欧美日韩精品一区| 亚洲日本韩国一区| 亚洲va韩国va欧美va精品| 久久丁香综合五月国产三级网站| 国内外成人在线| 92国产精品观看| 欧美日韩国产经典色站一区二区三区 | 日本亚洲最大的色成网站www| 久久精品国产亚洲a| 盗摄精品av一区二区三区| 在线亚洲欧美专区二区| 欧美一区二区三区四区视频| 久久久精品影视| 亚洲一区二区视频在线观看| 男男视频亚洲欧美| 国产v日产∨综合v精品视频| 色综合久久九月婷婷色综合| 在线91免费看| 日本一区二区三区视频视频| 亚洲影视在线观看| 韩国理伦片一区二区三区在线播放| 波多野结衣中文字幕一区二区三区| 日本高清视频一区二区| 久久久综合网站| 玉米视频成人免费看| 国产一区二区精品久久91| 日本韩国欧美三级| 国产视频一区二区三区在线观看| 亚洲欧美日韩一区| 精品一二三四区| 在线影院国内精品| 久久综合九色综合97婷婷女人| 一色桃子久久精品亚洲| 久久精品国产成人一区二区三区| av日韩在线网站| 久久人人爽人人爽| 视频一区免费在线观看| 成人免费视频国产在线观看| 日韩午夜精品电影| 亚洲激情图片小说视频| 国产精品一区二区在线播放| 欧美裸体bbwbbwbbw| 亚洲天堂久久久久久久| 国产真实乱偷精品视频免| 欧美日韩国产系列| 亚洲人亚洲人成电影网站色| 国产在线精品一区二区| 欧美一级二级三级蜜桃| 亚洲在线中文字幕| www.久久久久久久久| 久久综合九色综合欧美98 | 国产一区二区三区在线观看精品 | 日本高清成人免费播放| 国产精品进线69影院| 韩国一区二区在线观看| 欧美精品在线视频| 午夜婷婷国产麻豆精品| 欧洲一区二区三区在线| 日韩码欧中文字| 91在线观看免费视频| 国产精品免费久久久久| 国产福利一区二区三区视频在线 | 成人综合在线观看| 26uuu亚洲| 久久99九九99精品| 日韩欧美的一区二区| 蜜臀av一级做a爰片久久| 欧美人妇做爰xxxⅹ性高电影 | 日韩午夜精品电影| 婷婷一区二区三区| 欧美喷潮久久久xxxxx| 天天影视涩香欲综合网 | 欧美性大战xxxxx久久久| 亚洲嫩草精品久久| 日本乱人伦aⅴ精品| 一区av在线播放| 欧美日韩一区中文字幕| 亚洲国产精品一区二区久久| 欧美影视一区在线| 天天做天天摸天天爽国产一区| 欧美性生活一区| 午夜视频一区二区| 日韩一区二区免费电影| 国产在线日韩欧美| 久久久高清一区二区三区| 成人激情免费电影网址| 日韩理论在线观看| 在线看不卡av| 美女mm1313爽爽久久久蜜臀| 精品久久久久久久久久久久包黑料 | 久久丁香综合五月国产三级网站| 欧美一级午夜免费电影| 免费精品视频最新在线| 久久综合给合久久狠狠狠97色69| 国产成人一级电影| 亚洲人午夜精品天堂一二香蕉| 欧美影院午夜播放| 秋霞国产午夜精品免费视频| www国产成人免费观看视频 深夜成人网| 精一区二区三区| 日韩一区在线免费观看| 欧美日韩精品系列| 美女一区二区视频| **欧美大码日韩| 日韩一级精品视频在线观看| 国产成人精品一区二| 亚洲综合久久av|