직렬 드라이버가 tty 포트에 연결되는 방법

직렬 드라이버가 tty 포트에 연결되는 방법

여기에서 Linus 샘플 UART 드라이버 코드를 살펴보겠습니다.

https://github.com/martinezjavier/ldd3/blob/master/tty/tiny_serial.c

다음은 tty 포트로 데이터를 보내는 UART 드라이버의 코드 조각입니다.

static void tiny_timer(unsigned long data)
{
    struct uart_port *port;
    struct tty_struct *tty;
    struct tty_port *tty_port;


    port = (struct uart_port *)data;
    if (!port)
        return;
    if (!port->state)
        return;
    tty = port->state->port.tty;
    if (!tty)
        return;

    tty_port = tty->port;

    /* add one character to the tty port */
    /* this doesn't actually push the data through unless tty->low_latency is set */
    tty_insert_flip_char(tty_port, TINY_DATA_CHARACTER, 0);

    tty_flip_buffer_push(tty_port);

    /* resubmit the timer again */
    timer->expires = jiffies + DELAY_TIME;
    add_timer(timer);

    /* see if we have any data to transmit */
    tiny_tx_chars(port);
}

그러나 코드를 보면 UART 포트와 tty 포트 간의 결합이 어떻게 설정되는지 명확하지 않습니다. Linux에서는 수동 구성이 필요합니까?

관련 정보