Page MenuHomeFreeBSD

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

Authored by markj on Jul 12 2023, 1:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 21, 6:50 AM
Unknown Object (File)
Thu, Nov 14, 1:00 AM
Unknown Object (File)
Oct 19 2024, 1:25 PM
Unknown Object (File)
Sep 24 2024, 4:17 AM
Unknown Object (File)
Sep 21 2024, 10:15 AM
Unknown Object (File)
Sep 13 2024, 6:34 AM
Unknown Object (File)
Sep 9 2024, 7:19 AM
Unknown Object (File)
Sep 9 2024, 6:08 AM

Details

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 Not Applicable
Unit
Tests Not Applicable

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
129–143
160–175
218–234
usr.sbin/bhyve/uart_emul.c
192

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

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

I'll leave the code unmodified for now.

This revision was automatically updated to reflect the committed changes.
markj marked an inline comment as done.