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

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

?? serial_core.c

?? 宋寶華的《Linux設備驅(qū)動開發(fā)詳解》第一版的源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* *  linux/drivers/char/core.c * *  Driver core for serial ports * *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. * *  Copyright 1999 ARM Limited *  Copyright (C) 2000-2001 Deep Blue Solutions Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <linux/config.h>#include <linux/module.h>#include <linux/tty.h>#include <linux/slab.h>#include <linux/init.h>#include <linux/console.h>#include <linux/serial_core.h>#include <linux/smp_lock.h>#include <linux/device.h>#include <linux/serial.h> /* for serial_state and serial_icounter_struct */#include <linux/delay.h>#include <linux/mutex.h>#include <asm/irq.h>#include <asm/uaccess.h>#undef	DEBUG#ifdef DEBUG#define DPRINTK(x...)	printk(x)#else#define DPRINTK(x...)	do { } while (0)#endif/* * This is used to lock changes in serial line configuration. */static DEFINE_MUTEX(port_mutex);#define HIGH_BITS_OFFSET	((sizeof(long)-sizeof(int))*8)#define uart_users(state)	((state)->count + ((state)->info ? (state)->info->blocked_open : 0))#ifdef CONFIG_SERIAL_CORE_CONSOLE#define uart_console(port)	((port)->cons && (port)->cons->index == (port)->line)#else#define uart_console(port)	(0)#endifstatic void uart_change_speed(struct uart_state *state, struct termios *old_termios);static void uart_wait_until_sent(struct tty_struct *tty, int timeout);static void uart_change_pm(struct uart_state *state, int pm_state);/* * This routine is used by the interrupt handler to schedule processing in * the software interrupt portion of the driver. */void uart_write_wakeup(struct uart_port *port){	struct uart_info *info = port->info;	/*	 * This means you called this function _after_ the port was	 * closed.  No cookie for you.	 */	BUG_ON(!info);	tasklet_schedule(&info->tlet);}static void uart_stop(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	struct uart_port *port = state->port;	unsigned long flags;	spin_lock_irqsave(&port->lock, flags);	port->ops->stop_tx(port);	spin_unlock_irqrestore(&port->lock, flags);}static void __uart_start(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	struct uart_port *port = state->port;	if (!uart_circ_empty(&state->info->xmit) && state->info->xmit.buf &&	    !tty->stopped && !tty->hw_stopped)		port->ops->start_tx(port);}static void uart_start(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	struct uart_port *port = state->port;	unsigned long flags;	spin_lock_irqsave(&port->lock, flags);	__uart_start(tty);	spin_unlock_irqrestore(&port->lock, flags);}static void uart_tasklet_action(unsigned long data){	struct uart_state *state = (struct uart_state *)data;	tty_wakeup(state->info->tty);}static inline voiduart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear){	unsigned long flags;	unsigned int old;	spin_lock_irqsave(&port->lock, flags);	old = port->mctrl;	port->mctrl = (old & ~clear) | set;	if (old != port->mctrl)		port->ops->set_mctrl(port, port->mctrl);	spin_unlock_irqrestore(&port->lock, flags);}#define uart_set_mctrl(port,set)	uart_update_mctrl(port,set,0)#define uart_clear_mctrl(port,clear)	uart_update_mctrl(port,0,clear)/* * Startup the port.  This will be called once per open.  All calls * will be serialised by the per-port semaphore. */static int uart_startup(struct uart_state *state, int init_hw){	struct uart_info *info = state->info;	struct uart_port *port = state->port;	unsigned long page;	int retval = 0;	if (info->flags & UIF_INITIALIZED)		return 0;	/*	 * Set the TTY IO error marker - we will only clear this	 * once we have successfully opened the port.  Also set	 * up the tty->alt_speed kludge	 */	set_bit(TTY_IO_ERROR, &info->tty->flags);	if (port->type == PORT_UNKNOWN)		return 0;	/*	 * Initialise and allocate the transmit and temporary	 * buffer.	 */	if (!info->xmit.buf) {		page = get_zeroed_page(GFP_KERNEL);		if (!page)			return -ENOMEM;		info->xmit.buf = (unsigned char *) page;		uart_circ_clear(&info->xmit);	}	retval = port->ops->startup(port);	if (retval == 0) {		if (init_hw) {			/*			 * Initialise the hardware port settings.			 */			uart_change_speed(state, NULL);			/*			 * Setup the RTS and DTR signals once the			 * port is open and ready to respond.			 */			if (info->tty->termios->c_cflag & CBAUD)				uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);		}		if (info->flags & UIF_CTS_FLOW) {			spin_lock_irq(&port->lock);			if (!(port->ops->get_mctrl(port) & TIOCM_CTS))				info->tty->hw_stopped = 1;			spin_unlock_irq(&port->lock);		}		info->flags |= UIF_INITIALIZED;		clear_bit(TTY_IO_ERROR, &info->tty->flags);	}	if (retval && capable(CAP_SYS_ADMIN))		retval = 0;	return retval;}/* * This routine will shutdown a serial port; interrupts are disabled, and * DTR is dropped if the hangup on close termio flag is on.  Calls to * uart_shutdown are serialised by the per-port semaphore. */static void uart_shutdown(struct uart_state *state){	struct uart_info *info = state->info;	struct uart_port *port = state->port;	/*	 * Set the TTY IO error marker	 */	if (info->tty)		set_bit(TTY_IO_ERROR, &info->tty->flags);	if (info->flags & UIF_INITIALIZED) {		info->flags &= ~UIF_INITIALIZED;		/*		 * Turn off DTR and RTS early.		 */		if (!info->tty || (info->tty->termios->c_cflag & HUPCL))			uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);		/*		 * clear delta_msr_wait queue to avoid mem leaks: we may free		 * the irq here so the queue might never be woken up.  Note		 * that we won't end up waiting on delta_msr_wait again since		 * any outstanding file descriptors should be pointing at		 * hung_up_tty_fops now.		 */		wake_up_interruptible(&info->delta_msr_wait);		/*		 * Free the IRQ and disable the port.		 */		port->ops->shutdown(port);		/*		 * Ensure that the IRQ handler isn't running on another CPU.		 */		synchronize_irq(port->irq);	}	/*	 * kill off our tasklet	 */	tasklet_kill(&info->tlet);	/*	 * Free the transmit buffer page.	 */	if (info->xmit.buf) {		free_page((unsigned long)info->xmit.buf);		info->xmit.buf = NULL;	}}/** *	uart_update_timeout - update per-port FIFO timeout. *	@port:  uart_port structure describing the port *	@cflag: termios cflag value *	@baud:  speed of the port * *	Set the port FIFO timeout value.  The @cflag value should *	reflect the actual hardware settings. */voiduart_update_timeout(struct uart_port *port, unsigned int cflag,		    unsigned int baud){	unsigned int bits;	/* byte size and parity */	switch (cflag & CSIZE) {	case CS5:		bits = 7;		break;	case CS6:		bits = 8;		break;	case CS7:		bits = 9;		break;	default:		bits = 10;		break; // CS8	}	if (cflag & CSTOPB)		bits++;	if (cflag & PARENB)		bits++;	/*	 * The total number of bits to be transmitted in the fifo.	 */	bits = bits * port->fifosize;	/*	 * Figure the timeout to send the above number of bits.	 * Add .02 seconds of slop	 */	port->timeout = (HZ * bits) / baud + HZ/50;}EXPORT_SYMBOL(uart_update_timeout);/** *	uart_get_baud_rate - return baud rate for a particular port *	@port: uart_port structure describing the port in question. *	@termios: desired termios settings. *	@old: old termios (or NULL) *	@min: minimum acceptable baud rate *	@max: maximum acceptable baud rate * *	Decode the termios structure into a numeric baud rate, *	taking account of the magic 38400 baud rate (with spd_* *	flags), and mapping the %B0 rate to 9600 baud. * *	If the new baud rate is invalid, try the old termios setting. *	If it's still invalid, we try 9600 baud. * *	Update the @termios structure to reflect the baud rate *	we're actually going to be using. */unsigned intuart_get_baud_rate(struct uart_port *port, struct termios *termios,		   struct termios *old, unsigned int min, unsigned int max){	unsigned int try, baud, altbaud = 38400;	upf_t flags = port->flags & UPF_SPD_MASK;	if (flags == UPF_SPD_HI)		altbaud = 57600;	if (flags == UPF_SPD_VHI)		altbaud = 115200;	if (flags == UPF_SPD_SHI)		altbaud = 230400;	if (flags == UPF_SPD_WARP)		altbaud = 460800;	for (try = 0; try < 2; try++) {		baud = tty_termios_baud_rate(termios);		/*		 * The spd_hi, spd_vhi, spd_shi, spd_warp kludge...		 * Die! Die! Die!		 */		if (baud == 38400)			baud = altbaud;		/*		 * Special case: B0 rate.		 */		if (baud == 0)			baud = 9600;		if (baud >= min && baud <= max)			return baud;		/*		 * Oops, the quotient was zero.  Try again with		 * the old baud rate if possible.		 */		termios->c_cflag &= ~CBAUD;		if (old) {			termios->c_cflag |= old->c_cflag & CBAUD;			old = NULL;			continue;		}		/*		 * As a last resort, if the quotient is zero,		 * default to 9600 bps		 */		termios->c_cflag |= B9600;	}	return 0;}EXPORT_SYMBOL(uart_get_baud_rate);/** *	uart_get_divisor - return uart clock divisor *	@port: uart_port structure describing the port. *	@baud: desired baud rate * *	Calculate the uart clock divisor for the port. */unsigned intuart_get_divisor(struct uart_port *port, unsigned int baud){	unsigned int quot;	/*	 * Old custom speed handling.	 */	if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST)		quot = port->custom_divisor;	else		quot = (port->uartclk + (8 * baud)) / (16 * baud);	return quot;}EXPORT_SYMBOL(uart_get_divisor);static voiduart_change_speed(struct uart_state *state, struct termios *old_termios){	struct tty_struct *tty = state->info->tty;	struct uart_port *port = state->port;	struct termios *termios;	/*	 * If we have no tty, termios, or the port does not exist,	 * then we can't set the parameters for this port.	 */	if (!tty || !tty->termios || port->type == PORT_UNKNOWN)		return;	termios = tty->termios;	/*	 * Set flags based on termios cflag	 */	if (termios->c_cflag & CRTSCTS)		state->info->flags |= UIF_CTS_FLOW;	else		state->info->flags &= ~UIF_CTS_FLOW;	if (termios->c_cflag & CLOCAL)		state->info->flags &= ~UIF_CHECK_CD;	else		state->info->flags |= UIF_CHECK_CD;	port->ops->set_termios(port, termios, old_termios);}static inline void__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c){	unsigned long flags;	if (!circ->buf)		return;	spin_lock_irqsave(&port->lock, flags);	if (uart_circ_chars_free(circ) != 0) {		circ->buf[circ->head] = c;		circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);	}	spin_unlock_irqrestore(&port->lock, flags);}static void uart_put_char(struct tty_struct *tty, unsigned char ch){	struct uart_state *state = tty->driver_data;	__uart_put_char(state->port, &state->info->xmit, ch);}static void uart_flush_chars(struct tty_struct *tty){	uart_start(tty);}static intuart_write(struct tty_struct *tty, const unsigned char *buf, int count){	struct uart_state *state = tty->driver_data;	struct uart_port *port;	struct circ_buf *circ;	unsigned long flags;	int c, ret = 0;	/*	 * This means you called this function _after_ the port was	 * closed.  No cookie for you.	 */	if (!state || !state->info) {		WARN_ON(1);		return -EL3HLT;	}	port = state->port;	circ = &state->info->xmit;	if (!circ->buf)		return 0;	spin_lock_irqsave(&port->lock, flags);	while (1) {		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);		if (count < c)			c = count;		if (c <= 0)			break;		memcpy(circ->buf + circ->head, buf, c);		circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);		buf += c;		count -= c;		ret += c;	}	spin_unlock_irqrestore(&port->lock, flags);	uart_start(tty);	return ret;}static int uart_write_room(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	return uart_circ_chars_free(&state->info->xmit);}static int uart_chars_in_buffer(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	return uart_circ_chars_pending(&state->info->xmit);}static void uart_flush_buffer(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	struct uart_port *port = state->port;	unsigned long flags;	/*	 * This means you called this function _after_ the port was	 * closed.  No cookie for you.	 */	if (!state || !state->info) {		WARN_ON(1);		return;	}	DPRINTK("uart_flush_buffer(%d) called\n", tty->index);	spin_lock_irqsave(&port->lock, flags);	uart_circ_clear(&state->info->xmit);	spin_unlock_irqrestore(&port->lock, flags);	tty_wakeup(tty);}/* * This function is used to send a high-priority XON/XOFF character to * the device */static void uart_send_xchar(struct tty_struct *tty, char ch){	struct uart_state *state = tty->driver_data;	struct uart_port *port = state->port;	unsigned long flags;	if (port->ops->send_xchar)		port->ops->send_xchar(port, ch);	else {		port->x_char = ch;		if (ch) {			spin_lock_irqsave(&port->lock, flags);			port->ops->start_tx(port);			spin_unlock_irqrestore(&port->lock, flags);		}	}}static void uart_throttle(struct tty_struct *tty){	struct uart_state *state = tty->driver_data;	if (I_IXOFF(tty))		uart_send_xchar(tty, STOP_CHAR(tty));	if (tty->termios->c_cflag & CRTSCTS)		uart_clear_mctrl(state->port, TIOCM_RTS);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产色产综合色产在线视频 | 成人免费黄色大片| 91麻豆免费看片| 日韩欧美一级二级| 亚洲精品一二三四区| 国产精品123| 欧美一区二区三区免费在线看| 国产精品亲子伦对白| 蜜臀av性久久久久蜜臀aⅴ四虎 | 一本久道中文字幕精品亚洲嫩 | 日韩成人精品在线| 91老师国产黑色丝袜在线| 久久午夜老司机| 麻豆一区二区三区| 欧美日韩国产大片| 一区二区三区欧美视频| 99久久综合99久久综合网站| 久久老女人爱爱| 麻豆国产精品一区二区三区| 精品视频资源站| 亚洲欧美国产毛片在线| 不卡的av在线播放| 中国色在线观看另类| 国产精品一线二线三线精华| 欧美一级爆毛片| 青青国产91久久久久久| 欧美日韩国产一级| 亚洲电影中文字幕在线观看| 日本道在线观看一区二区| 亚洲视频在线观看三级| 99久久久久久99| 亚洲色图欧美偷拍| 91毛片在线观看| 亚洲激情自拍偷拍| 欧美在线视频全部完| 亚洲午夜成aⅴ人片| 精品视频1区2区| 亚洲午夜免费电影| 欧美日韩成人综合| 美女mm1313爽爽久久久蜜臀| 日韩欧美亚洲另类制服综合在线| 热久久国产精品| 精品国免费一区二区三区| 国产一区二区中文字幕| 欧美国产一区在线| 色呦呦日韩精品| 日日摸夜夜添夜夜添亚洲女人| 欧美日韩国产免费一区二区| 人人爽香蕉精品| 久久你懂得1024| 99久久精品免费看| 亚洲综合视频在线观看| 91超碰这里只有精品国产| 日av在线不卡| 中文字幕欧美激情一区| 欧美亚洲一区二区在线| 蜜桃视频在线观看一区二区| 亚洲国产精品t66y| 色视频成人在线观看免| 日本免费在线视频不卡一不卡二| 26uuu色噜噜精品一区| 成人高清视频在线| 亚洲成人先锋电影| 国产亚洲一区二区三区在线观看 | 色一区在线观看| 欧美a级理论片| 中文字幕不卡三区| 欧美日本韩国一区二区三区视频| 黑人精品欧美一区二区蜜桃| 国产精品私人影院| 欧美日韩一本到| 国产精品乡下勾搭老头1| 亚洲精品午夜久久久| 日韩三级电影网址| 色综合久久久久久久久久久| 蜜桃传媒麻豆第一区在线观看| 亚洲国产精品激情在线观看| 欧美日韩国产美女| 国产**成人网毛片九色| 日本人妖一区二区| 亚洲人快播电影网| 久久精品一区蜜桃臀影院| 欧美中文字幕亚洲一区二区va在线| 国内精品免费在线观看| 亚洲观看高清完整版在线观看| 久久久不卡网国产精品二区| 欧美久久一二区| 色综合久久88色综合天天| 国产一区二区不卡老阿姨| 午夜伦理一区二区| 亚洲欧美日韩久久| 欧美国产日本视频| 精品国产一区二区三区四区四| 欧美亚洲免费在线一区| 波多野结衣精品在线| 国产在线精品国自产拍免费| 奇米一区二区三区av| 亚洲午夜精品网| 一区二区三区在线视频免费| 欧美国产精品久久| 国产区在线观看成人精品| 日韩精品一区二区三区在线观看 | 亚洲私人影院在线观看| 国产日韩v精品一区二区| 精品日韩在线观看| 日韩视频免费观看高清完整版 | 亚洲精品乱码久久久久久日本蜜臀| www国产成人免费观看视频 深夜成人网| 欧美日韩久久一区| 欧美日韩一区三区四区| 欧美一a一片一级一片| 色婷婷狠狠综合| 色综合久久久久网| 在线免费观看日本欧美| 欧美亚洲国产一区在线观看网站| 99re这里都是精品| 91麻豆精品一区二区三区| www.成人网.com| 91网址在线看| 欧美丝袜自拍制服另类| 欧美日韩另类一区| 日韩一级片在线观看| 26uuu国产电影一区二区| 国产亚洲精品资源在线26u| 国产亚洲精品久| 国产精品高潮呻吟| 一区二区三区中文字幕电影| 亚洲一区二区偷拍精品| 日本人妖一区二区| 国产资源精品在线观看| 成人国产精品免费观看动漫| 91色在线porny| 欧美日本在线看| 精品国产一区a| 国产精品女主播av| 亚洲一区二区在线观看视频| 亚洲va国产天堂va久久en| 久久精品99国产精品日本| 国产一区二区三区在线看麻豆| 成人av在线网| 欧美四级电影网| 26uuu精品一区二区在线观看| 中文字幕第一区综合| 亚洲尤物视频在线| 久久99久久99小草精品免视看| 国产精品资源在线看| 91免费看片在线观看| 91精品在线一区二区| 国产日本欧美一区二区| 亚洲乱码国产乱码精品精98午夜 | 亚洲视频在线观看三级| 午夜精品一区二区三区免费视频| 久久精品国产99国产精品| 成人美女视频在线观看| 欧美精品自拍偷拍动漫精品| 久久青草欧美一区二区三区| 一区二区三区成人在线视频| 久久激五月天综合精品| 99久久精品国产一区| 欧美大片在线观看一区二区| 中文字幕一区二区三区四区| 亚洲aⅴ怡春院| 成人性色生活片| 日韩视频一区二区三区| 亚洲精品视频自拍| 韩国女主播成人在线观看| 在线观看日产精品| 国产亚洲欧美激情| 蜜桃视频在线观看一区二区| 在线亚洲精品福利网址导航| 久久丝袜美腿综合| 日本三级韩国三级欧美三级| 91视频国产观看| 亚洲国产精华液网站w| 另类中文字幕网| 欧美三级一区二区| 1区2区3区精品视频| 粉嫩av一区二区三区在线播放| 91精品麻豆日日躁夜夜躁| 亚洲女同ⅹxx女同tv| 成人丝袜高跟foot| 久久九九久精品国产免费直播| 日本不卡一二三区黄网| 欧美日韩精品一区二区| 亚洲视频在线一区| 99久久精品免费看国产免费软件| 久久久99精品久久| 精品在线亚洲视频| 日韩精品专区在线影院观看| 日韩高清不卡一区| 在线成人小视频| 亚洲va国产va欧美va观看| 欧美性淫爽ww久久久久无| 一区二区在线观看av| 99久久99久久久精品齐齐| 日本成人在线看| 8x福利精品第一导航| 日本免费在线视频不卡一不卡二 | av一区二区三区在线| 欧美激情在线一区二区三区|