linux-uart

drivers/tty
tty_write()->(ld->ops->write)//调用线路规程的ld->ops的write(n_tty_write)
console_init()->tty_ldisc_begin()->tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY)
tty_ldiscs[disc] = new_ldisc;//设置ld->ops
tty_open()->tty_init_dev()->initialize_tty_struct()->tty_ldisc_init(tty)->
get_ldops(disc)->
ldops = tty_ldiscs[disc]//open的时候获取ld->ops
n_tty_write()->(tty->ops->write(tty, b, nr))调用tty->ops->write(uart_write)
uart_register_driver()->tty_set_operations(normal, &uart_ops)//设置tty->ops->
write
normal->driver_state = drv;//uart_driver保存在了tty_driver的driver_state
uart_write()->uart_start()->__uart_start()->(port->ops->start_tx(port))
tty_open()->tty_init_dev()->initialize_tty_struct()
tty->ops = driver->ops;
tty_open()->(tty->ops->open(tty, filp))//由于上述,该open为uart_open
uart_open()->
tty->driver_data = state;//uart_state保存在了tty_struct的driver_data
driver和device匹配:
uart_register_driver()->tty_register_driver()->list_add(&driver->tty_drivers,
&tty_drivers)/
tty_open()->
tty = tty_open_current_tty(device, filp);//获取tty_struct
tty_open()->tty_lookup_driver(device, filp, &noctty, &index)->get_tty_driver(
device, index)//获取tty_driver
static void __uart_start(struct tty_struct *tty)
{
struct uart_state *state = tty->driver_data;//上面设置了uart_state放到driver_data中
struct uart_port *port = state->uart_port;

if (port->ops->wake_peer)
port->ops->wake_peer(port);

if (!uart_circ_empty(&state->xmit) && state->xmit.buf &&
!tty->stopped && !tty->hw_stopped)
port->ops->start_tx(port);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值