mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
dm: flush the input/output during tty open.
Discard the input/output data when open tty file. To avoid the mevent callback is triggered immediately when the fd is added to epoll. Also update the uart_drain only read the data from tty file when fifo has available space. Tracked-On: #2159 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
88a7d8b2cc
commit
f6ae835137
@ -134,6 +134,7 @@ ttyopen(struct ttyfd *tf)
|
|||||||
tf->tio_new = tf->tio_orig;
|
tf->tio_new = tf->tio_orig;
|
||||||
cfmakeraw(&tf->tio_new);
|
cfmakeraw(&tf->tio_new);
|
||||||
tf->tio_new.c_cflag |= CLOCAL;
|
tf->tio_new.c_cflag |= CLOCAL;
|
||||||
|
tcflush(tf->fd_in, TCIOFLUSH);
|
||||||
tcsetattr(tf->fd_in, TCSANOW, &tf->tio_new);
|
tcsetattr(tf->fd_in, TCSANOW, &tf->tio_new);
|
||||||
|
|
||||||
if (tf->fd_in == STDIN_FILENO) {
|
if (tf->fd_in == STDIN_FILENO) {
|
||||||
@ -396,9 +397,10 @@ uart_drain(int fd, enum ev_type ev, void *arg)
|
|||||||
if ((uart->mcr & MCR_LOOPBACK) != 0) {
|
if ((uart->mcr & MCR_LOOPBACK) != 0) {
|
||||||
(void) ttyread(&uart->tty);
|
(void) ttyread(&uart->tty);
|
||||||
} else {
|
} else {
|
||||||
while ((ch = ttyread(&uart->tty)) != -1)
|
/* only read tty when rxfifo available to make sure no data lost */
|
||||||
|
while (rxfifo_available(uart) && (ch = ttyread(&uart->tty)) != -1) {
|
||||||
rxfifo_putchar(uart, ch);
|
rxfifo_putchar(uart, ch);
|
||||||
|
}
|
||||||
uart_toggle_intr(uart);
|
uart_toggle_intr(uart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user