Page MenuHomeFreeBSD

bhyve: Move device model-independent UART code into a separate file
AcceptedPublic

Authored by markj on Jul 12 2023, 1:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 2:14 AM
Unknown Object (File)
Dec 11 2023, 4:26 AM
Unknown Object (File)
Nov 21 2023, 3:36 AM
Unknown Object (File)
Nov 20 2023, 9:18 PM
Unknown Object (File)
Aug 28 2023, 9:44 AM
Unknown Object (File)
Aug 27 2023, 2:53 PM
Unknown Object (File)
Aug 14 2023, 2:28 PM
Unknown Object (File)
Aug 14 2023, 1:43 AM

Details

Reviewers
jhb
corvink
andrew
Group Reviewers
bhyve
Summary

Currently bhyve implements a ns16550-compatible UART in uart_emul.c.
This file also contains generic code to manage RX FIFOs and to handle
reading from and writing to a TTY. bhyve instantiates UARTs to
implement COM devices (via pci_lpc.c) and PCI UART devices.

The arm64 port will bring with it a PL011 device model which is used as
the default console (i.e., no COM ports). To simplify its integration,
add a UART "backend" layer which lets UART device models allocate an RX
FIFO and interact with TTYs without duplicating code. In particular,
code in uart_backend.* is to be shared among device models, and the
namespace for uart_emul.* is changed to uart_ns16550_*.

This is based on andrew@'s work in
https://github.com/zxombie/freebsd/tree/bhyvearm64 but I've made quite a
few small changes, particularly with respect to naming and source code
organization.

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 52586
Build 49477: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jul 12 2023, 1:52 PM

I did not review the changes in detail, but the concept certainly makes sense and we use a similar model in other places (e.g. the block_if layer vs nvme, virtio-block, and ahci frontends).

This revision is now accepted and ready to land.Jul 12 2023, 6:46 PM
corvink added inline comments.
usr.sbin/bhyve/uart_backend.c
128–142
159–174
217–233
usr.sbin/bhyve/uart_emul.c
197

Oh. I see, that the functions are copied. Feel free to ignore my suggestions.

markj added inline comments.
usr.sbin/bhyve/uart_emul.c
197

I'll leave the code unmodified for now.