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)
Sat, Oct 19, 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
Unknown Object (File)
Sep 9 2024, 6:01 AM
Unknown Object (File)
Sep 9 2024, 3:13 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 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.

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