pub struct Serial {
_p: (),
}Expand description
A serial teletype interface for x86_64 systems.
This struct provides a basic implementation of a serial TTY using the
COM1 serial port. It implements the Teletype trait to allow
read and write operations over a serial interface.
Fields§
§_p: ()Implementations§
Trait Implementations§
Source§impl Teletype for Serial
impl Teletype for Serial
Source§fn write(&mut self, data: &[u8]) -> Result<usize, KernelError>
fn write(&mut self, data: &[u8]) -> Result<usize, KernelError>
Writes data to the serial teletype (COM1).
This function attempts to convert the input byte slice into a UTF-8 string. If the conversion is successful, it prints the string to the console. If the data is aligned to a 16-byte boundary, it is printed as a single string; otherwise, it is printed byte by byte.
§Arguments
data: The byte slice to be written.
§Returns
Ok(usize): The number of bytes written.Err: If the input data is not valid UTF-8.
Source§fn read(&mut self, data: &mut [u8]) -> Result<usize, KernelError>
fn read(&mut self, data: &mut [u8]) -> Result<usize, KernelError>
Reads data from the serial teletype (COM1).
This function retrieves data from the serial interface and stores it in the provided mutable buffer.
§Arguments
data: A mutable byte slice where the read data will be stored.
§Returns
Ok(usize): The number of bytes successfully read.Err: If the read operation failed.