 |
Xyris
0.5
|
Go to the documentation of this file.
25 #define RS_232_COM1_IRQ 0x04
26 #define RS_232_COM3_IRQ 0x04
27 #define RS_232_COM2_IRQ 0x03
28 #define RS_232_COM4_IRQ 0x03
30 #define RS_232_DATA_REG 0x0
31 #define RS_232_INTERRUPT_ENABLE_REG 0x1
32 #define RS_232_INTERRUPT_IDENTIFICATION_REG 0x2
33 #define RS_232_LINE_CONTROL_REG 0x3
34 #define RS_232_MODEM_CONTROL_REG 0x4
35 #define RS_232_LINE_STATUS_REG 0x5
36 #define RS_232_MODEM_STATUS_REG 0x6
37 #define RS_232_SCRATCH_REG 0x7
41 static uint16_t rs_232_port_base;
43 static Mutex mutex_rs232(
"rs232");
45 static int received();
46 static int is_transmit_empty();
47 static char read_byte();
48 static void callback(
struct registers* regs);
55 static int is_transmit_empty()
60 static char read_byte()
63 while (received() == 0)
70 static int vprintf_helper(
unsigned c,
void** ptr)
79 int vprintf(
const char* fmt, va_list args)
91 va_start(args, format);
92 ret_val =
vprintf(format, args);
97 static void callback(
struct registers* regs)
101 char in = read_byte();
115 rs_232_port_base = com_id;
135 " | |/ /_ _______(_)____ _ _|__ /\n"
136 " | / / / / ___/ / ___/ | | / //_ <\n"
137 " / / /_/ / / / (__ ) | |/ /__/ /\n"
138 "/_/|_\\__, /_/ /_/____/ |___/____/\n"
141 "Xyris Serial Output Debugger\n\n");
144 size_t read(
char* buf,
size_t count)
148 for (
size_t idx = 0; idx < count && !ring.IsEmpty(); idx++) {
149 buf[idx] = ring.Dequeue();
156 size_t write(
const char* buf,
size_t count)
159 while (is_transmit_empty() == 0);
161 for (
size_t idx = 0; idx < count; idx++) {
#define RS_232_LINE_STATUS_REG
bool unlock()
Release the mutex.
Resource Acquisition Is Initialization mutex. Locks when constructed and unlocks when destructed.
A ring buffer is a buffer method where the same memory used to contain data is reused....
#define RS_232_MODEM_CONTROL_REG
size_t write(const char *buf, size_t count)
Write bytes to the serial device.
Standard string and memory utility library.
A structure definining values for all x86 registers. Cannot be namespaced due to C linkage and ASM in...
size_t read(char *buf, size_t count)
Reads bytes from the serial buffer.
void registerHandler(uint8_t interrupt, InterruptHandler_t handler)
bool lock()
Aquire the mutex.
int vprintf(const char *fmt, va_list args)
Prints a formatted string to serial output using a va_list of arguments.
A simple, write-only driver for the RS232 serial device standard. Code mostly ported from Panix-Archi...
#define RS_232_INTERRUPT_ENABLE_REG
Architecture control and initialization.
static bool addWriter(LogWriter writer)
#define RS_232_INTERRUPT_IDENTIFICATION_REG
int close()
Closes the serial input buffer and frees all of the data contained within.
void lockedRegion(Function lockedWork, Mutex &mutex)
Mutex protected region lambda function. Executed the provided function after locking the provided mut...
static void Print(const char *fmt,...)
void init(uint16_t com_id)
Activates the RS232 serial driver.
void writeByte(uint16_t port, uint8_t data)
Writes a byte (8 bits) to the CPU bus at a given port address.
Liballoc heap implementation.
int printf_helper(const char *fmt, va_list args, printf_cb_fnptr_t fn, void *ptr)
Perform all printf operations on the format string using the provided argument list and uses the call...
uint8_t readByte(uint16_t port)
Reads a byte (8 bits) off the CPU bus at a given port address.
#define RS_232_LINE_CONTROL_REG
int printf(const char *format,...)
Prints a formatted string to serial output.