kernel/logging/_serial.rs
1// SPDX-License-Identifier: GPL-3.0-only
2//! Serial port abstraction: the [`_Serial`] trait and the [`SerialPort`] identifier enum.
3//!
4//! Authors: MarioS271
5
6/// Interface for a serial port implementation.
7pub trait _Serial {
8 /// Create a new (uninitialized) serial port instance for the given COM port.
9 fn new(port: SerialPort) -> Self;
10
11 /// Program the UART hardware and mark the port ready; `Err` if already initialized.
12 fn init(&self) -> Result<(), &'static str>;
13
14 /// Write all bytes of `string` to the port, blocking until each is accepted.
15 fn write(&self, string: &str);
16}
17
18/// Identifier for one of the four standard IBM PC serial ports.
19pub enum SerialPort {
20 /// COM1 — I/O base address `0x03F8`, typically connected to the host in QEMU.
21 Serial1,
22 /// COM2 — I/O base address `0x02F8`.
23 Serial2,
24 /// COM3 — I/O base address `0x03E8`.
25 Serial3,
26 /// COM4 — I/O base address `0x02E8`.
27 Serial4
28}