diff options
-rw-r--r-- | sw/z80/crt0.s | 4 | ||||
-rw-r--r-- | sw/z80/kernel/include/devices.h | 13 | ||||
-rw-r--r-- | sw/z80/kernel/include/serial.h | 85 | ||||
-rw-r--r-- | sw/z80/kernel/include/types.h | 2 | ||||
-rw-r--r-- | sw/z80/kernel/kernel.c | 7 | ||||
-rw-r--r-- | sw/z80/libc/mem.c | 7 |
6 files changed, 104 insertions, 14 deletions
diff --git a/sw/z80/crt0.s b/sw/z80/crt0.s index 7701ca6..00c7da1 100644 --- a/sw/z80/crt0.s +++ b/sw/z80/crt0.s @@ -27,7 +27,7 @@ ;-------------------------------------------------------------------------- .module crt0 - .globl _main + .globl _kmain .area _HEADER (ABS) ;; Reset vector @@ -56,7 +56,7 @@ init: ;; Initialise global variables call gsinit - call _main + call _kmain jp _exit ;; Ordering of segments for the linker. diff --git a/sw/z80/kernel/include/devices.h b/sw/z80/kernel/include/devices.h new file mode 100644 index 0000000..ea29065 --- /dev/null +++ b/sw/z80/kernel/include/devices.h @@ -0,0 +1,13 @@ +#ifndef __DEVICES_H__ +#define __DEVICES_H__ + +#define ADDR_DEV_ROM_L 0x0000 +#define ADDR_DEV_ROM_H 0x2000 + +#define ADDR_DEV_USART 0x4000 +#define ADDR_DEV_CTC +#define ADDR_DEV_PIO + +#define ADDR_DEV_RAM 0x8000 + +#endif 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__ diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h index c24b311..552b7e9 100644 --- a/sw/z80/kernel/include/types.h +++ b/sw/z80/kernel/include/types.h @@ -1,6 +1,8 @@ #ifndef __TYPES_H__ #define __TYPES_H__ +#define register_t volatile unsigned char + #define int8_t char #define uint8_t unsigned char #define int16_t int diff --git a/sw/z80/kernel/kernel.c b/sw/z80/kernel/kernel.c index fe87c3d..3db6579 100644 --- a/sw/z80/kernel/kernel.c +++ b/sw/z80/kernel/kernel.c @@ -1,10 +1,7 @@ #include "types.h" -void main(void) +void kmain(void) { - int i, j = 20; - for (i = 0; i < 10; i++) { - j--; - } + } diff --git a/sw/z80/libc/mem.c b/sw/z80/libc/mem.c deleted file mode 100644 index 667a752..0000000 --- a/sw/z80/libc/mem.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "types.h" -#include "mem.h" - -void *malloc(size_t size) -{ - : -} |