AxlSerial — serial-port enumeration + line-setting readout
Serial-port enumeration via EFI_SERIAL_IO_PROTOCOL.
Header: <axl/axl-serial.h>. A read-only descriptor probe for
inventory and diagnostics: it enumerates the firmware’s serial-I/O
handles and reads each port’s current line settings (baud, framing,
timeout, FIFO depth) and modem control/status lines. It does not open
a port or move bytes — console byte I/O is <axl/axl-stream.h>; this
is the lower-level port descriptor.
Lazy on first call: AxlSerial locates the serial-I/O handles once with
LocateHandleBuffer and caches the set for the image lifetime. On
platforms with no serial ports every call returns NULL / AXL_ERR
cleanly.
Cursor-style enumeration matches axl_block_next / axl_usb_next and
returns the firmware AxlHandle directly, so position is recovered
from the handle you pass back — no hidden shared cursor:
AxlHandle h = NULL;
while ((h = axl_serial_next(h)) != NULL) {
AxlSerialMode m;
AxlSerialControl c;
if (axl_serial_get_mode(h, &m) == AXL_OK) {
axl_printf("Uart(%u,%u,parity=%u,stop=%u)\n",
m.baud_rate, m.data_bits, m.parity, m.stop_bits);
}
if (axl_serial_get_control(h, &c) == AXL_OK && c.cts) {
axl_printf(" CTS asserted\n");
}
}
Device-path text needs no extra API: the same AxlHandle resolves
through the existing axl_handle_get_protocol(h, "device-path", ...)
axl_device_path_to_text()(both in<axl/axl-sys.h>).
parity and stop_bits are raw enum codes the consumer names (e.g.
"N", "8N1"); baud_rate is the firmware’s UINT64 BaudRate
narrowed to 32 bits (every real UART rate fits).
API Reference
Serial-port enumeration and line-setting readout.
Enumerates the handles publishing the firmware’s serial-I/O protocol and reads each port’s line settings (baud, framing, timeout, FIFO depth) and modem control/status lines. This is a read-only descriptor probe for inventory and diagnostics — it does not open a port, transmit, or receive. (Console byte I/O is <axl/axl-stream.h>; this is the lower-level port descriptor.)
Cursor-style iteration matches the other platform readers and returns the firmware AxlHandle directly:
AxlHandle h = NULL;
while ((h = axl_serial_next(h)) != NULL) {
AxlSerialMode m;
if (axl_serial_get_mode(h, &m) == AXL_OK) {
// ... report Uart(baud, data, parity, stop) ...
}
}
Device-path text needs no new API: the same AxlHandle resolves through the existing axl_handle_get_protocol(h, "device-path", ...) + axl_device_path_to_text() (both in <axl/axl-sys.h>).
Line-setting fields are raw readouts; the consumer names the parity/stop-bit codes (e.g. “N”, “8N1”).
Functions
-
AxlHandle axl_serial_next(AxlHandle prev)
Iterate handles publishing the serial-I/O protocol.
Cursor-style enumeration: pass NULL to get the first serial handle, then pass each returned handle back to get the next. Returns NULL once exhausted (including when no serial ports exist).
The handle set is located once and cached for the image lifetime (like AxlBlock / AxlUsb) — a port that appears afterward will not show up; the cache mirrors the boot device set. Position is recovered from the handle you pass back, not a hidden shared cursor: passing NULL — or any handle not in the cached set — starts again from the first port, and independent walks do not interfere. The returned handle is firmware-owned (do not free) and valid to pass to the readers below and to
axl_handle_get_protocol(h, "device-path", ...).- Parameters:
prev – previous handle, or NULL to start
- Returns:
next serial-I/O handle, or NULL at end of enumeration.
-
int axl_serial_get_mode(AxlHandle handle, AxlSerialMode *out)
Read a serial port’s current line settings.
- Parameters:
handle – handle from axl_serial_next
out – [out] populated on success
- Returns:
AXL_OK on success, AXL_ERR if
handledoes not publish the serial-I/O protocol oroutis NULL.
-
int axl_serial_get_control(AxlHandle handle, AxlSerialControl *out)
Read a serial port’s modem control/status lines.
Calls the protocol’s GetControl and decodes the handshake bits.
- Parameters:
handle – handle from axl_serial_next
out – [out] populated on success
- Returns:
AXL_OK on success, AXL_ERR if
handledoes not publish the serial-I/O protocol, the GetControl call fails, oroutis NULL.
-
struct AxlSerialMode
- #include <axl-serial.h>
Line settings for a serial port.
Typed projection of the firmware’s
SERIAL_IO_MODE(current attributes).parityandstop_bitsare raw enum codes the consumer maps to names; the firmware fields are:parity: 0 Default, 1 None, 2 Even, 3 Odd, 4 Mark, 5 Space
stop_bits: 0 Default, 1 OneStopBit, 2 OneFive, 3 Two
Public Members
-
uint32_t baud_rate
current baud rate; 0 = device’s designed speed (firmware field is UINT64, narrowed to 32 bits — every real UART rate fits)
-
uint32_t data_bits
data bits per character (5-8; 0 = device default)
-
uint8_t parity
parity code (EFI_PARITY_TYPE raw)
-
uint8_t stop_bits
stop-bits code (EFI_STOP_BITS_TYPE raw)
-
uint32_t timeout
receive/transmit timeout in microseconds (0 = device default)
-
uint32_t receive_fifo_depth
receive FIFO depth in bytes
-
struct AxlSerialControl
- #include <axl-serial.h>
Modem control/status lines for a serial port.
Decoded from the protocol’s GetControl bitmask. These are the status/handshake lines a diagnostic view reports; the consumer formats them.