diff options
author | Nao Pross <naopross@thearcway.org> | 2017-10-05 16:09:59 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-10-05 16:09:59 +0200 |
commit | eb169ea5a89909b90794e0388f89d6d372754e46 (patch) | |
tree | ce7e826fd2dd4e4248cb4f1fbf8ce2885c943f49 /sw/z80/kernel | |
parent | Test units are now in their own folder 'z80_test', add programmer cli interface (diff) | |
download | z80uPC-eb169ea5a89909b90794e0388f89d6d372754e46.tar.gz z80uPC-eb169ea5a89909b90794e0388f89d6d372754e46.zip |
Move test units to z80/tests, and drivers are now statically linked
Makefiles for the test units were getting messier, so now drivers
(that need to be tested) are statically compiled in their own
folder under z80/drivers.
The kernel makefile and is now broken since everything has been moved.
Diffstat (limited to '')
-rw-r--r-- | sw/z80/drivers/ctc.c (renamed from sw/z80/kernel/drivers/ctc.c) | 2 | ||||
-rw-r--r-- | sw/z80/drivers/include/ctc.h (renamed from sw/z80/kernel/include/drivers/ctc.h) | 0 | ||||
-rw-r--r-- | sw/z80/drivers/include/pio.h (renamed from sw/z80/kernel/include/drivers/pio.h) | 7 | ||||
-rw-r--r-- | sw/z80/drivers/include/usart.h (renamed from sw/z80/kernel/include/drivers/usart.h) | 9 | ||||
-rw-r--r-- | sw/z80/drivers/pio.c (renamed from sw/z80/kernel/drivers/pio.c) | 14 | ||||
-rw-r--r-- | sw/z80/drivers/usart.c (renamed from sw/z80/kernel/drivers/usart.c) | 2 | ||||
-rw-r--r-- | sw/z80/kernel/crt0.s (renamed from sw/z80/crt0.s) | 0 | ||||
-rw-r--r-- | sw/z80/kernel/makefile (renamed from sw/z80/makefile) | 18 |
8 files changed, 32 insertions, 20 deletions
diff --git a/sw/z80/kernel/drivers/ctc.c b/sw/z80/drivers/ctc.c index 841202a..5ac4254 100644 --- a/sw/z80/kernel/drivers/ctc.c +++ b/sw/z80/drivers/ctc.c @@ -1,4 +1,4 @@ -#include "drivers/ctc.h" +#include "ctc.h" void ctc_control() { diff --git a/sw/z80/kernel/include/drivers/ctc.h b/sw/z80/drivers/include/ctc.h index 80e8b4b..80e8b4b 100644 --- a/sw/z80/kernel/include/drivers/ctc.h +++ b/sw/z80/drivers/include/ctc.h diff --git a/sw/z80/kernel/include/drivers/pio.h b/sw/z80/drivers/include/pio.h index 0df2ed0..e91029c 100644 --- a/sw/z80/kernel/include/drivers/pio.h +++ b/sw/z80/drivers/include/pio.h @@ -1,8 +1,8 @@ #ifndef __PIO_H__ #define __PIO_H__ -#include "devices.h" -#include "types.h" +#include "addresses.h" +#include <stdint.h> #define PIO_A 0 #define PIO_B 1 @@ -20,6 +20,7 @@ inline void _pio_data(int port, uint8_t data); inline void _pio_control(int port, uint8_t cmd); +/* the last argument is needed only for IO mode */ void pio_set_mode(int port, int mode, uint8_t io); void pio_set_interrupts(int port, int control); @@ -34,4 +35,4 @@ inline void pio_write_pin(int port, uint8_t pin); // TODO: implement mode (in/out/both) and interrupt vector -#endif // __PIO_H__ +#endif /* __PIO_H__ */ diff --git a/sw/z80/kernel/include/drivers/usart.h b/sw/z80/drivers/include/usart.h index b85ee3e..bb06aab 100644 --- a/sw/z80/kernel/include/drivers/usart.h +++ b/sw/z80/drivers/include/usart.h @@ -1,10 +1,10 @@ #ifndef __USART_H__ #define __USART_H__ -#include "types.h" -#include "devices.h" +#include "addresses.h" -#include "string.h" +#include <stdint.h> +#include <string.h> // baudrate clock divisors // values from TL16C550C datasheet (table 9 for 1.8432 MHz crystal) @@ -48,6 +48,9 @@ #define USART_AUTOFLOW_CTS 2 #define USART_AUTOFLOW_OFF 0 +typedef unsigned int uint; +typedef uint8_t register_t; + /* stuctures for usart registers */ struct IER { diff --git a/sw/z80/kernel/drivers/pio.c b/sw/z80/drivers/pio.c index 4321fb8..bdbe1c3 100644 --- a/sw/z80/kernel/drivers/pio.c +++ b/sw/z80/drivers/pio.c @@ -1,4 +1,4 @@ -#include "drivers/pio.h" +#include "pio.h" static uint8_t *pio_port = (uint8_t *) ADDR_DEV_PIO; static uint8_t *pio_ctrl = (uint8_t *) (ADDR_DEV_PIO + 2); @@ -34,7 +34,17 @@ void pio_set_interrupts(int port, int control) void pio_set_interrupts_mask(int port, int control, uint8_t mask) { // 0x17 is a control sequence to set interrupts - // and to interpret the next byte as a mask + // AND interpret the next byte as a bitmask _pio_control(port, (control | 0x17)); _pio_control(port, mask); } + +uint8_t pio_read(int port) +{ + return *(pio_port + port); +} + +void pio_write(int port, uint8_t data) +{ + _pio_data(port, data); +} diff --git a/sw/z80/kernel/drivers/usart.c b/sw/z80/drivers/usart.c index c54fe37..9ec6dbd 100644 --- a/sw/z80/kernel/drivers/usart.c +++ b/sw/z80/drivers/usart.c @@ -1,4 +1,4 @@ -#include "drivers/usart.h" +#include "usart.h" static struct _usart_device *_usart = (struct _usart_device *) ADDR_DEV_USART; diff --git a/sw/z80/crt0.s b/sw/z80/kernel/crt0.s index 00c7da1..00c7da1 100644 --- a/sw/z80/crt0.s +++ b/sw/z80/kernel/crt0.s diff --git a/sw/z80/makefile b/sw/z80/kernel/makefile index 5ab7e93..be8eed4 100644 --- a/sw/z80/makefile +++ b/sw/z80/kernel/makefile @@ -3,9 +3,8 @@ # OSNAME := helvetiOS -CSOURCES := $(wildcard kernel/*.c) \ - $(wildcard kernel/drivers/*.c) \ - $(wildcard libc/*.c) +CSOURCES := $(wildcard *.c) \ + $(wildcard drivers/*.c) OBJECTS := $(patsubst %.c,build/%.rel,$(CSOURCES)) HEXFILE := build/$(OSNAME).hex @@ -17,13 +16,13 @@ BINARY := build/$(OSNAME).bin CC := sdcc CFLAGS := -mz80 \ - -I kernel/include \ - -I kernel/include/drivers \ + -I include \ + -I include/drivers \ -I libc/include \ --opt-code-size \ -DDEBUG -LDFLAGS := -mz80 --no-std-crt0 crt0.rel \ +LDFLAGS := -mz80 --no-std-crt0 build/crt0.rel \ --std-c89 -pedantic \ --code-loc 0x0800 --data-loc 0x8000 @@ -33,21 +32,20 @@ all: $(BINARY) # build binary $(BINARY): $(OBJECTS) dirs $(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE) - @# xxd -r -p $(HEXFILE) $(BINARY) makebin -s 16384 $(HEXFILE) $(BINARY) -$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs crt0.rel +$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs build/crt0.rel @printf "\n" $(CC) $(CFLAGS) -c $< -o $@ -crt0.rel: crt0.s +build/crt0.rel: crt0.s sdasz80 -o $< + @mv crt0.rel build dirs: mkdir -p build build/kernel build/libc build/kernel/drivers dis: $(BINARY) - @# z80dasm -a -l -g 0h $< -o build/$(OSNAME).s dz80 -b -n $< clean: |