mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-09-19 18:31:20 +00:00
processmanager: use rx_fifo_level in OpenTitanUARTDriver
Use RX_FIFO_LEVEL additionally to RX_EMPTY. This improves performance a bit, as RX_EMPTY register and circular buffer status don't have to be read for every byte. Change-Id: Ib56b4c6a0dc5689b63941b449f476f3555421abb GitOrigin-RevId: f7a46154afaf5be28feab173687cebd8b584e8f4
This commit is contained in:
committed by
Sam Leffler
parent
8961c75d25
commit
18474970dc
@@ -76,6 +76,11 @@ static uint32_t tx_fifo_level() {
|
|||||||
return SHIFT_DOWN_AND_MASK(REG(FIFO_STATUS), FIFO_STATUS, TXLVL);
|
return SHIFT_DOWN_AND_MASK(REG(FIFO_STATUS), FIFO_STATUS, TXLVL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gets the number of unread bytes in the RX FIFO from hardware MMIO.
|
||||||
|
static uint32_t rx_fifo_level() {
|
||||||
|
return SHIFT_DOWN_AND_MASK(REG(FIFO_STATUS), FIFO_STATUS, RXLVL);
|
||||||
|
}
|
||||||
|
|
||||||
// Gets whether the receive FIFO empty status bit is set.
|
// Gets whether the receive FIFO empty status bit is set.
|
||||||
//
|
//
|
||||||
// Prefer this to FIFO_STATUS.RXLVL, which the simulation has sometimes reported
|
// Prefer this to FIFO_STATUS.RXLVL, which the simulation has sometimes reported
|
||||||
@@ -276,7 +281,8 @@ void tx_watermark_handle(void) {
|
|||||||
void rx_watermark_handle(void) {
|
void rx_watermark_handle(void) {
|
||||||
LOCK(rx_mutex);
|
LOCK(rx_mutex);
|
||||||
while (!rx_empty()) {
|
while (!rx_empty()) {
|
||||||
if (circular_buffer_remaining(&rx_buf) == 0) {
|
size_t buffer_remaining = circular_buffer_remaining(&rx_buf);
|
||||||
|
if (buffer_remaining == 0) {
|
||||||
// The buffer is full.
|
// The buffer is full.
|
||||||
//
|
//
|
||||||
// We want to stay in this invocation of the interrupt handler until the
|
// We want to stay in this invocation of the interrupt handler until the
|
||||||
@@ -289,8 +295,12 @@ void rx_watermark_handle(void) {
|
|||||||
LOCK(rx_mutex);
|
LOCK(rx_mutex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
size_t to_read = rx_fifo_level();
|
||||||
|
to_read = to_read > buffer_remaining ? buffer_remaining : to_read;
|
||||||
|
while(to_read--) {
|
||||||
KATA_ASSERT(circular_buffer_push_back(&rx_buf, uart_getchar()));
|
KATA_ASSERT(circular_buffer_push_back(&rx_buf, uart_getchar()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
KATA_ASSERT(rx_nonempty_semaphore_post() == 0);
|
KATA_ASSERT(rx_nonempty_semaphore_post() == 0);
|
||||||
UNLOCK(rx_mutex);
|
UNLOCK(rx_mutex);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user