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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? serial_core.c

?? Linux驅(qū)動(dòng)編程源碼
?? C
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
/* *  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);}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美乱妇15p| 午夜影视日本亚洲欧洲精品| 日韩免费一区二区| 在线综合视频播放| 欧美高清hd18日本| 欧美高清性hdvideosex| 6080国产精品一区二区| 7777精品伊人久久久大香线蕉超级流畅 | 91麻豆国产福利在线观看| 成人免费av资源| 99久久精品情趣| 91视频在线看| 欧美日韩一级片在线观看| 欧美日韩黄色影视| 欧美一区二区久久久| 日韩三级伦理片妻子的秘密按摩| 日韩视频免费观看高清在线视频| 91精选在线观看| 精品国产一区久久| 欧美韩日一区二区三区四区| 国产精品视频看| 亚洲伦理在线精品| 午夜精品久久久久久久| 另类成人小视频在线| 国内欧美视频一区二区| 成人午夜伦理影院| 91色乱码一区二区三区| 欧美四级电影网| 日韩欧美高清一区| 国产欧美日韩在线看| 中文字幕亚洲精品在线观看| 亚洲一区二区欧美日韩| 美腿丝袜在线亚洲一区| 懂色av中文字幕一区二区三区| 99在线热播精品免费| 欧美日韩五月天| 久久亚区不卡日本| 亚洲日本在线观看| 日本色综合中文字幕| 国产xxx精品视频大全| 91高清视频免费看| 精品少妇一区二区三区视频免付费| 欧美激情一区二区三区| 亚洲一区二区四区蜜桃| 国产一区二区免费在线| 91久久精品一区二区| 日韩色视频在线观看| 中文字幕av免费专区久久| 亚洲国产综合人成综合网站| 精品一区二区久久久| 91欧美一区二区| 日韩一区二区在线播放| 成人欧美一区二区三区视频网页 | 亚洲色图20p| 美女精品一区二区| 99精品欧美一区二区三区小说 | 石原莉奈一区二区三区在线观看| 久久国产精品免费| 色哟哟一区二区三区| 精品欧美一区二区久久| 亚洲自拍偷拍av| 国产福利一区在线| 欧美一区二区视频免费观看| 国产精品久久久久久亚洲伦| 日韩av电影免费观看高清完整版在线观看 | 国产精品国产三级国产三级人妇| 丝袜美腿一区二区三区| 99久久精品情趣| 2023国产一二三区日本精品2022| 亚洲国产综合人成综合网站| 成人性生交大合| 日韩免费一区二区| 一区二区高清在线| 成人一级视频在线观看| 欧美一级黄色片| 亚洲成年人影院| 99视频精品全部免费在线| 精品国产乱码91久久久久久网站| 亚洲在线一区二区三区| 99在线热播精品免费| 国产亚洲一区二区三区四区| 日本一区中文字幕| 欧美色电影在线| 亚洲免费观看在线视频| 大尺度一区二区| 精品国精品国产尤物美女| 日韩avvvv在线播放| 欧美在线观看你懂的| 亚洲欧美在线视频| 成人v精品蜜桃久久一区| 久久久国产午夜精品| 久久国产精品99久久久久久老狼| 欧美日韩aaa| 亚洲福利视频一区| 在线精品国精品国产尤物884a| 国产精品免费看片| 成人午夜激情影院| 中文成人av在线| 成人网男人的天堂| 国产精品午夜在线| 不卡电影一区二区三区| 中文字幕乱码一区二区免费| 国产成人亚洲综合a∨猫咪| 久久一夜天堂av一区二区三区| 美女网站视频久久| 日韩女优制服丝袜电影| 美国av一区二区| 精品福利视频一区二区三区| 狠狠色狠狠色综合系列| 久久天天做天天爱综合色| 久久99精品国产麻豆婷婷洗澡| 欧美成人精品二区三区99精品| 蜜桃一区二区三区在线观看| 欧美成人vr18sexvr| 精品一区二区三区日韩| 精品日韩一区二区三区| 国产一区二区三区视频在线播放| 2020国产精品自拍| 国产东北露脸精品视频| 国产精品欧美精品| 99vv1com这只有精品| 亚洲综合久久久久| 日韩一区二区三区观看| 国内精品免费**视频| 欧美国产日韩一二三区| 91首页免费视频| 亚洲福利国产精品| 欧美www视频| 成人午夜视频福利| 亚洲精品免费看| 91精品国产91久久久久久一区二区 | 日韩你懂的在线播放| 国产精品18久久久久久久久| 国产精品久久久久影院亚瑟| 91国产福利在线| 七七婷婷婷婷精品国产| 国产日韩欧美综合一区| 色一情一乱一乱一91av| 日本一区中文字幕| 中文字幕乱码一区二区免费| 在线国产亚洲欧美| 六月婷婷色综合| 成人免费在线视频观看| 欧美日韩美女一区二区| 国产一区二区看久久| 亚洲美腿欧美偷拍| 欧美刺激午夜性久久久久久久| 成人精品免费看| 天堂久久一区二区三区| 国产三区在线成人av| 色老汉av一区二区三区| 麻豆精品在线观看| 中文字幕佐山爱一区二区免费| 91精品免费观看| eeuss影院一区二区三区| 午夜伦欧美伦电影理论片| 久久久精品综合| 欧美午夜精品久久久久久孕妇 | 韩国v欧美v日本v亚洲v| 亚洲伦理在线免费看| 26uuu国产日韩综合| 91久久精品网| 国产91在线看| 视频一区视频二区中文| 综合电影一区二区三区| 日韩精品一区二区三区中文不卡| 91蝌蚪porny九色| 7777精品久久久大香线蕉| 国产河南妇女毛片精品久久久 | 色老头久久综合| 国产剧情一区在线| 日韩精品一二区| 亚洲男人的天堂在线aⅴ视频| 精品国产人成亚洲区| 欧美丝袜第三区| av一本久道久久综合久久鬼色| 免费人成精品欧美精品| 一区二区三区在线视频观看| 久久美女艺术照精彩视频福利播放 | 国产精品狼人久久影院观看方式| 7777女厕盗摄久久久| 日本韩国欧美三级| 成人av网站在线| 国产一区二区免费看| 裸体歌舞表演一区二区| 午夜欧美电影在线观看| 亚洲视频一二区| 国产日韩av一区| 精品播放一区二区| 欧美一级高清大全免费观看| 欧美亚洲动漫另类| 色妹子一区二区| www.色综合.com| 成人午夜在线播放| 国产精品一区二区三区99| 精品中文字幕一区二区| 蜜桃在线一区二区三区| 日本欧美在线观看| 日韩高清在线不卡| 亚洲成人1区2区|