Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_dev_ns8250.c
| Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | if (what & UART_DRAIN_TRANSMITTER) { | ||||
| * Pick an arbitrary high limit to avoid getting stuck in | * Pick an arbitrary high limit to avoid getting stuck in | ||||
| * an infinite loop when the hardware is broken. Make the | * an infinite loop when the hardware is broken. Make the | ||||
| * limit high enough to handle large FIFOs. | * limit high enough to handle large FIFOs. | ||||
| */ | */ | ||||
| limit = 10*1024; | limit = 10*1024; | ||||
| while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit) | while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit) | ||||
| DELAY(delay); | DELAY(delay); | ||||
| if (limit == 0) { | if (limit == 0) { | ||||
| /* printf("ns8250: transmitter appears stuck... "); */ | /* printf("uart: ns8250: transmitter appears stuck... "); */ | ||||
| return (EIO); | return (EIO); | ||||
| } | } | ||||
| } | } | ||||
| if (what & UART_DRAIN_RECEIVER) { | if (what & UART_DRAIN_RECEIVER) { | ||||
| /* | /* | ||||
| * Pick an arbitrary high limit to avoid getting stuck in | * Pick an arbitrary high limit to avoid getting stuck in | ||||
| * an infinite loop when the hardware is broken. Make the | * an infinite loop when the hardware is broken. Make the | ||||
| Show All 11 Lines | while (limit && (uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit) { | ||||
| do { | do { | ||||
| (void)uart_getreg(bas, REG_DATA); | (void)uart_getreg(bas, REG_DATA); | ||||
| uart_barrier(bas); | uart_barrier(bas); | ||||
| } while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit); | } while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit); | ||||
| uart_barrier(bas); | uart_barrier(bas); | ||||
| DELAY(delay << 2); | DELAY(delay << 2); | ||||
| } | } | ||||
| if (limit == 0) { | if (limit == 0) { | ||||
| /* printf("ns8250: receiver appears broken... "); */ | /* printf("uart: ns8250: receiver appears broken... "); */ | ||||
| return (EIO); | return (EIO); | ||||
| } | } | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| /* | /* | ||||
| Show All 23 Lines | ns8250_flush(struct uart_bas *bas, int what) | ||||
| * https://github.com/rust-vmm/vm-superio/issues/83 | * https://github.com/rust-vmm/vm-superio/issues/83 | ||||
| */ | */ | ||||
| lsr = uart_getreg(bas, REG_LSR); | lsr = uart_getreg(bas, REG_LSR); | ||||
| if (((lsr & LSR_TEMT) == 0) && (what & UART_FLUSH_TRANSMITTER)) | if (((lsr & LSR_TEMT) == 0) && (what & UART_FLUSH_TRANSMITTER)) | ||||
| drain |= UART_DRAIN_TRANSMITTER; | drain |= UART_DRAIN_TRANSMITTER; | ||||
| if ((lsr & LSR_RXRDY) && (what & UART_FLUSH_RECEIVER)) | if ((lsr & LSR_RXRDY) && (what & UART_FLUSH_RECEIVER)) | ||||
| drain |= UART_DRAIN_RECEIVER; | drain |= UART_DRAIN_RECEIVER; | ||||
| if (drain != 0) { | if (drain != 0) { | ||||
| printf("ns8250: UART FCR is broken\n"); | printf("uart: ns8250: UART FCR is broken\n"); | ||||
| ns8250_drain(bas, drain); | ns8250_drain(bas, drain); | ||||
| } | } | ||||
| } | } | ||||
| static int | static int | ||||
| ns8250_param(struct uart_bas *bas, int baudrate, int databits, int stopbits, | ns8250_param(struct uart_bas *bas, int baudrate, int databits, int stopbits, | ||||
| int parity) | int parity) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 857 Lines • Show Last 20 Lines | |||||