template <typename Driver, uint32_t KdrvExtra, typename KdrvConfig, IoRegisterType IoRegType, IoSlotType<IoRegType> IoSlots = kDynamicIoSlot>
class DriverBase
Defined at line 245 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
Specific hardware support is implemented in a class uart::xyz::Driver,
referred to here as UartDriver. The uart::DriverBase template class
provides a helper base class for UartDriver implementations.
The UartDriver object represents the hardware itself. Many UartDriver
classes hold no state other than the initial configuration data used in the
constructor, but a UartDriver is not required to be stateless. However, a
UartDriver is required to be copy-constructible, trivially destructible,
and contain no pointers. This makes it safe to copy an object set up by
physboot into a new object in the virtual-memory kernel to hand off the
configuration and the state of the hardware.
All access to the UartDriver object is serialized by its caller, so it does
no synchronization of its own. This serves to serialize the actual access
to the hardware.
The UartDriver API fills four roles:
1. Match a ZBI item that configures this driver.
2. Generate a ZBI item for another kernel to match this configuration.
3. Configure the IoProvider (see below).
4. Drive the actual hardware.
The first three are handled by DriverBase. The KdrvExtra and KdrvConfig
template arguments give the ZBI_KERNEL_DRIVER_* value and the zbi_dcfg_*_t type for the ZBI
item. The Pio template argument tells the IoProvider whether this driver
uses MMIO or PIO (including PIO via MMIO): the number of consecutive PIO
ports used, or 0 for simple MMIO.
Item matching is done by the MaybeCreate static method. If the item
matches KdrvExtra, then the UartDriver(KdrvConfig) constructor is called.
DriverBase provides this constructor to fill the cfg_ field, which the
UartDriver can then refer to. The UartDriver copy constructor copies it.
The calls to drive the hardware are all template functions passed an
IoProvider object (see below). The driver accesses device registers using
hwreg ReadFrom and WriteTo calls on the pointers from the provider. The
IoProvider constructed is passed uart.config() and uart.pio_size().
`IoSlots` is an opaque parameter whose meaning is tied to the value of `IoRegType`.
A very broad description would be the number of 'slots' to perform I/O operations.
* `kMmio8` and `kMmio32` represents the number of bytes from the base address with the proper
scaling factor applied, 1 and 4 respectively.
* `kPio` represents the number the port count.
Public Members
static array kDevicetreeBindings
static IoRegisterType kIoType
static const uint32_t kType
static const uint32_t kExtra
Protected Members
config_type cfg_
Public Methods
std::optional<uart::Config<Driver>> TryMatch (const zbi_header_t & header, const void * payload)
Defined at line 258 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
std::optional<uart::Config<Driver>> TryMatch (std::string_view string)
Defined at line 268 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
std::optional<uart::Config<Driver>> TryMatch (const acpi_lite::AcpiDebugPortDescriptor & debug_port)
API to match DBG2 Table (ACPI). Currently only 16550 compatible uarts are supported.
Defined at line 281 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
bool TrySelect (const devicetree::PropertyDecoder & decoder)
API to match a devicetree bindings.
Defined at line 287 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
void DriverBase<Driver, KdrvExtra, KdrvConfig, IoRegType, IoSlots> (const config_type & cfg)
Defined at line 307 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
void DriverBase<Driver, KdrvExtra, KdrvConfig, IoRegType, IoSlots> (const Config<Driver> & tagged_config)
Defined at line 308 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
void FillItem (void * payload)
API to fill a ZBI item describing this UART.
Defined at line 311 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
void Unparse (FILE * out)
API to reproduce a configuration string.
Defined at line 314 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
template <class IoProvider>
void SetLineControl (IoProvider & io, std::optional<DataBits> data_bits, std::optional<Parity> parity, std::optional<StopBits> stop_bits)
TODO(https://fxbug.dev/42053694): Remove once all drivers define this method.
Defined at line 321 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
const config_type & config ()
API for use in IoProvider setup.
Defined at line 328 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
template <IoSlotType<IoRegType> _IoSlots = IoSlots, std::enable_if_t<_IoSlots != kDynamicIoSlot, bool> = true>
IoSlotType<IoRegType> io_slots ()
Number of 'slots' to perform I/O operations.
Defined at line 333 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
template <IoSlotType<IoRegType> _IoSlots = IoSlots, std::enable_if_t<_IoSlots == kDynamicIoSlot, bool> = true>
IoSlotType<IoRegType> io_slots ()
Defined at line 339 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
MmioRange mmio_range ()
Defined at line 346 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
IoPortRange ioports ()
Defined at line 358 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
template <typename IoProvider, typename IrqProvider>
void PrepareForSuspend (IoProvider & io, IrqProvider & irq)
Prepare/Wake-up the UART hardware before going into, and after coming out
of a suspended state. Unlike other kernel API methods, these methods are
considered optional, and default to no-ops.
Defined at line 451 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h
template <typename IoProvider, typename IrqProvider>
void WakeupFromSuspend (IoProvider & io, IrqProvider & irq)
Defined at line 454 of file ../../zircon/system/ulib/uart/include/lib/uart/uart.h