rust-vmm / vm-superio

Emulation for legacy devices
Apache License 2.0
30 stars 25 forks source link

serial: implement receive FIFO flush via FCR #103

Open 00xc opened 11 months ago

00xc commented 11 months ago

Summary of the PR

The FIFO Control Register (FCR) controls the behavior of the receive and transmit FIFO buffers of the device. The current implementation does not emulate this register, as FIFO buffers are always enabled. However, there are two bits in this register that control flushing of said FIFOS. The transmission FIFO is already flushed by the current implementation on every write, but the receive FIFO is not. This is problematic, as some driver implementations (e.g. FreeBSD's) rely on being able to clear this buffer via the corresponding bit.

Implement the correct behavior when a driver sets this bit by clearing in_buffer. Since there is no more data in the receive FIFO, the data-ready bit in the Line Status Register (LSR) must be cleared as well, in case it was set.

Add a test for this new feature as well.

Fixes #83

Requirements

00xc commented 11 months ago

To be tested by @cperciva

00xc commented 11 months ago

@cperciva have you had time to test this patch?

00xc commented 6 months ago

CI failures are unrelated it seeems:

docker: error during connect: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": read unix @->/run/docker.sock: read: connection reset by peer