tty

14 篇文章 0 订阅
3 篇文章 0 订阅

         tty_insert_flip_string(porty, (u8 *)rx_buf, i);
         tty_flip_buffer_push(porty); 

 

-->

void tty_flip_buffer_push(struct tty_port *port)
{
        tty_schedule_flip(port);                                                                                                                                                                            
}

 

-->

void tty_schedule_flip(struct tty_port *port)
{
        struct tty_bufhead *buf = &port->buf;

        /* paired w/ acquire in flush_to_ldisc(); ensures
         * flush_to_ldisc() sees buffer data.
         */
        smp_store_release(&buf->tail->commit, buf->tail->used);
        queue_work(system_unbound_wq,  &buf->work);                                                                                                                                                          
}

 

---------------------------------------------------------------------------->

INIT_WORK(&buf->work, flush_to_ldisc);

 

-->

static void flush_to_ldisc(struct work_struct *work)
{

count = receive_buf(disc, head, count);

}

 

-->

static int
receive_buf(struct tty_ldisc *ld, struct tty_buffer *head, int count)                                                                                                                                       
{
        unsigned char *p = char_buf_ptr(head, head->read);
        char          *f = NULL;

        if (~head->flags & TTYB_NORMAL)
                f = flag_buf_ptr(head, head->read);

        return tty_ldisc_receive_buf(ld, p, f, count);
}

-->

int tty_ldisc_receive_buf(struct tty_ldisc *ld, unsigned char *p,
                          char *f, int count)
{                       
        if (ld->ops->receive_buf2)
                count = ld->ops->receive_buf2(ld->tty, p, f, count);
        else {          
                count = min_t(int, count, ld->tty->receive_room);
                if (count && ld->ops->receive_buf)
                        ld->ops->receive_buf(ld->tty, p, f, count);
        }
        return count;
}

-->

2441 static struct tty_ldisc_ops n_tty_ops = {
2442         .magic           = TTY_LDISC_MAGIC,
2443         .name            = "n_tty",
2444         .open            = n_tty_open,
2445         .close           = n_tty_close,
2446         .flush_buffer    = n_tty_flush_buffer,
2447         .read            = n_tty_read,
2448         .write           = n_tty_write,
2449         .ioctl           = n_tty_ioctl,
2450         .set_termios     = n_tty_set_termios,
2451         .poll            = n_tty_poll,
2452         .receive_buf     =  n_tty_receive_buf,                                                                                                                                                          
2453         .write_wakeup    = n_tty_write_wakeup,
2454         .receive_buf2    = n_tty_receive_buf2,
2455 };


-->

static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,                                                                                                                              
                              char *fp, int count)
{
        n_tty_receive_buf_common(tty, cp, fp, count, 0);
}

--->

static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
                          char *fp, int count)
{
        struct n_tty_data *ldata = tty->disc_data;
        bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));

        if (ldata->real_raw)
                n_tty_receive_buf_real_raw(tty, cp, fp, count);
        else if (ldata->raw || (L_EXTPROC(tty) && !preops))
                n_tty_receive_buf_raw(tty, cp, fp, count);


-->

 

static void
n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp,
                           char *fp, int count)
{
        struct n_tty_data *ldata = tty->disc_data;
        size_t n, head;
        
        head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
        n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
        memcpy(read_buf_addr(ldata, head), cp, n);
        ldata->read_head += n;
        cp += n;
        count -= n;
        
        head = ldata->read_head & (N_TTY_BUF_SIZE - 1);
        n = min_t(size_t, count, N_TTY_BUF_SIZE - head);
        memcpy(read_buf_addr(ldata, head), cp, n);
        ldata->read_head += n;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值