Console Drivers
Unikraft provides console drivers for serial communication and text output. These drivers are essential for debugging and system monitoring in both physical and virtualized environments.Console Architecture
Console drivers integrate withlibukconsole, which provides a unified interface for character I/O. Multiple console devices can be registered, with output going to all enabled consoles.
Available Console Drivers
NS16550 UART Driver
The NS16550 driver supports 16550-compatible UARTs, which are standard on x86 PCs and many ARM platforms. Configuration:- x86_64: Port-mapped I/O (COM1-COM4)
- ARM64: Memory-mapped I/O (FDT-based discovery)
IBM PC/AT Mode (x86_64)
For x86_64 systems, the driver supports up to 4 COM ports with fixed I/O addresses: Configuration:FDT Mode (ARM64 and x86_64 with FDT)
For ARM64 and FDT-based systems, the driver discovers UART devices from the device tree: Configuration:/chosen/stdout-path property:
LIBUKLIBPARAM enabled, override the console device:
drivers/ukconsole/ns16550/
PL011 UART Driver
ARM PrimeCell UART (PL011) is the standard UART on ARM platforms like Raspberry Pi and QEMU virt machines. Configuration:LIBUKLIBPARAM enabled:
drivers/ukconsole/pl011/
VGA Console Driver
VGA text-mode console for x86 systems with VGA hardware. Configuration:- 80x25 text mode
- 16 colors
- Hardware scrolling
- Cursor positioning
- Video memory: 0xB8000
- 4000 bytes (2000 characters)
- Each character: 2 bytes (ASCII + attribute)
drivers/ukconsole/vgacons/
Console API
The console drivers implement thelibukconsole API:
Output Functions
Early Console
Early console is available before full system initialization:Configuration Comparison
| Feature | NS16550 (x86) | NS16550 (ARM) | PL011 | VGA |
|---|---|---|---|---|
| Architecture | x86_64 | ARM64 | ARM64 | x86_64 |
| Discovery | Fixed ports | FDT | FDT | Fixed address |
| Baud Rate | Configurable | Device-specific | Device-specific | N/A |
| Early Console | Yes | Yes | Yes | Yes |
| Interrupt Support | Yes | Yes | Yes | No |
| Multiple Devices | Up to 4 | Multiple (FDT) | Multiple (FDT) | Single |
Multi-Console Setup
Multiple consoles can be enabled simultaneously:Debugging Console Issues
No Output
-
Verify driver is enabled:
-
Check early console:
-
QEMU serial setup:
Garbled Output
- Check baud rate matches on both sides
- Verify clock frequency in device tree (ARM)
- Check for timing issues with early console
FDT Discovery Failures (ARM)
-
Enable debug output:
-
Verify FDT is loaded:
-
Check device tree:
Integration with Other Libraries
Debug Printing
Console drivers integrate withlibukdebug:
Standard I/O
With a C library (newlib, musl), console integrates with stdio:Performance Considerations
Interrupt vs. Polling
Interrupt mode (default):- Efficient CPU usage
- Better for interactive applications
- Requires interrupt controller
- Simpler implementation
- Higher CPU usage
- Useful for early boot
Buffering
Console output may be buffered. To flush:Common Use Cases
Serial Console for Debugging
Enable COM1 with early console:Logging to File
Redirect serial output to file:Multiple Consoles
Output to both serial and VGA:Console Driver Implementation
Implementing a custom console driver:Source Code Reference
Console driver source locations:References
- NS16550 Datasheet: https://www.ti.com/lit/ds/symlink/pc16550d.pdf
- PL011 Technical Reference: https://developer.arm.com/documentation/ddi0183/
- UART Programming: https://en.wikibooks.org/wiki/Serial_Programming/
- Source:
drivers/ukconsole/in Unikraft repository