Browse Source
Merge pull request #1224 from riscv-software-src/uart-poll-less-often
For NS16550 UART, poll stdin less often
pull/1229/head
Andrew Waterman
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
1 deletions
-
riscv/devices.h
-
riscv/ns16550.cc
|
|
|
@ -148,6 +148,9 @@ class ns16550_t : public abstract_device_t { |
|
|
|
void update_interrupt(void); |
|
|
|
uint8_t rx_byte(void); |
|
|
|
void tx_byte(uint8_t val); |
|
|
|
|
|
|
|
int backoff_counter; |
|
|
|
static const int MAX_BACKOFF = 16; |
|
|
|
}; |
|
|
|
|
|
|
|
class mmio_plugin_device_t : public abstract_device_t { |
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ |
|
|
|
|
|
|
|
ns16550_t::ns16550_t(class bus_t *bus, abstract_interrupt_controller_t *intctrl, |
|
|
|
uint32_t interrupt_id, uint32_t reg_shift, uint32_t reg_io_width) |
|
|
|
: bus(bus), intctrl(intctrl), interrupt_id(interrupt_id), reg_shift(reg_shift), reg_io_width(reg_io_width) |
|
|
|
: bus(bus), intctrl(intctrl), interrupt_id(interrupt_id), reg_shift(reg_shift), reg_io_width(reg_io_width), backoff_counter(0) |
|
|
|
{ |
|
|
|
ier = 0; |
|
|
|
iir = UART_IIR_NO_INT; |
|
|
|
@ -300,11 +300,19 @@ void ns16550_t::tick(void) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (backoff_counter > 0 && backoff_counter < MAX_BACKOFF) { |
|
|
|
backoff_counter++; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
int rc = canonical_terminal_t::read(); |
|
|
|
if (rc < 0) { |
|
|
|
backoff_counter = 1; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
backoff_counter = 0; |
|
|
|
|
|
|
|
rx_queue.push((uint8_t)rc); |
|
|
|
lsr |= UART_LSR_DR; |
|
|
|
update_interrupt(); |
|
|
|
|