IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
serial.cpp File Reference

UART driver. More...

#include <array>
#include <arch/io.hpp>
#include <arch/irq.hpp>
#include <drivers/uart/serial.hpp>
#include <klib/kFlags.hpp>
#include <klib/kPrint.hpp>
#include <klib/kString.hpp>
Include dependency graph for serial.cpp:

Go to the source code of this file.

Namespaces

namespace  igros
 IgrOS kernel: common types and literals.
namespace  igros::arch
 Architecture-independent interface: drivers and aliases of current architecture types.
namespace  igros::arch::anonymous_namespace{serial.cpp}
 Anonymous namespace.

Enumerations

enum class  igros::arch::anonymous_namespace{serial.cpp}::SERIAL_REG : igros_word_t {
  igros::arch::anonymous_namespace{serial.cpp}::DATA = 0x00_u16 , igros::arch::anonymous_namespace{serial.cpp}::IER = 0x01_u16 , igros::arch::anonymous_namespace{serial.cpp}::IIR = 0x02_u16 , igros::arch::anonymous_namespace{serial.cpp}::LCR = 0x03_u16 ,
  igros::arch::anonymous_namespace{serial.cpp}::MCR = 0x04_u16 , igros::arch::anonymous_namespace{serial.cpp}::LSR = 0x05_u16 , igros::arch::anonymous_namespace{serial.cpp}::MSR = 0x06_u16 , igros::arch::anonymous_namespace{serial.cpp}::SCRATCH = 0x07_u16
}
 Serial port registers (offsets from port base). More...
enum class  igros::arch::anonymous_namespace{serial.cpp}::SERIAL_LSR : igros_byte_t { igros::arch::anonymous_namespace{serial.cpp}::DATA_READY = 0x01_u8 , igros::arch::anonymous_namespace{serial.cpp}::THR_EMPTY = 0x20_u8 , igros::arch::anonymous_namespace{serial.cpp}::TX_IDLE = 0x40_u8 }
 Line status register bits. More...
enum class  igros::arch::anonymous_namespace{serial.cpp}::SERIAL_IER : igros_byte_t { igros::arch::anonymous_namespace{serial.cpp}::RX_READY = 0x01_u8 }
 Interrupt enable register bits. More...
enum class  igros::arch::anonymous_namespace{serial.cpp}::SERIAL_MCR : igros_byte_t {
  igros::arch::anonymous_namespace{serial.cpp}::DTR = 0x01_u8 , igros::arch::anonymous_namespace{serial.cpp}::RTS = 0x02_u8 , igros::arch::anonymous_namespace{serial.cpp}::OUT1 = 0x04_u8 , igros::arch::anonymous_namespace{serial.cpp}::OUT2 = 0x08_u8 ,
  igros::arch::anonymous_namespace{serial.cpp}::LOOPBACK = 0x10_u8
}
 Modem control register bits. More...

Functions

static constexpr auto igros::arch::serialRegister (const SERIAL_PORT port, const SERIAL_REG reg) noexcept -> port_t
 Serial port register address.
static void igros::arch::serialRegWrite (const SERIAL_PORT port, const SERIAL_REG reg, const igros_byte_t value) noexcept
 Write serial port register.
static auto igros::arch::serialRegRead (const SERIAL_PORT port, const SERIAL_REG reg) noexcept -> igros_byte_t
 Read serial port register.
static auto igros::arch::serialStatus (const SERIAL_PORT port) noexcept -> klib::kFlags< SERIAL_LSR >
 Read line status register.
static auto igros::arch::serialWaitStatus (const SERIAL_PORT port, const SERIAL_LSR status) noexcept -> bool
 Wait until line status bit is set (bounded, so missing UART can't hang the kernel).
auto igros::arch::serialInit (const SERIAL_PORT port, const BAUD_RATE baudRate, const DATA_SIZE dataSize, const STOP_BITS stopBits, const PARITY parity) noexcept -> bool
 Initialize serial port.
auto igros::arch::serialReadyWrite (const SERIAL_PORT port) noexcept -> bool
 Is write ready?
auto igros::arch::serialReadyRead (const SERIAL_PORT port) noexcept -> bool
 Is read ready?
static auto igros::arch::serialWaitWrite (const SERIAL_PORT port) noexcept -> bool
 Wait until write ready.
static auto igros::arch::serialPut (const SERIAL_PORT port, const igros_byte_t value) noexcept -> bool
 Wait for transmitter and send one byte.
static auto igros::arch::serialPutSymbol (const SERIAL_PORT port, const char symbol) noexcept -> bool
 Send one symbol (new line is sent as CR LF).
static auto igros::arch::serialGetSymbol (const SERIAL_PORT port, char &symbol) noexcept -> bool
 Receive one symbol (only if available).
auto igros::arch::serialWrite (const SERIAL_PORT port, const std::string_view text) noexcept -> igros_usize_t
 Serial write.
auto igros::arch::serialRead (const SERIAL_PORT port, const std::span< char > buffer) noexcept -> igros_usize_t
 Serial read.
auto igros::arch::serialWrite (const std::string_view text) noexcept -> igros_usize_t
 Serial write to COM1 (kernel console).
auto igros::arch::serialWrite (const char *const src) noexcept -> igros_usize_t
 Serial write to COM1 (kernel console).
static void igros::arch::serialInterruptHandler1 (const register_t *const regs) noexcept
 Serial #1 | #3 IRQ handler.
auto igros::arch::serialSetup () noexcept -> bool
 Setup COM1 (115200 8N1) with receive interrupt.

Detailed Description

UART driver.

Date
03 Nov 2026
Author
Igor Baklykov

Definition in file serial.cpp.