[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:
33
src/user/drv.uart/serial.h
Normal file
33
src/user/drv.uart/serial.h
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user