#pragma once #include #include "ports.h" /* * Serial Port * * useful links: * https://wiki.osdev.org/Serial_Ports * https://www.lowlevel.eu/wiki/Serielle_Schnittstelle */ class SerialPort : public Console { public: SerialPort(); ~SerialPort() = default; bool self_check() const { return self_check_okay; } bool ready_read(); uint8_t read(); bool ready_write(); void write(char c) override; void write(ViewIterator& iter) override { while (iter) write(iter.next()); } void update_cursor() override {} private: bool self_check_okay; enum PortOffset : uint16_t { BaudDiv_l = 0, // if dlab is set BaudDiv_h = 1, // if dlab is set Data = 0, // read from receive buffer / write to transmit buffer InterruptControl = 1, // interrupt enable FifoControl = 2, // interrupt ID and FIFO control LineControl = 3, // most significant bit is the DLAB ModemControl = 4, LineStatus = 5, ModemStatus = 6, Scratch = 7, }; com1_port_t port; };