[uart] Add first pass UART driver and logger

First attempt at a UART driver. I'm not sure it's the most stable. Now
that userspace is handling displaying logs, also removed serial and log
output support from the kernel.
This commit is contained in:
Justin C. Miller
2022-01-15 18:07:25 -08:00
parent 44d3918e4f
commit c631ec5ef5
40 changed files with 354 additions and 482 deletions

View File

@@ -0,0 +1,33 @@
#pragma once
/// \file serial.h
/// Declarations related to serial ports.
#include <stdint.h>
#include <util/bip_buffer.h>
#include <util/spinlock.h>
class serial_port
{
public:
/// Constructor.
/// \arg port The IO address of the serial port
serial_port(uint16_t port,
size_t in_buffer_len, uint8_t *in_buffer,
size_t out_buffer_len, uint8_t *out_buffer);
size_t write(const char *str, size_t len);
char read();
void handle_interrupt();
private:
bool m_writing;
uint16_t m_port;
util::bip_buffer m_out_buffer;
util::bip_buffer m_in_buffer;
util::spinlock m_lock;
void do_read();
void do_write();
void handle_error(uint16_t reg, uint8_t value);
};