Skip to content

Commit f823520

Browse files
andreeaflorescualxiord
authored andcommitted
renamed LOOP_SIZE to FIFO_SIZE and updated readme
Besides the rename, now the readme also specifies that the FIFO size is 64. Signed-off-by: Andreea Florescu <[email protected]>
1 parent efecba9 commit f823520

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ this support only for the
1111
### Design
1212

1313
The console emulation is done by emulating a simple
14-
[UART 16550A serial port](https://en.wikipedia.org/wiki/16550_UART).
14+
[UART 16550A serial port](https://en.wikipedia.org/wiki/16550_UART) with a
15+
64-byte FIFO.
1516
This UART is an improvement of the original
1617
[UART 8250 serial port](https://en.wikibooks.org/w/index.php?title=Serial_Programming/8250_UART_Programming&section=15#Serial_COM_Port_Memory_and_I/O_Allocation),
1718
mostly because of the FIFO buffers that allow storing more than one byte at a

src/serial.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const SCR_OFFSET: u8 = 7;
3030
const DLAB_LOW_OFFSET: u8 = 0;
3131
const DLAB_HIGH_OFFSET: u8 = 1;
3232

33-
const LOOP_SIZE: usize = 0x40;
33+
const FIFO_SIZE: usize = 0x40;
3434

3535
// Received Data Available interrupt - for letting the driver know that
3636
// there is some pending data to be processed.
@@ -316,7 +316,7 @@ impl<T: Trigger, W: Write> Serial<T, W> {
316316
// transmitted bytes and letting the driver know there is some
317317
// pending data to be read, by setting RDA bit and its
318318
// corresponding interrupt.
319-
if self.in_buffer.len() < LOOP_SIZE {
319+
if self.in_buffer.len() < FIFO_SIZE {
320320
self.in_buffer.push_back(value);
321321
self.set_lsr_rda_bit();
322322
self.received_data_interrupt().map_err(Error::Trigger)?;
@@ -530,7 +530,7 @@ mod tests {
530530
serial.write(MCR_OFFSET, MCR_LOOP_BIT).unwrap();
531531
serial.write(IER_OFFSET, IER_RDA_BIT).unwrap();
532532

533-
for value in 0..LOOP_SIZE as u8 {
533+
for value in 0..FIFO_SIZE as u8 {
534534
serial.write(DATA_OFFSET, value).unwrap();
535535
assert_eq!(intr_evt.read().unwrap(), 1);
536536
assert_eq!(serial.in_buffer.len(), 1);
@@ -540,15 +540,15 @@ mod tests {
540540

541541
assert_eq!(serial.line_status & LSR_DATA_READY_BIT, 0);
542542

543-
for value in 0..LOOP_SIZE as u8 {
543+
for value in 0..FIFO_SIZE as u8 {
544544
serial.write(DATA_OFFSET, value).unwrap();
545545
}
546546

547547
assert_eq!(intr_evt.read().unwrap(), 1);
548-
assert_eq!(serial.in_buffer.len(), LOOP_SIZE);
548+
assert_eq!(serial.in_buffer.len(), FIFO_SIZE);
549549

550550
// Read the pushed values at the end.
551-
for value in 0..LOOP_SIZE as u8 {
551+
for value in 0..FIFO_SIZE as u8 {
552552
assert_ne!(serial.line_status & LSR_DATA_READY_BIT, 0);
553553
assert_eq!(serial.read(DATA_OFFSET), value);
554554
}

0 commit comments

Comments
 (0)