summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include/serial.h
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-05-02 22:09:40 +0200
committerNao Pross <naopross@thearcway.org>2017-05-02 22:09:40 +0200
commit8a461a14c3ceaf42f1483abe51cda47ac785bfc9 (patch)
treeb31789c1c24340e2e0f391f875aa5a12fc85d485 /sw/z80/kernel/include/serial.h
parentMerge branch 'atlas' into naopross (diff)
downloadz80uPC-8a461a14c3ceaf42f1483abe51cda47ac785bfc9.tar.gz
z80uPC-8a461a14c3ceaf42f1483abe51cda47ac785bfc9.zip
add serial device struct
other changes: - change from main() to kmain() in crt0.s and kernel.c - new file devices.h to define all address locations for devices - new data type - register_t as volatile uint8_t for registers in devices - size_t from libc
Diffstat (limited to 'sw/z80/kernel/include/serial.h')
-rw-r--r--sw/z80/kernel/include/serial.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/sw/z80/kernel/include/serial.h b/sw/z80/kernel/include/serial.h
new file mode 100644
index 0000000..03e2448
--- /dev/null
+++ b/sw/z80/kernel/include/serial.h
@@ -0,0 +1,85 @@
+#ifndef __SERIAL_H__
+#define __SERIAL_H__
+
+#include "types.h"
+#include "devices.h"
+
+/* this structure is only for internal usage */
+struct _usart_device
+{
+ register_t buffer; // also used as LSB for divisor latch
+
+ struct IER
+ {
+ volatile int received_data_interrupt :1;
+ volatile int transmitter_empty_interrupt :1;
+ volatile int receiver_line_status_interrupt :1;
+ volatile int modem_status_interrupt :1;
+ volatile int reserved :4;
+ } IER;
+
+ struct IIR
+ {
+ volatile int interrupt_pending :1;
+ volatile int interrupt_id :3;
+ volatile int reserved :2;
+ volatile int fifos :2;
+ } IIR;
+
+ struct FCR
+ {
+ volatile int fifo_enable :1;
+ volatile int receiver_fifo_rst :1;
+ }
+
+ struct LCR
+ {
+ volatile int word_length :2;
+ volatile int stop_bits :1;
+ volatile int parity :1;
+ volatile int even_parity :1;
+ volatile int stick_parity :1;
+ volatile int break_control :1;
+ volatile int divisor_latch_access :1;
+ } LCR;
+
+ struct MCR
+ {
+ volatile int data_terminal_ready :1;
+ volatile int request_to_send :1;
+ volatile int out1;
+ volatile int out2;
+ volatile int loop;
+ volatile int autoflow :1;
+ volatile int reserved :2;
+ } MCR;
+
+ struct LSR
+ {
+ volatile int data_ready :1;
+ volatile int overrun_error :1;
+ volatile int parity_error :1;
+ volatile int framing_error :1;
+ volatile int break_interrupt :1;
+ volatile int transmitter_register :1;
+ volatile int transmitter_emtpy :1;
+ volatile int fifo_recv_error :1;
+ } LSR;
+
+ struct MSR
+ {
+ volatile int delta_cts :1;
+ volatile int delta_data_set_ready :1;
+ volatile int trailing_edge_ring_indicator :1;
+ volatile int delta_data_carrier_detect :1;
+ volatile int clear_to_send :1;
+ volatile int data_set_ready :1;
+ volatile int ring_indicator :1;
+ volatile int data_carrier_detect :1;
+ } MSR;
+
+ register_t scratch;
+} *_usart = (_usart_device *) ADDR_DEV_USART;
+
+
+#endif // __SERIAL__H__