summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--doc/report/build/notes.pdfbin47404 -> 47404 bytes
-rw-r--r--doc/report/build/z80uPC.pdfbin970633 -> 971051 bytes
-rw-r--r--doc/report/build/z80uPC_nostyle.pdfbin0 -> 141261 bytes
-rw-r--r--doc/report/makefile2
-rw-r--r--doc/report/res/addrspace.pdfbin7208 -> 7210 bytes
-rw-r--r--doc/report/res/block_diagram.pdfbin23233 -> 23235 bytes
-rw-r--r--doc/report/res/iospace.pdfbin6118 -> 6120 bytes
-rw-r--r--doc/report/res/kernel_mem_base.pdfbin16923 -> 17257 bytes
-rw-r--r--doc/report/res/mem_kern_alloc.pdfbin0 -> 8132 bytes
-rw-r--r--doc/report/z80uPC.tex30
-rw-r--r--doc/report/z80uPC_nostyle.tex163
-rw-r--r--sw/programmer/avr/main.c9
-rw-r--r--sw/programmer/linux/config.h26
-rw-r--r--sw/programmer/linux/src/flash.c15
-rw-r--r--sw/programmer/linux/src/ui.c1
-rwxr-xr-xsw/programmer/linux/src/z80progbin48160 -> 0 bytes
-rw-r--r--sw/z80/build/kernel/filesystem.asm117
-rw-r--r--sw/z80/build/kernel/filesystem.lst117
-rw-r--r--sw/z80/build/kernel/filesystem.rel54
-rw-r--r--sw/z80/build/kernel/filesystem.sym33
-rw-r--r--sw/z80/build/kernel/kernel.asm66
-rw-r--r--sw/z80/build/kernel/kernel.lst66
-rw-r--r--sw/z80/build/kernel/kernel.rel22
-rw-r--r--sw/z80/build/kernel/kernel.sym27
-rw-r--r--sw/z80/build/kernel/memory.asm186
-rw-r--r--sw/z80/build/kernel/memory.lst186
-rw-r--r--sw/z80/build/kernel/memory.rel76
-rw-r--r--sw/z80/build/kernel/memory.sym30
-rw-r--r--sw/z80/build/kernel/process.asm89
-rw-r--r--sw/z80/build/kernel/process.lst89
-rw-r--r--sw/z80/build/kernel/process.rel45
-rw-r--r--sw/z80/build/kernel/process.sym32
-rw-r--r--sw/z80/crt0.rel86
-rw-r--r--sw/z80/kernel/drivers/ctc.c1
-rw-r--r--sw/z80/kernel/drivers/pio.c29
-rw-r--r--sw/z80/kernel/include/drivers/ctc.h6
-rw-r--r--sw/z80/kernel/include/drivers/pio.h20
-rw-r--r--sw/z80/kernel/include/fs/fs.h2
-rw-r--r--sw/z80/kernel/include/memory.h10
-rw-r--r--sw/z80/kernel/include/process.h21
-rw-r--r--sw/z80/kernel/include/syscall.h20
-rw-r--r--sw/z80/kernel/include/types.h42
-rw-r--r--sw/z80/kernel/memory.c32
-rw-r--r--sw/z80/kernel/process.c38
-rw-r--r--sw/z80/libc/string.c20
-rw-r--r--sw/z80/makefile3
-rw-r--r--sw/z80_test/crt0.s103
-rw-r--r--sw/z80_test/ctc.c7
-rw-r--r--sw/z80_test/ctc.h6
-rw-r--r--sw/z80_test/devices.h15
-rw-r--r--sw/z80_test/main.c11
-rw-r--r--sw/z80_test/makefile52
-rw-r--r--sw/z80_test/pio.c40
-rw-r--r--sw/z80_test/pio.h37
-rw-r--r--sw/z80_test/types.h13
-rw-r--r--sw/z80_test/usart.c91
-rw-r--r--sw/z80_test/usart.h155
58 files changed, 886 insertions, 1459 deletions
diff --git a/.gitignore b/.gitignore
index 6ce0290..dcc8a88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,10 @@ sw/**/*.bin
sw/**/*.o
sw/**/*.a
+# sdcc compiler output
+sw/z80/build
+sw/z80_test/build
+
# custom
various/*
diff --git a/doc/report/build/notes.pdf b/doc/report/build/notes.pdf
index 5a43c7d..56e2cd1 100644
--- a/doc/report/build/notes.pdf
+++ b/doc/report/build/notes.pdf
Binary files differ
diff --git a/doc/report/build/z80uPC.pdf b/doc/report/build/z80uPC.pdf
index aff4174..df353cb 100644
--- a/doc/report/build/z80uPC.pdf
+++ b/doc/report/build/z80uPC.pdf
Binary files differ
diff --git a/doc/report/build/z80uPC_nostyle.pdf b/doc/report/build/z80uPC_nostyle.pdf
new file mode 100644
index 0000000..87cdd60
--- /dev/null
+++ b/doc/report/build/z80uPC_nostyle.pdf
Binary files differ
diff --git a/doc/report/makefile b/doc/report/makefile
index e10c0b9..d88b1bb 100644
--- a/doc/report/makefile
+++ b/doc/report/makefile
@@ -2,7 +2,7 @@
BUILD_DIR := build
RES_DIR := res
-SOURCES := z80uPC.tex notes.tex
+SOURCES := z80uPC.tex z80uPC_nostyle.tex notes.tex
DOCUMENTS := $(patsubst %.tex,$(BUILD_DIR)/%.pdf,$(SOURCES))
RES_SRC := $(wildcard $(RES_DIR)/*.svg)
diff --git a/doc/report/res/addrspace.pdf b/doc/report/res/addrspace.pdf
index 96ac657..abf9fed 100644
--- a/doc/report/res/addrspace.pdf
+++ b/doc/report/res/addrspace.pdf
Binary files differ
diff --git a/doc/report/res/block_diagram.pdf b/doc/report/res/block_diagram.pdf
index 204a22e..57b42d6 100644
--- a/doc/report/res/block_diagram.pdf
+++ b/doc/report/res/block_diagram.pdf
Binary files differ
diff --git a/doc/report/res/iospace.pdf b/doc/report/res/iospace.pdf
index c1773fd..ba36d9d 100644
--- a/doc/report/res/iospace.pdf
+++ b/doc/report/res/iospace.pdf
Binary files differ
diff --git a/doc/report/res/kernel_mem_base.pdf b/doc/report/res/kernel_mem_base.pdf
index 875d16e..7d2a257 100644
--- a/doc/report/res/kernel_mem_base.pdf
+++ b/doc/report/res/kernel_mem_base.pdf
Binary files differ
diff --git a/doc/report/res/mem_kern_alloc.pdf b/doc/report/res/mem_kern_alloc.pdf
new file mode 100644
index 0000000..fd02dfd
--- /dev/null
+++ b/doc/report/res/mem_kern_alloc.pdf
Binary files differ
diff --git a/doc/report/z80uPC.tex b/doc/report/z80uPC.tex
index eaad987..50034ec 100644
--- a/doc/report/z80uPC.tex
+++ b/doc/report/z80uPC.tex
@@ -50,25 +50,33 @@
\maketitle
\begin{abstract}
+
Lo Zilog Z80 \`e un processore a 8 bit che fu introdotto nel 1976 che ebbe
un grandissimo successo nel mondo dell'elettronica e dell'informatica
- nella fine del 20esimo secolo. In memoria di questo processore pioniere
- dell'industria di sistemi embedded ho deciso di costruire un computer a
- scopo generico intorno a questa piattaforma. L'obiettivo \`e di realizzare
- una scheda programmabile con tutti i componenti necessari come ROM, RAM e
- timers per far funzionare del software programmato se possibile sul
- dispositivo stesso.
+ nella fine del 20esimo secolo. In memoria di questo pioniere
+ dell'industria dei sistemi informatici questo progetto documenta la
+ realizzazione di un microcomputer a scopo generico a base di esso.
+ L'obiettivo primario dunque \`e di realizzare una scheda simile ad una
+ motherboard dei computers venduti all'epoca completa di RAM, ROMs,
+ interfacce seriali e altri circuiti di supporto. Successivamente per
+ l'aspetto software il progetto deve implementare i drivers per ogni
+ circuito presente sulla scheda in modo da semplificare la programmazione.
+ L'obiettivo opzionale del progetto, una volta terminata la costruzione
+ hardware, \`e di realizzare una kernel monolitica che offre funzioni
+ minimali simili ad un sistema UNIX, quali processi, filesystem, memory
+ management e drivers.
+
\end{abstract}
\section{Specifiche tecniche dello Z80}
Lo Z80 \`e un processore molto minimalistico se paragonato a ci\`o che si
-trova oggi sul mercato dei microcontrollori. Per il mio progetto ho deciso di
-utilizzare il modello originale \texttt{Zilog Z8400} che non dispone di
-sistemi integrati come i modelli SoC odierni. Le specifiche pi\`u importanti
-sono elencate a seguire.
+trova oggi sul mercato dei microcontrollori. Per il progetto \prj la CPU in
+uso \`e il modello originale \texttt{Zilog Z8400} che non dispone di sistemi
+integrati come i modelli SoC odierni. Le specifiche pi\`u importanti sono
+elencate a seguire.
\begin{itemize}
- \item Architettura a 8 bit con bus a 16 bit con 64K indirizzi indirizzabili
+ \item Architettura a 8 bit con bus a 16 bit, 64K indirizzi indirizzabili
\item Registri a 16 bit per {\tt SP,PC} e registri di utilizzo generico a
8 bit {\tt A..F} combinabili a coppie {\tt AF,BC,..} per utilizzare
valori a 16 bit
diff --git a/doc/report/z80uPC_nostyle.tex b/doc/report/z80uPC_nostyle.tex
new file mode 100644
index 0000000..a3421ef
--- /dev/null
+++ b/doc/report/z80uPC_nostyle.tex
@@ -0,0 +1,163 @@
+\documentclass[a4paper, 11pt]{article}
+
+\usepackage{array}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{textgreek}
+\usepackage{graphicx}
+
+% source code
+\usepackage{listings}
+
+% set correct hypenation
+\usepackage[italian]{babel}
+
+% to fix macros
+\usepackage{xspace}
+% commands
+% macro for project name
+\newcommand{\prj}{Z80\textmu PC\xspace}
+
+% invert signal (not, active low)
+\newcommand{\inv}[1]{$\overline{\mbox{#1}}$}
+
+% metadata
+\title{\prj Single Board \\ Computer Development }
+\author{Naoki Pross}
+
+% document
+\begin{document}
+
+\maketitle
+\begin{abstract}
+
+ Lo Zilog Z80 \`e un processore a 8 bit che fu introdotto nel 1976 che ebbe
+ un grandissimo successo nel mondo dell'elettronica e dell'informatica
+ nella fine del 20esimo secolo. In memoria di questo pioniere
+ dell'industria dei sistemi informatici questo progetto documenta la
+ realizzazione di un microcomputer a scopo generico a base di esso.
+ L'obiettivo primario dunque \`e di realizzare una scheda simile ad una
+ motherboard dei computers venduti all'epoca completa di RAM, ROMs,
+ interfacce seriali e altri circuiti di supporto. Successivamente per
+ l'aspetto software il progetto deve implementare i drivers per ogni
+ circuito presente sulla scheda in modo da semplificare la programmazione.
+ L'obiettivo opzionale del progetto, una volta terminata la costruzione
+ hardware, \`e di realizzare una kernel monolitica che offre funzioni
+ minimali simili ad un sistema UNIX, quali processi, filesystem, memory
+ management e drivers.
+
+\end{abstract}
+
+\section{Hardware}
+
+\subsection{Specifiche tecniche dello Z80}
+
+Lo Z80 \`e un processore molto minimalistico se paragonato a ci\`o che si
+trova oggi sul mercato dei microcontrollori. Per il progetto \prj la CPU in
+uso \`e il modello originale \texttt{Zilog Z8400} che non dispone di moduli
+aggiuntivi integrati come i modelli SoC odierni. La scelta di una CPU tanto
+semplice \`e la conseguenza del design didattico del progetto, inoltre senza
+alcun dispositivo interno lo \texttt{Z8400} si presenta con un address space
+completamente vuoto, ad eccezzione del punto d'inizio e i vettori di reset.
+
+Lo Z80 utilizza I/O paralleli sia per la lina a 16 degli indizzi che per la
+linea dati a 8 bit e dispone di 6 registri 8 bit ad utilizzo generico
+combinabili in coppie per ottenere un valore a 16 bit. Per il controllo dei
+dispositivi esterni, come lettura e scrittura esso possiede delle linee di
+controllo dedicate come {\tt\inv{RD}}, {\tt\inv{WR}}, {\tt\inv{MREQ}}, ecc. In
+quanto instruction set, lo Z80 ha 158 istruzioni possibili di cui 78 sono un
+sottoinsieme dello 8080A, architettate per poter mantere una
+retrocompatiblit\`a.
+
+\begin{table}[ht]\centering
+\caption{Riassunto delle specifiche}
+
+\begin{tabular}{ l l }
+ \\ \hline
+ Dimensione Indirizzi & 16 bit \\
+ Dimensione Dati (word) & 8 bit \\
+ Spazio Indirizzabile & 64 KB \\
+ Registri Generici 8 bit & 6 ({\tt A..F}) \\
+ Registri 16 bit & 2 ({\tt SP, PC}) \\
+ Clock speed & 8 MHz, 6MHz, 4MHz, 2.5MHz \\
+ \hline
+\end{tabular}
+\end{table}
+
+\subsection{Componenti e modello di design}
+
+Il minimo necessario per far funzionare uno Z80 sono una {\tt RAM} ed una {\tt
+ROM}, ma avendo a disposizione altri dispositivi I/O lo \prj dispone anche di
+una porta seriale, di una porta parallela e di un counter timer; Hardware che
+si presenta normalmente all'interno di microcontrollori odierni.
+
+\begin{table}[hb]\centering
+\caption{Lista dei componenti}
+\begin{tabular}{ >{\tt}l >{\tt\bfseries}l >{\footnotesize}p{.7\linewidth} }
+ \\ \hline
+ ROM & M28C64 & EEPROM da 8KB x 8 bit (64K) per il BIOS / Bootloader /
+ OS installata doppia per avere 16KB \\
+ RAM & HM62256B & SRAM da 32KB x 8bit (256K) \\
+ CTC & Z8430 & Counter timer circuit ufficiale di Zilog a 4 canali
+ programmabili \\
+ PIO & Z8420 & Parallel input/output controller di Zilog per avere un
+ intefaccia digitale con due porte da 8 bit \\
+ MMU & M4-32/32-15JC & CPLD programmabile che implementa una memory
+ management unit semplificata in grado di gestire i 5
+ bit pi\`u significativi della linea di indirizzi \\
+ USART & TL16C550C & Interfaccia USART per poter comunicare utilizzando il
+ protocollo RS232 \\
+ \hline
+\end{tabular}
+\end{table}
+
+Il design dello \prj \`e costruito sulla falsa riga di un Arduino o di un
+EasyPIC con l'aggiunta di funzionalit\`a a scopo didattico quali; la
+possiblit\`a di cambiare la velocit\`a di clock tra 4MHz, 200Hz o manuale
+(mediante un bottone sulla scheda) e una serie di display a 7 segmenti per
+vedere in tempo reale i valori sui bus degli indirizzi e dei dati.
+\begin{center}
+\begin{tabular}{ >{\bfseries}r p{.8\linewidth} }
+ 0Hz & Il clock manuale \`e un bottone che permette di creare
+ le pulsazioni, per poter analizzare ogni istruzione \\
+ 200Hz & Mediante un classico circuito con un LM555 si ha un clock
+ per eseguire i programmi a velocit\`a rallentata \\
+ 4MHz & Clock per esecuzione a velocit\`a piena (normale)
+\end{tabular}
+\end{center}
+
+\subsection{Memory management unit}
+
+Alcuni modelli sucessori dello Z8400 implementavano ina MMU (Memory Management
+Unit) SoC che permetteva di ampliare la dimensione dell'address space,
+permettendo quindi di mappare pi\`u memorie o dispositivi separati negli
+stessi indirizzi. Ci\`o \`e un sistema \`e comune nei sistemi a base di
+microcontrollers per ovviare al problema dello spazio. Lo \prj per\`o ha un
+architettura pi\`u simile ad un computer X86 in cui la MMU viene utilizzata
+per la gestione delle \emph{pagine} di memoria.
+
+Il concetto di pagine (pages in inglese) \`e necessario per sistemi con un
+supporto per il multitasking o per poter ampliare la memoria dinamica.
+
+\section*{Glossario Tecnico}
+
+\begin{tabular}{ >{\bfseries}p{.3\linewidth} p{.7\linewidth} }
+
+ Address Space & In informatica l'\emph{address space} \`e un intervallo di
+ indirizzi che possono corrispondere a indirizzi in rete, regioni di un
+ dispositivo, di una memoria o di un qualsiasi altro dispositivo fisico o
+ logico. Per questo progetto \emph{address space} si riferisce
+ all'intervallo indirizzabile dal processore, ovvero $2^{16}$ locazioni
+ siccome il sistema dispone di un bus a 16 bit. \\
+
+ Registro & Un registro \`e un dispositivo di memoria in cui \`e possibile
+ pu\`o leggere e/o scrivere un certo valore. Normalmente in un computer /
+ microcontrollore la dimensione della memoria \`e data dall'architettura,
+ dunque 8, 16, 32 o 64 bits. In questo documento viene viene comunemente
+ utilizzato per riferirsi ad una memoria di un dispositivo fisico come la
+ CPU o un IC seriale. \\
+
+
+\end{tabular}
+
+\end{document}
diff --git a/sw/programmer/avr/main.c b/sw/programmer/avr/main.c
index 9cdc35d..4f39100 100644
--- a/sw/programmer/avr/main.c
+++ b/sw/programmer/avr/main.c
@@ -98,16 +98,21 @@ void eeprom_write(uint16_t addr, uint8_t byte)
/* set data */
EEPROMDR = byte;
+
+ // because EEPROMDR0 and EEPROMDR1 are used by Tx and Rx
+ EEPROMCR = (PINC & 0x07) | (byte & 0x03)<<3;
EEPROMCR &= ~(_BV(ADDR_EH) | _BV(ADDR_EL));
/* write eeprom */
EEPROMCR &= ~_BV(EEPROM_WR);
- eeprom_tick();
+
+ // eeprom_tick();
EEPROMCR |= _BV(EEPROM_WR);
EEPROMCR |= _BV(ADDR_EH) | _BV(ADDR_EL);
}
+#if 0
/* pulse the clock line for the eeprom */
void eeprom_tick()
{
@@ -116,4 +121,4 @@ void eeprom_tick()
EEPROMCR &= ~_BV(EEPROM_CLK);
_delay_ms(EEPROM_TICK_MS);
}
-
+#endif \ No newline at end of file
diff --git a/sw/programmer/linux/config.h b/sw/programmer/linux/config.h
deleted file mode 100644
index d319f43..0000000
--- a/sw/programmer/linux/config.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Name of package */
-#define PACKAGE "z80prog"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "naopross@tharcway.org"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "z80prog"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "z80prog 0.1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "z80prog"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.1"
-
-/* Version number of package */
-#define VERSION "0.1"
diff --git a/sw/programmer/linux/src/flash.c b/sw/programmer/linux/src/flash.c
index 48189da..6fcd09f 100644
--- a/sw/programmer/linux/src/flash.c
+++ b/sw/programmer/linux/src/flash.c
@@ -28,19 +28,24 @@ int flash_write(const char *romfile, void (*log)(const char *))
goto exit_romfd;
while ((head.size = read(romfd, buffer, FLASH_BLOCK_SIZE))) {
+ if (head.size < 0) {
+ log("[!] Error while reading from file\n");
+ break;
+ }
+
head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR);
written = write(flash_serial_fd, &head, sizeof(struct flash_blk));
- if (written < 0) {
- // error
+ if (written != sizeof(struct flash_blk)) {
+ log("[!] Some bytes of flash_blk haven't been written\n");
}
written = write(flash_serial_fd, buffer, head.size);
- if (written < 0) {
- // error
+ if (written != head.size) {
+ log("[#] Some bytes might not have been written\n");
}
- char logbuf[64];
+ char logbuf[64];
sprintf(logbuf, "[@] Written %d bytes at address %d\n", head.size, head.addr);
log(logbuf);
}
diff --git a/sw/programmer/linux/src/ui.c b/sw/programmer/linux/src/ui.c
index 87dc0c7..b53ff0b 100644
--- a/sw/programmer/linux/src/ui.c
+++ b/sw/programmer/linux/src/ui.c
@@ -18,6 +18,7 @@ void ui_init(int *argc, char **argv[])
/* connect objects to callbacks */
window = GTK_WINDOW(gtk_builder_get_object(ui_builder, "window"));
+ g_signal_connect(window, "delete_event", G_CALLBACK(flash_close), NULL);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
connectbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "connectbtn"));
diff --git a/sw/programmer/linux/src/z80prog b/sw/programmer/linux/src/z80prog
deleted file mode 100755
index 2f0d230..0000000
--- a/sw/programmer/linux/src/z80prog
+++ /dev/null
Binary files differ
diff --git a/sw/z80/build/kernel/filesystem.asm b/sw/z80/build/kernel/filesystem.asm
deleted file mode 100644
index f868b5a..0000000
--- a/sw/z80/build/kernel/filesystem.asm
+++ /dev/null
@@ -1,117 +0,0 @@
-;--------------------------------------------------------
-; File Created by SDCC : free open source ANSI-C Compiler
-; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
-; This file was generated Wed Aug 23 21:44:59 2017
-;--------------------------------------------------------
- .module filesystem
- .optsdcc -mz80
-
-;--------------------------------------------------------
-; Public variables in this module
-;--------------------------------------------------------
- .globl _fs_parse_superblock
- .globl _fs_parse_path
- .globl _fs_get_inode
- .globl _fs_new_inode
- .globl _fs_free_inode
- .globl _fs_chmod
- .globl _fs_chown
- .globl _fs_rename
-;--------------------------------------------------------
-; special function registers
-;--------------------------------------------------------
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _DATA
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _INITIALIZED
-;--------------------------------------------------------
-; absolute external ram data
-;--------------------------------------------------------
- .area _DABS (ABS)
-;--------------------------------------------------------
-; global & static initialisations
-;--------------------------------------------------------
- .area _HOME
- .area _GSINIT
- .area _GSFINAL
- .area _GSINIT
-;--------------------------------------------------------
-; Home
-;--------------------------------------------------------
- .area _HOME
- .area _HOME
-;--------------------------------------------------------
-; code
-;--------------------------------------------------------
- .area _CODE
-;kernel/filesystem.c:3: struct filesystem * fs_parse_superblock(struct filesystem *fs)
-; ---------------------------------
-; Function fs_parse_superblock
-; ---------------------------------
-_fs_parse_superblock::
-;kernel/filesystem.c:5: return 0;
- ld hl,#0x0000
- ret
-;kernel/filesystem.c:9: uint16_t fs_parse_path(const char *path)
-; ---------------------------------
-; Function fs_parse_path
-; ---------------------------------
-_fs_parse_path::
-;kernel/filesystem.c:11: return 0;
- ld hl,#0x0000
- ld e,l
- ld d,h
- ret
-;kernel/filesystem.c:15: inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number)
-; ---------------------------------
-; Function fs_get_inode
-; ---------------------------------
-_fs_get_inode::
-;kernel/filesystem.c:17: return 0;
- ld hl,#0x0000
- ret
-;kernel/filesystem.c:20: inode_t * fs_new_inode(inode_t *inode, const char *name)
-; ---------------------------------
-; Function fs_new_inode
-; ---------------------------------
-_fs_new_inode::
-;kernel/filesystem.c:22: return 0;
- ld hl,#0x0000
- ret
-;kernel/filesystem.c:25: int fs_free_inode(const inode_t *inode)
-; ---------------------------------
-; Function fs_free_inode
-; ---------------------------------
-_fs_free_inode::
-;kernel/filesystem.c:27: return 0;
- ld hl,#0x0000
- ret
-;kernel/filesystem.c:30: void fs_chmod(inode_t *inode, uint8_t mode)
-; ---------------------------------
-; Function fs_chmod
-; ---------------------------------
-_fs_chmod::
-;kernel/filesystem.c:32: }
- ret
-;kernel/filesystem.c:34: void fs_chown(inode_t *inode, uint8_t uid)
-; ---------------------------------
-; Function fs_chown
-; ---------------------------------
-_fs_chown::
-;kernel/filesystem.c:37: }
- ret
-;kernel/filesystem.c:39: int fs_rename(inode_t *inode, const char *name)
-; ---------------------------------
-; Function fs_rename
-; ---------------------------------
-_fs_rename::
-;kernel/filesystem.c:41: return 0;
- ld hl,#0x0000
- ret
- .area _CODE
- .area _INITIALIZER
- .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/filesystem.lst b/sw/z80/build/kernel/filesystem.lst
deleted file mode 100644
index 80ecda7..0000000
--- a/sw/z80/build/kernel/filesystem.lst
+++ /dev/null
@@ -1,117 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
- 4 ; This file was generated Wed Aug 23 21:44:59 2017
- 5 ;--------------------------------------------------------
- 6 .module filesystem
- 7 .optsdcc -mz80
- 8
- 9 ;--------------------------------------------------------
- 10 ; Public variables in this module
- 11 ;--------------------------------------------------------
- 12 .globl _fs_parse_superblock
- 13 .globl _fs_parse_path
- 14 .globl _fs_get_inode
- 15 .globl _fs_new_inode
- 16 .globl _fs_free_inode
- 17 .globl _fs_chmod
- 18 .globl _fs_chown
- 19 .globl _fs_rename
- 20 ;--------------------------------------------------------
- 21 ; special function registers
- 22 ;--------------------------------------------------------
- 23 ;--------------------------------------------------------
- 24 ; ram data
- 25 ;--------------------------------------------------------
- 26 .area _DATA
- 27 ;--------------------------------------------------------
- 28 ; ram data
- 29 ;--------------------------------------------------------
- 30 .area _INITIALIZED
- 31 ;--------------------------------------------------------
- 32 ; absolute external ram data
- 33 ;--------------------------------------------------------
- 34 .area _DABS (ABS)
- 35 ;--------------------------------------------------------
- 36 ; global & static initialisations
- 37 ;--------------------------------------------------------
- 38 .area _HOME
- 39 .area _GSINIT
- 40 .area _GSFINAL
- 41 .area _GSINIT
- 42 ;--------------------------------------------------------
- 43 ; Home
- 44 ;--------------------------------------------------------
- 45 .area _HOME
- 46 .area _HOME
- 47 ;--------------------------------------------------------
- 48 ; code
- 49 ;--------------------------------------------------------
- 50 .area _CODE
- 51 ;kernel/filesystem.c:3: struct filesystem * fs_parse_superblock(struct filesystem *fs)
- 52 ; ---------------------------------
- 53 ; Function fs_parse_superblock
- 54 ; ---------------------------------
- 0000 55 _fs_parse_superblock::
- 56 ;kernel/filesystem.c:5: return 0;
- 0000 21 00 00 [10] 57 ld hl,#0x0000
- 0003 C9 [10] 58 ret
- 59 ;kernel/filesystem.c:9: uint16_t fs_parse_path(const char *path)
- 60 ; ---------------------------------
- 61 ; Function fs_parse_path
- 62 ; ---------------------------------
- 0004 63 _fs_parse_path::
- 64 ;kernel/filesystem.c:11: return 0;
- 0004 21 00 00 [10] 65 ld hl,#0x0000
- 0007 5D [ 4] 66 ld e,l
- 0008 54 [ 4] 67 ld d,h
- 0009 C9 [10] 68 ret
- 69 ;kernel/filesystem.c:15: inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number)
- 70 ; ---------------------------------
- 71 ; Function fs_get_inode
- 72 ; ---------------------------------
- 000A 73 _fs_get_inode::
- 74 ;kernel/filesystem.c:17: return 0;
- 000A 21 00 00 [10] 75 ld hl,#0x0000
- 000D C9 [10] 76 ret
- 77 ;kernel/filesystem.c:20: inode_t * fs_new_inode(inode_t *inode, const char *name)
- 78 ; ---------------------------------
- 79 ; Function fs_new_inode
- 80 ; ---------------------------------
- 000E 81 _fs_new_inode::
- 82 ;kernel/filesystem.c:22: return 0;
- 000E 21 00 00 [10] 83 ld hl,#0x0000
- 0011 C9 [10] 84 ret
- 85 ;kernel/filesystem.c:25: int fs_free_inode(const inode_t *inode)
- 86 ; ---------------------------------
- 87 ; Function fs_free_inode
- 88 ; ---------------------------------
- 0012 89 _fs_free_inode::
- 90 ;kernel/filesystem.c:27: return 0;
- 0012 21 00 00 [10] 91 ld hl,#0x0000
- 0015 C9 [10] 92 ret
- 93 ;kernel/filesystem.c:30: void fs_chmod(inode_t *inode, uint8_t mode)
- 94 ; ---------------------------------
- 95 ; Function fs_chmod
- 96 ; ---------------------------------
- 0016 97 _fs_chmod::
- 98 ;kernel/filesystem.c:32: }
- 0016 C9 [10] 99 ret
- 100 ;kernel/filesystem.c:34: void fs_chown(inode_t *inode, uint8_t uid)
- 101 ; ---------------------------------
- 102 ; Function fs_chown
- 103 ; ---------------------------------
- 0017 104 _fs_chown::
- 105 ;kernel/filesystem.c:37: }
- 0017 C9 [10] 106 ret
- 107 ;kernel/filesystem.c:39: int fs_rename(inode_t *inode, const char *name)
- 108 ; ---------------------------------
- 109 ; Function fs_rename
- 110 ; ---------------------------------
- 0018 111 _fs_rename::
- 112 ;kernel/filesystem.c:41: return 0;
- 0018 21 00 00 [10] 113 ld hl,#0x0000
- 001B C9 [10] 114 ret
- 115 .area _CODE
- 116 .area _INITIALIZER
- 117 .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/filesystem.rel b/sw/z80/build/kernel/filesystem.rel
deleted file mode 100644
index 3ccb28f..0000000
--- a/sw/z80/build/kernel/filesystem.rel
+++ /dev/null
@@ -1,54 +0,0 @@
-XL2
-H 9 areas 9 global symbols
-M filesystem
-O -mz80
-S .__.ABS. Def0000
-A _CODE size 1C flags 0 addr 0
-S _fs_get_inode Def000A
-S _fs_parse_superblock Def0000
-S _fs_rename Def0018
-S _fs_new_inode Def000E
-S _fs_chmod Def0016
-S _fs_free_inode Def0012
-S _fs_chown Def0017
-S _fs_parse_path Def0004
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 0 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 00 00
-T 00 00 21 00 00 C9
-R 00 00 00 00
-T 04 00
-R 00 00 00 00
-T 04 00 21 00 00 5D 54 C9
-R 00 00 00 00
-T 0A 00
-R 00 00 00 00
-T 0A 00 21 00 00 C9
-R 00 00 00 00
-T 0E 00
-R 00 00 00 00
-T 0E 00 21 00 00 C9
-R 00 00 00 00
-T 12 00
-R 00 00 00 00
-T 12 00 21 00 00 C9
-R 00 00 00 00
-T 16 00
-R 00 00 00 00
-T 16 00 C9
-R 00 00 00 00
-T 17 00
-R 00 00 00 00
-T 17 00 C9
-R 00 00 00 00
-T 18 00
-R 00 00 00 00
-T 18 00 21 00 00 C9
-R 00 00 00 00
diff --git a/sw/z80/build/kernel/filesystem.sym b/sw/z80/build/kernel/filesystem.sym
deleted file mode 100644
index 6e95911..0000000
--- a/sw/z80/build/kernel/filesystem.sym
+++ /dev/null
@@ -1,33 +0,0 @@
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1.
-Hexadecimal [16-Bits]
-
-Symbol Table
-
- .__.$$$. = 2710 L
- .__.ABS. = 0000 G
- .__.CPU. = 0000 L
- .__.H$L. = 0000 L
- 0 _fs_chmod 0016 GR
- 0 _fs_chown 0017 GR
- 0 _fs_free_inode 0012 GR
- 0 _fs_get_inode 000A GR
- 0 _fs_new_inode 000E GR
- 0 _fs_parse_path 0004 GR
- 0 _fs_parse_superblock 0000 GR
- 0 _fs_rename 0018 GR
-
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
-Hexadecimal [16-Bits]
-
-Area Table
-
- 0 _CODE size 1C flags 0
- 1 _DATA size 0 flags 0
- 2 _INITIALIZED size 0 flags 0
- 3 _DABS size 0 flags 8
- 4 _HOME size 0 flags 0
- 5 _GSINIT size 0 flags 0
- 6 _GSFINAL size 0 flags 0
- 7 _INITIALIZER size 0 flags 0
- 8 _CABS size 0 flags 8
-
diff --git a/sw/z80/build/kernel/kernel.asm b/sw/z80/build/kernel/kernel.asm
deleted file mode 100644
index e0839fc..0000000
--- a/sw/z80/build/kernel/kernel.asm
+++ /dev/null
@@ -1,66 +0,0 @@
-;--------------------------------------------------------
-; File Created by SDCC : free open source ANSI-C Compiler
-; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
-; This file was generated Wed Aug 23 21:44:59 2017
-;--------------------------------------------------------
- .module kernel
- .optsdcc -mz80
-
-;--------------------------------------------------------
-; Public variables in this module
-;--------------------------------------------------------
- .globl _kmain
- .globl _usart_init
-;--------------------------------------------------------
-; special function registers
-;--------------------------------------------------------
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _DATA
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _INITIALIZED
-;--------------------------------------------------------
-; absolute external ram data
-;--------------------------------------------------------
- .area _DABS (ABS)
-;--------------------------------------------------------
-; global & static initialisations
-;--------------------------------------------------------
- .area _HOME
- .area _GSINIT
- .area _GSFINAL
- .area _GSINIT
-;--------------------------------------------------------
-; Home
-;--------------------------------------------------------
- .area _HOME
- .area _HOME
-;--------------------------------------------------------
-; code
-;--------------------------------------------------------
- .area _CODE
-;kernel/kernel.c:4: void kmain(void)
-; ---------------------------------
-; Function kmain
-; ---------------------------------
-_kmain::
-;kernel/kernel.c:6: usart_init(USART_BAUDRATE_9600, USART_PARITY_EVEN, USART_STOP_BITS_1);
- ld hl,#0x000A
- push hl
- ld l, #0x01
- push hl
- ld hl,#0x0000
- push hl
- ld hl,#0x000C
- push hl
- call _usart_init
- ld hl,#8
- add hl,sp
- ld sp,hl
- ret
- .area _CODE
- .area _INITIALIZER
- .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/kernel.lst b/sw/z80/build/kernel/kernel.lst
deleted file mode 100644
index e839f83..0000000
--- a/sw/z80/build/kernel/kernel.lst
+++ /dev/null
@@ -1,66 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
- 4 ; This file was generated Wed Aug 23 21:44:59 2017
- 5 ;--------------------------------------------------------
- 6 .module kernel
- 7 .optsdcc -mz80
- 8
- 9 ;--------------------------------------------------------
- 10 ; Public variables in this module
- 11 ;--------------------------------------------------------
- 12 .globl _kmain
- 13 .globl _usart_init
- 14 ;--------------------------------------------------------
- 15 ; special function registers
- 16 ;--------------------------------------------------------
- 17 ;--------------------------------------------------------
- 18 ; ram data
- 19 ;--------------------------------------------------------
- 20 .area _DATA
- 21 ;--------------------------------------------------------
- 22 ; ram data
- 23 ;--------------------------------------------------------
- 24 .area _INITIALIZED
- 25 ;--------------------------------------------------------
- 26 ; absolute external ram data
- 27 ;--------------------------------------------------------
- 28 .area _DABS (ABS)
- 29 ;--------------------------------------------------------
- 30 ; global & static initialisations
- 31 ;--------------------------------------------------------
- 32 .area _HOME
- 33 .area _GSINIT
- 34 .area _GSFINAL
- 35 .area _GSINIT
- 36 ;--------------------------------------------------------
- 37 ; Home
- 38 ;--------------------------------------------------------
- 39 .area _HOME
- 40 .area _HOME
- 41 ;--------------------------------------------------------
- 42 ; code
- 43 ;--------------------------------------------------------
- 44 .area _CODE
- 45 ;kernel/kernel.c:4: void kmain(void)
- 46 ; ---------------------------------
- 47 ; Function kmain
- 48 ; ---------------------------------
- 0000 49 _kmain::
- 50 ;kernel/kernel.c:6: usart_init(USART_BAUDRATE_9600, USART_PARITY_EVEN, USART_STOP_BITS_1);
- 0000 21 0A 00 [10] 51 ld hl,#0x000A
- 0003 E5 [11] 52 push hl
- 0004 2E 01 [ 7] 53 ld l, #0x01
- 0006 E5 [11] 54 push hl
- 0007 21 00 00 [10] 55 ld hl,#0x0000
- 000A E5 [11] 56 push hl
- 000B 21 0C 00 [10] 57 ld hl,#0x000C
- 000E E5 [11] 58 push hl
- 000F CDr00r00 [17] 59 call _usart_init
- 0012 21 08 00 [10] 60 ld hl,#8
- 0015 39 [11] 61 add hl,sp
- 0016 F9 [ 6] 62 ld sp,hl
- 0017 C9 [10] 63 ret
- 64 .area _CODE
- 65 .area _INITIALIZER
- 66 .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/kernel.rel b/sw/z80/build/kernel/kernel.rel
deleted file mode 100644
index 103d026..0000000
--- a/sw/z80/build/kernel/kernel.rel
+++ /dev/null
@@ -1,22 +0,0 @@
-XL2
-H 9 areas 3 global symbols
-M kernel
-O -mz80
-S .__.ABS. Def0000
-S _usart_init Ref0000
-A _CODE size 18 flags 0 addr 0
-S _kmain Def0000
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 0 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 00 00
-T 00 00 21 0A 00 E5 2E 01 E5 21 00 00 E5 21 0C 00
-R 00 00 00 00
-T 0E 00 E5 CD 00 00 21 08 00 39 F9 C9
-R 00 00 00 00 02 04 01 00
diff --git a/sw/z80/build/kernel/kernel.sym b/sw/z80/build/kernel/kernel.sym
deleted file mode 100644
index b5145d5..0000000
--- a/sw/z80/build/kernel/kernel.sym
+++ /dev/null
@@ -1,27 +0,0 @@
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1.
-Hexadecimal [16-Bits]
-
-Symbol Table
-
- .__.$$$. = 2710 L
- .__.ABS. = 0000 G
- .__.CPU. = 0000 L
- .__.H$L. = 0000 L
- 0 _kmain 0000 GR
- _usart_init **** GX
-
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
-Hexadecimal [16-Bits]
-
-Area Table
-
- 0 _CODE size 18 flags 0
- 1 _DATA size 0 flags 0
- 2 _INITIALIZED size 0 flags 0
- 3 _DABS size 0 flags 8
- 4 _HOME size 0 flags 0
- 5 _GSINIT size 0 flags 0
- 6 _GSFINAL size 0 flags 0
- 7 _INITIALIZER size 0 flags 0
- 8 _CABS size 0 flags 8
-
diff --git a/sw/z80/build/kernel/memory.asm b/sw/z80/build/kernel/memory.asm
deleted file mode 100644
index ffa5214..0000000
--- a/sw/z80/build/kernel/memory.asm
+++ /dev/null
@@ -1,186 +0,0 @@
-;--------------------------------------------------------
-; File Created by SDCC : free open source ANSI-C Compiler
-; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
-; This file was generated Wed Aug 23 21:44:59 2017
-;--------------------------------------------------------
- .module memory
- .optsdcc -mz80
-
-;--------------------------------------------------------
-; Public variables in this module
-;--------------------------------------------------------
- .globl _pages_table
- .globl _mmu_write_table
- .globl _page_map
- .globl _page_unmap
-;--------------------------------------------------------
-; special function registers
-;--------------------------------------------------------
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _DATA
-_pages_table::
- .ds 192
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _INITIALIZED
-;--------------------------------------------------------
-; absolute external ram data
-;--------------------------------------------------------
- .area _DABS (ABS)
-;--------------------------------------------------------
-; global & static initialisations
-;--------------------------------------------------------
- .area _HOME
- .area _GSINIT
- .area _GSFINAL
- .area _GSINIT
-;--------------------------------------------------------
-; Home
-;--------------------------------------------------------
- .area _HOME
- .area _HOME
-;--------------------------------------------------------
-; code
-;--------------------------------------------------------
- .area _CODE
-;kernel/memory.c:5: int mmu_write_table(void)
-; ---------------------------------
-; Function mmu_write_table
-; ---------------------------------
-_mmu_write_table::
-;kernel/memory.c:9: for (i = 0; i < PAGES_MAX_COUNT; i++) {
- ld hl,#0x0000
-00102$:
- inc hl
- ld a,l
- sub a, #0x20
- ld a,h
- rla
- ccf
- rra
- sbc a, #0x80
- jr C,00102$
-;kernel/memory.c:15: return 0;
- ld hl,#0x0000
- ret
-;kernel/memory.c:18: int page_map(int page, int pid, uint16_t addr)
-; ---------------------------------
-; Function page_map
-; ---------------------------------
-_page_map::
- push ix
- ld ix,#0
- add ix,sp
-;kernel/memory.c:20: if (page >= PAGES_MAX_COUNT)
- ld a,4 (ix)
- sub a, #0x20
- ld a,5 (ix)
- rla
- ccf
- rra
- sbc a, #0x80
- jr C,00102$
-;kernel/memory.c:21: return -1;
- ld hl,#0xFFFF
- jr 00105$
-00102$:
-;kernel/memory.c:23: if (pages_table[page].used)
- ld de,#_pages_table+0
- ld c,4 (ix)
- ld b,5 (ix)
- ld l, c
- ld h, b
- add hl, hl
- add hl, bc
- add hl, hl
- add hl,de
- ld c,l
- ld b,h
- ld a,(hl)
- and a,#0x01
- jr Z,00104$
-;kernel/memory.c:24: return -2;
- ld hl,#0xFFFE
- jr 00105$
-00104$:
-;kernel/memory.c:26: pages_table[page].addr = addr;
- ld e, c
- ld d, b
- inc de
- inc de
- push bc
- ld hl, #0x000A
- add hl, sp
- ld bc, #0x0004
- ldir
- pop bc
-;kernel/memory.c:27: pages_table[page].pid = pid;
- ld l, c
- ld h, b
- inc hl
- ld a,6 (ix)
- ld (hl),a
-;kernel/memory.c:29: pages_table[page].used = 1;
- ld a,(bc)
- or a,#0x01
- ld (bc),a
-;kernel/memory.c:30: return 0;
- ld hl,#0x0000
-00105$:
- pop ix
- ret
-;kernel/memory.c:33: int page_unmap(int page)
-; ---------------------------------
-; Function page_unmap
-; ---------------------------------
-_page_unmap::
- push ix
- ld ix,#0
- add ix,sp
-;kernel/memory.c:35: if (page >= PAGES_MAX_COUNT)
- ld a,4 (ix)
- sub a, #0x20
- ld a,5 (ix)
- rla
- ccf
- rra
- sbc a, #0x80
- jr C,00102$
-;kernel/memory.c:36: return -1;
- ld hl,#0xFFFF
- jr 00105$
-00102$:
-;kernel/memory.c:38: if (pages_table[page].used == 0)
- ld de,#_pages_table+0
- ld c,4 (ix)
- ld b,5 (ix)
- ld l, c
- ld h, b
- add hl, hl
- add hl, bc
- add hl, hl
- add hl,de
- ld e,l
- ld d,h
- ld a,(hl)
- and a,#0x01
- jr NZ,00104$
-;kernel/memory.c:39: return -2;
- ld hl,#0xFFFE
- jr 00105$
-00104$:
-;kernel/memory.c:41: pages_table[page].used = 0;
- ld a,(de)
- and a,#0xFE
- ld (de),a
-;kernel/memory.c:42: return 0;
- ld hl,#0x0000
-00105$:
- pop ix
- ret
- .area _CODE
- .area _INITIALIZER
- .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/memory.lst b/sw/z80/build/kernel/memory.lst
deleted file mode 100644
index 5f229f5..0000000
--- a/sw/z80/build/kernel/memory.lst
+++ /dev/null
@@ -1,186 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
- 4 ; This file was generated Wed Aug 23 21:44:59 2017
- 5 ;--------------------------------------------------------
- 6 .module memory
- 7 .optsdcc -mz80
- 8
- 9 ;--------------------------------------------------------
- 10 ; Public variables in this module
- 11 ;--------------------------------------------------------
- 12 .globl _pages_table
- 13 .globl _mmu_write_table
- 14 .globl _page_map
- 15 .globl _page_unmap
- 16 ;--------------------------------------------------------
- 17 ; special function registers
- 18 ;--------------------------------------------------------
- 19 ;--------------------------------------------------------
- 20 ; ram data
- 21 ;--------------------------------------------------------
- 22 .area _DATA
- 0000 23 _pages_table::
- 0000 24 .ds 192
- 25 ;--------------------------------------------------------
- 26 ; ram data
- 27 ;--------------------------------------------------------
- 28 .area _INITIALIZED
- 29 ;--------------------------------------------------------
- 30 ; absolute external ram data
- 31 ;--------------------------------------------------------
- 32 .area _DABS (ABS)
- 33 ;--------------------------------------------------------
- 34 ; global & static initialisations
- 35 ;--------------------------------------------------------
- 36 .area _HOME
- 37 .area _GSINIT
- 38 .area _GSFINAL
- 39 .area _GSINIT
- 40 ;--------------------------------------------------------
- 41 ; Home
- 42 ;--------------------------------------------------------
- 43 .area _HOME
- 44 .area _HOME
- 45 ;--------------------------------------------------------
- 46 ; code
- 47 ;--------------------------------------------------------
- 48 .area _CODE
- 49 ;kernel/memory.c:5: int mmu_write_table(void)
- 50 ; ---------------------------------
- 51 ; Function mmu_write_table
- 52 ; ---------------------------------
- 0000 53 _mmu_write_table::
- 54 ;kernel/memory.c:9: for (i = 0; i < PAGES_MAX_COUNT; i++) {
- 0000 21 00 00 [10] 55 ld hl,#0x0000
- 0003 56 00102$:
- 0003 23 [ 6] 57 inc hl
- 0004 7D [ 4] 58 ld a,l
- 0005 D6 20 [ 7] 59 sub a, #0x20
- 0007 7C [ 4] 60 ld a,h
- 0008 17 [ 4] 61 rla
- 0009 3F [ 4] 62 ccf
- 000A 1F [ 4] 63 rra
- 000B DE 80 [ 7] 64 sbc a, #0x80
- 000D 38 F4 [12] 65 jr C,00102$
- 66 ;kernel/memory.c:15: return 0;
- 000F 21 00 00 [10] 67 ld hl,#0x0000
- 0012 C9 [10] 68 ret
- 69 ;kernel/memory.c:18: int page_map(int page, int pid, uint16_t addr)
- 70 ; ---------------------------------
- 71 ; Function page_map
- 72 ; ---------------------------------
- 0013 73 _page_map::
- 0013 DD E5 [15] 74 push ix
- 0015 DD 21 00 00 [14] 75 ld ix,#0
- 0019 DD 39 [15] 76 add ix,sp
- 77 ;kernel/memory.c:20: if (page >= PAGES_MAX_COUNT)
- 001B DD 7E 04 [19] 78 ld a,4 (ix)
- 001E D6 20 [ 7] 79 sub a, #0x20
- 0020 DD 7E 05 [19] 80 ld a,5 (ix)
- 0023 17 [ 4] 81 rla
- 0024 3F [ 4] 82 ccf
- 0025 1F [ 4] 83 rra
- 0026 DE 80 [ 7] 84 sbc a, #0x80
- 0028 38 05 [12] 85 jr C,00102$
- 86 ;kernel/memory.c:21: return -1;
- 002A 21 FF FF [10] 87 ld hl,#0xFFFF
- 002D 18 38 [12] 88 jr 00105$
- 002F 89 00102$:
- 90 ;kernel/memory.c:23: if (pages_table[page].used)
- 002F 11r00r00 [10] 91 ld de,#_pages_table+0
- 0032 DD 4E 04 [19] 92 ld c,4 (ix)
- 0035 DD 46 05 [19] 93 ld b,5 (ix)
- 0038 69 [ 4] 94 ld l, c
- 0039 60 [ 4] 95 ld h, b
- 003A 29 [11] 96 add hl, hl
- 003B 09 [11] 97 add hl, bc
- 003C 29 [11] 98 add hl, hl
- 003D 19 [11] 99 add hl,de
- 003E 4D [ 4] 100 ld c,l
- 003F 44 [ 4] 101 ld b,h
- 0040 7E [ 7] 102 ld a,(hl)
- 0041 E6 01 [ 7] 103 and a,#0x01
- 0043 28 05 [12] 104 jr Z,00104$
- 105 ;kernel/memory.c:24: return -2;
- 0045 21 FE FF [10] 106 ld hl,#0xFFFE
- 0048 18 1D [12] 107 jr 00105$
- 004A 108 00104$:
- 109 ;kernel/memory.c:26: pages_table[page].addr = addr;
- 004A 59 [ 4] 110 ld e, c
- 004B 50 [ 4] 111 ld d, b
- 004C 13 [ 6] 112 inc de
- 004D 13 [ 6] 113 inc de
- 004E C5 [11] 114 push bc
- 004F 21 0A 00 [10] 115 ld hl, #0x000A
- 0052 39 [11] 116 add hl, sp
- 0053 01 04 00 [10] 117 ld bc, #0x0004
- 0056 ED B0 [21] 118 ldir
- 0058 C1 [10] 119 pop bc
- 120 ;kernel/memory.c:27: pages_table[page].pid = pid;
- 0059 69 [ 4] 121 ld l, c
- 005A 60 [ 4] 122 ld h, b
- 005B 23 [ 6] 123 inc hl
- 005C DD 7E 06 [19] 124 ld a,6 (ix)
- 005F 77 [ 7] 125 ld (hl),a
- 126 ;kernel/memory.c:29: pages_table[page].used = 1;
- 0060 0A [ 7] 127 ld a,(bc)
- 0061 F6 01 [ 7] 128 or a,#0x01
- 0063 02 [ 7] 129 ld (bc),a
- 130 ;kernel/memory.c:30: return 0;
- 0064 21 00 00 [10] 131 ld hl,#0x0000
- 0067 132 00105$:
- 0067 DD E1 [14] 133 pop ix
- 0069 C9 [10] 134 ret
- 135 ;kernel/memory.c:33: int page_unmap(int page)
- 136 ; ---------------------------------
- 137 ; Function page_unmap
- 138 ; ---------------------------------
- 006A 139 _page_unmap::
- 006A DD E5 [15] 140 push ix
- 006C DD 21 00 00 [14] 141 ld ix,#0
- 0070 DD 39 [15] 142 add ix,sp
- 143 ;kernel/memory.c:35: if (page >= PAGES_MAX_COUNT)
- 0072 DD 7E 04 [19] 144 ld a,4 (ix)
- 0075 D6 20 [ 7] 145 sub a, #0x20
- 0077 DD 7E 05 [19] 146 ld a,5 (ix)
- 007A 17 [ 4] 147 rla
- 007B 3F [ 4] 148 ccf
- 007C 1F [ 4] 149 rra
- 007D DE 80 [ 7] 150 sbc a, #0x80
- 007F 38 05 [12] 151 jr C,00102$
- 152 ;kernel/memory.c:36: return -1;
- 0081 21 FF FF [10] 153 ld hl,#0xFFFF
- 0084 18 22 [12] 154 jr 00105$
- 0086 155 00102$:
- 156 ;kernel/memory.c:38: if (pages_table[page].used == 0)
- 0086 11r00r00 [10] 157 ld de,#_pages_table+0
- 0089 DD 4E 04 [19] 158 ld c,4 (ix)
- 008C DD 46 05 [19] 159 ld b,5 (ix)
- 008F 69 [ 4] 160 ld l, c
- 0090 60 [ 4] 161 ld h, b
- 0091 29 [11] 162 add hl, hl
- 0092 09 [11] 163 add hl, bc
- 0093 29 [11] 164 add hl, hl
- 0094 19 [11] 165 add hl,de
- 0095 5D [ 4] 166 ld e,l
- 0096 54 [ 4] 167 ld d,h
- 0097 7E [ 7] 168 ld a,(hl)
- 0098 E6 01 [ 7] 169 and a,#0x01
- 009A 20 05 [12] 170 jr NZ,00104$
- 171 ;kernel/memory.c:39: return -2;
- 009C 21 FE FF [10] 172 ld hl,#0xFFFE
- 009F 18 07 [12] 173 jr 00105$
- 00A1 174 00104$:
- 175 ;kernel/memory.c:41: pages_table[page].used = 0;
- 00A1 1A [ 7] 176 ld a,(de)
- 00A2 E6 FE [ 7] 177 and a,#0xFE
- 00A4 12 [ 7] 178 ld (de),a
- 179 ;kernel/memory.c:42: return 0;
- 00A5 21 00 00 [10] 180 ld hl,#0x0000
- 00A8 181 00105$:
- 00A8 DD E1 [14] 182 pop ix
- 00AA C9 [10] 183 ret
- 184 .area _CODE
- 185 .area _INITIALIZER
- 186 .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/memory.rel b/sw/z80/build/kernel/memory.rel
deleted file mode 100644
index a0cbbca..0000000
--- a/sw/z80/build/kernel/memory.rel
+++ /dev/null
@@ -1,76 +0,0 @@
-XL2
-H 9 areas 5 global symbols
-M memory
-O -mz80
-S .__.ABS. Def0000
-A _CODE size AB flags 0 addr 0
-S _page_map Def0013
-S _mmu_write_table Def0000
-S _page_unmap Def006A
-A _DATA size C0 flags 0 addr 0
-S _pages_table Def0000
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 0 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 01 00
-T 00 00
-R 00 00 01 00
-T 00 00
-R 00 00 00 00
-T 00 00 21 00 00
-R 00 00 00 00
-T 03 00
-R 00 00 00 00
-T 03 00 23 7D D6 20 7C 17 3F 1F DE 80 38 F4 21
-R 00 00 00 00
-T 10 00 00 00 C9
-R 00 00 00 00
-T 13 00
-R 00 00 00 00
-T 13 00 DD E5 DD 21 00 00 DD 39 DD 7E 04 D6 20 DD
-R 00 00 00 00
-T 21 00 7E 05 17 3F 1F DE 80 38 05 21 FF FF 18 38
-R 00 00 00 00
-T 2F 00
-R 00 00 00 00
-T 2F 00 11 00 00 DD 4E 04 DD 46 05 69 60 29 09 29
-R 00 00 00 00 00 03 01 00
-T 3D 00 19 4D 44 7E E6 01 28 05 21 FE FF 18 1D
-R 00 00 00 00
-T 4A 00
-R 00 00 00 00
-T 4A 00 59 50 13 13 C5 21 0A 00 39 01 04 00 ED B0
-R 00 00 00 00
-T 58 00 C1 69 60 23 DD 7E 06 77 0A F6 01 02 21
-R 00 00 00 00
-T 65 00 00 00
-R 00 00 00 00
-T 67 00
-R 00 00 00 00
-T 67 00 DD E1 C9
-R 00 00 00 00
-T 6A 00
-R 00 00 00 00
-T 6A 00 DD E5 DD 21 00 00 DD 39 DD 7E 04 D6 20 DD
-R 00 00 00 00
-T 78 00 7E 05 17 3F 1F DE 80 38 05 21 FF FF 18 22
-R 00 00 00 00
-T 86 00
-R 00 00 00 00
-T 86 00 11 00 00 DD 4E 04 DD 46 05 69 60 29 09 29
-R 00 00 00 00 00 03 01 00
-T 94 00 19 5D 54 7E E6 01 20 05 21 FE FF 18 07
-R 00 00 00 00
-T A1 00
-R 00 00 00 00
-T A1 00 1A E6 FE 12 21 00 00
-R 00 00 00 00
-T A8 00
-R 00 00 00 00
-T A8 00 DD E1 C9
-R 00 00 00 00
diff --git a/sw/z80/build/kernel/memory.sym b/sw/z80/build/kernel/memory.sym
deleted file mode 100644
index 26090e8..0000000
--- a/sw/z80/build/kernel/memory.sym
+++ /dev/null
@@ -1,30 +0,0 @@
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1.
-Hexadecimal [16-Bits]
-
-Symbol Table
-
- .__.$$$. = 2710 L
- .__.ABS. = 0000 G
- .__.CPU. = 0000 L
- .__.H$L. = 0000 L
- 0 _mmu_write_table 0000 GR
- 0 _page_map 0013 GR
- 0 _page_unmap 006A GR
- 1 _pages_table 0000 GR
-
-
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
-Hexadecimal [16-Bits]
-
-Area Table
-
- 0 _CODE size AB flags 0
- 1 _DATA size C0 flags 0
- 2 _INITIALIZED size 0 flags 0
- 3 _DABS size 0 flags 8
- 4 _HOME size 0 flags 0
- 5 _GSINIT size 0 flags 0
- 6 _GSFINAL size 0 flags 0
- 7 _INITIALIZER size 0 flags 0
- 8 _CABS size 0 flags 8
-
diff --git a/sw/z80/build/kernel/process.asm b/sw/z80/build/kernel/process.asm
deleted file mode 100644
index f50bb3d..0000000
--- a/sw/z80/build/kernel/process.asm
+++ /dev/null
@@ -1,89 +0,0 @@
-;--------------------------------------------------------
-; File Created by SDCC : free open source ANSI-C Compiler
-; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
-; This file was generated Wed Aug 23 21:44:59 2017
-;--------------------------------------------------------
- .module process
- .optsdcc -mz80
-
-;--------------------------------------------------------
-; Public variables in this module
-;--------------------------------------------------------
- .globl _proc_table
- .globl _newpid
- .globl _fork
- .globl _exec
- .globl _spawn
-;--------------------------------------------------------
-; special function registers
-;--------------------------------------------------------
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _DATA
-_proc_table::
- .ds 6375
-_newpid_last_pid_1_11:
- .ds 1
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _INITIALIZED
-;--------------------------------------------------------
-; absolute external ram data
-;--------------------------------------------------------
- .area _DABS (ABS)
-;--------------------------------------------------------
-; global & static initialisations
-;--------------------------------------------------------
- .area _HOME
- .area _GSINIT
- .area _GSFINAL
- .area _GSINIT
-;kernel/process.c:7: static pid_t last_pid = 0;
- ld iy,#_newpid_last_pid_1_11
- ld 0 (iy),#0x00
-;--------------------------------------------------------
-; Home
-;--------------------------------------------------------
- .area _HOME
- .area _HOME
-;--------------------------------------------------------
-; code
-;--------------------------------------------------------
- .area _CODE
-;kernel/process.c:5: pid_t newpid(void)
-; ---------------------------------
-; Function newpid
-; ---------------------------------
-_newpid::
-;kernel/process.c:8: return ++last_pid;
- ld hl, #_newpid_last_pid_1_11+0
- inc (hl)
- ld iy,#_newpid_last_pid_1_11
- ld l,0 (iy)
- ret
-;kernel/process.c:11: int fork(void)
-; ---------------------------------
-; Function fork
-; ---------------------------------
-_fork::
-;kernel/process.c:14: }
- ret
-;kernel/process.c:16: int exec(char *path, char *args)
-; ---------------------------------
-; Function exec
-; ---------------------------------
-_exec::
-;kernel/process.c:19: }
- ret
-;kernel/process.c:21: int spawn(char *path, char *args)
-; ---------------------------------
-; Function spawn
-; ---------------------------------
-_spawn::
-;kernel/process.c:24: }
- ret
- .area _CODE
- .area _INITIALIZER
- .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/process.lst b/sw/z80/build/kernel/process.lst
deleted file mode 100644
index eb73943..0000000
--- a/sw/z80/build/kernel/process.lst
+++ /dev/null
@@ -1,89 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
- 4 ; This file was generated Wed Aug 23 21:44:59 2017
- 5 ;--------------------------------------------------------
- 6 .module process
- 7 .optsdcc -mz80
- 8
- 9 ;--------------------------------------------------------
- 10 ; Public variables in this module
- 11 ;--------------------------------------------------------
- 12 .globl _proc_table
- 13 .globl _newpid
- 14 .globl _fork
- 15 .globl _exec
- 16 .globl _spawn
- 17 ;--------------------------------------------------------
- 18 ; special function registers
- 19 ;--------------------------------------------------------
- 20 ;--------------------------------------------------------
- 21 ; ram data
- 22 ;--------------------------------------------------------
- 23 .area _DATA
- 0000 24 _proc_table::
- 0000 25 .ds 6375
- 18E7 26 _newpid_last_pid_1_11:
- 18E7 27 .ds 1
- 28 ;--------------------------------------------------------
- 29 ; ram data
- 30 ;--------------------------------------------------------
- 31 .area _INITIALIZED
- 32 ;--------------------------------------------------------
- 33 ; absolute external ram data
- 34 ;--------------------------------------------------------
- 35 .area _DABS (ABS)
- 36 ;--------------------------------------------------------
- 37 ; global & static initialisations
- 38 ;--------------------------------------------------------
- 39 .area _HOME
- 40 .area _GSINIT
- 41 .area _GSFINAL
- 42 .area _GSINIT
- 43 ;kernel/process.c:7: static pid_t last_pid = 0;
- 0000 FD 21rE7r18 [14] 44 ld iy,#_newpid_last_pid_1_11
- 0004 FD 36 00 00 [19] 45 ld 0 (iy),#0x00
- 46 ;--------------------------------------------------------
- 47 ; Home
- 48 ;--------------------------------------------------------
- 49 .area _HOME
- 50 .area _HOME
- 51 ;--------------------------------------------------------
- 52 ; code
- 53 ;--------------------------------------------------------
- 54 .area _CODE
- 55 ;kernel/process.c:5: pid_t newpid(void)
- 56 ; ---------------------------------
- 57 ; Function newpid
- 58 ; ---------------------------------
- 0000 59 _newpid::
- 60 ;kernel/process.c:8: return ++last_pid;
- 0000 21rE7r18 [10] 61 ld hl, #_newpid_last_pid_1_11+0
- 0003 34 [11] 62 inc (hl)
- 0004 FD 21rE7r18 [14] 63 ld iy,#_newpid_last_pid_1_11
- 0008 FD 6E 00 [19] 64 ld l,0 (iy)
- 000B C9 [10] 65 ret
- 66 ;kernel/process.c:11: int fork(void)
- 67 ; ---------------------------------
- 68 ; Function fork
- 69 ; ---------------------------------
- 000C 70 _fork::
- 71 ;kernel/process.c:14: }
- 000C C9 [10] 72 ret
- 73 ;kernel/process.c:16: int exec(char *path, char *args)
- 74 ; ---------------------------------
- 75 ; Function exec
- 76 ; ---------------------------------
- 000D 77 _exec::
- 78 ;kernel/process.c:19: }
- 000D C9 [10] 79 ret
- 80 ;kernel/process.c:21: int spawn(char *path, char *args)
- 81 ; ---------------------------------
- 82 ; Function spawn
- 83 ; ---------------------------------
- 000E 84 _spawn::
- 85 ;kernel/process.c:24: }
- 000E C9 [10] 86 ret
- 87 .area _CODE
- 88 .area _INITIALIZER
- 89 .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/process.rel b/sw/z80/build/kernel/process.rel
deleted file mode 100644
index f4908e9..0000000
--- a/sw/z80/build/kernel/process.rel
+++ /dev/null
@@ -1,45 +0,0 @@
-XL2
-H 9 areas 6 global symbols
-M process
-O -mz80
-S .__.ABS. Def0000
-A _CODE size F flags 0 addr 0
-S _exec Def000D
-S _spawn Def000E
-S _fork Def000C
-S _newpid Def0000
-A _DATA size 18E8 flags 0 addr 0
-S _proc_table Def0000
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 8 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 01 00
-T 00 00
-R 00 00 01 00
-T E7 18
-R 00 00 01 00
-T E7 18
-R 00 00 01 00
-T 00 00 FD 21 E7 18 FD 36 00 00
-R 00 00 05 00 00 04 01 00
-T 00 00
-R 00 00 00 00
-T 00 00 21 E7 18 34 FD 21 E7 18 FD 6E 00 C9
-R 00 00 00 00 00 03 01 00 00 08 01 00
-T 0C 00
-R 00 00 00 00
-T 0C 00 C9
-R 00 00 00 00
-T 0D 00
-R 00 00 00 00
-T 0D 00 C9
-R 00 00 00 00
-T 0E 00
-R 00 00 00 00
-T 0E 00 C9
-R 00 00 00 00
diff --git a/sw/z80/build/kernel/process.sym b/sw/z80/build/kernel/process.sym
deleted file mode 100644
index f6884cd..0000000
--- a/sw/z80/build/kernel/process.sym
+++ /dev/null
@@ -1,32 +0,0 @@
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1.
-Hexadecimal [16-Bits]
-
-Symbol Table
-
- .__.$$$. = 2710 L
- .__.ABS. = 0000 G
- .__.CPU. = 0000 L
- .__.H$L. = 0000 L
- 0 _exec 000D GR
- 0 _fork 000C GR
- 0 _newpid 0000 GR
- 1 _newpid_last_pid_1_11 18E7 R
- 1 _proc_table 0000 GR
- 0 _spawn 000E GR
-
-
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
-Hexadecimal [16-Bits]
-
-Area Table
-
- 0 _CODE size F flags 0
- 1 _DATA size 18E8 flags 0
- 2 _INITIALIZED size 0 flags 0
- 3 _DABS size 0 flags 8
- 4 _HOME size 0 flags 0
- 5 _GSINIT size 8 flags 0
- 6 _GSFINAL size 0 flags 0
- 7 _INITIALIZER size 0 flags 0
- 8 _CABS size 0 flags 8
-
diff --git a/sw/z80/crt0.rel b/sw/z80/crt0.rel
deleted file mode 100644
index 880fd57..0000000
--- a/sw/z80/crt0.rel
+++ /dev/null
@@ -1,86 +0,0 @@
-XL2
-H 14 areas 5 global symbols
-M crt0
-S .__.ABS. Def0000
-S _kmain Ref0000
-A _CODE size A flags 0 addr 0
-S __clock Def0000
-S _exit Def0004
-A _HEADER size 0 flags 8 addr 0
-A _HEADER0 size 3 flags 8 addr 0
-A _HEADER1 size 2 flags 8 addr 8
-A _HEADER2 size 2 flags 8 addr 10
-A _HEADER3 size 2 flags 8 addr 18
-A _HEADER4 size 2 flags 8 addr 20
-A _HEADER5 size 2 flags 8 addr 28
-A _HEADER6 size 2 flags 8 addr 30
-A _HEADER7 size 2 flags 8 addr 38
-A _HEADER8 size C flags 8 addr 100
-A _HOME size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _GSINIT size 6 flags 0 addr 0
-S gsinit Def0000
-A _GSFINAL size 1 flags 0 addr 0
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _BSEG size 0 flags 0 addr 0
-A _BSS size 0 flags 0 addr 0
-A _HEAP size 0 flags 0 addr 0
-T 00 00
-R 00 00 02 00
-T 00 00 C3 00 01
-R 00 00 02 00 00 03 0A 00
-T 08 00
-R 00 00 03 00
-T 08 00 ED 4D
-R 00 00 03 00
-T 10 00
-R 00 00 04 00
-T 10 00 ED 4D
-R 00 00 04 00
-T 18 00
-R 00 00 05 00
-T 18 00 ED 4D
-R 00 00 05 00
-T 20 00
-R 00 00 06 00
-T 20 00 ED 4D
-R 00 00 06 00
-T 28 00
-R 00 00 07 00
-T 28 00 ED 4D
-R 00 00 07 00
-T 30 00
-R 00 00 08 00
-T 30 00 ED 4D
-R 00 00 08 00
-T 38 00
-R 00 00 09 00
-T 38 00 ED 4D
-R 00 00 09 00
-T 00 01
-R 00 00 0A 00
-T 00 01
-R 00 00 0A 00
-T 00 01 31 FF FF CD 00 00 CD 00 00 C3 04 00
-R 00 00 0A 00 00 06 0D 00 02 09 01 00 00 0C 00 00
-T 00 00
-R 00 00 00 00
-T 00 00 3E 02 CF C9
-R 00 00 00 00
-T 04 00
-R 00 00 00 00
-T 04 00 3E 00 CF
-R 00 00 00 00
-T 07 00
-R 00 00 00 00
-T 07 00 76 18 FD
-R 00 00 00 00
-T 00 00
-R 00 00 0D 00
-T 00 00 78 B1 28 02 ED B0
-R 00 00 0D 00
-T 06 00
-R 00 00 0D 00
-T 00 00 C9
-R 00 00 0E 00
diff --git a/sw/z80/kernel/drivers/ctc.c b/sw/z80/kernel/drivers/ctc.c
new file mode 100644
index 0000000..e23ed8e
--- /dev/null
+++ b/sw/z80/kernel/drivers/ctc.c
@@ -0,0 +1 @@
+#include "drivers/ctc.h" \ No newline at end of file
diff --git a/sw/z80/kernel/drivers/pio.c b/sw/z80/kernel/drivers/pio.c
index 289ebe0..4321fb8 100644
--- a/sw/z80/kernel/drivers/pio.c
+++ b/sw/z80/kernel/drivers/pio.c
@@ -3,17 +3,38 @@
static uint8_t *pio_port = (uint8_t *) ADDR_DEV_PIO;
static uint8_t *pio_ctrl = (uint8_t *) (ADDR_DEV_PIO + 2);
-void _pio_data(int port, uint8_t data)
+inline void _pio_data(int port, uint8_t data)
{
*(pio_port + port) = data;
}
-void _pio_command(int port, uint8_t cmd)
+inline void _pio_control(int port, uint8_t cmd)
{
*(pio_ctrl + port) = cmd;
}
-/* void pio_set_mode(int port, int mode)
+void pio_set_mode(int port, int mode, uint8_t io)
{
+ // 0x0F is a control sequence to set mode
+ _pio_control(port, ((mode << 6) | 0x0F));
-} */
+ // this mode requires an additional argument that sets
+ // a mode for each pin
+ if (mode == PIO_MODE_BIT_IO) {
+ _pio_control(port, io);
+ }
+}
+
+void pio_set_interrupts(int port, int control)
+{
+ // 0x07 is a control sequence to set interrupts
+ _pio_control(port, (control | 0x07));
+}
+
+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
+ _pio_control(port, (control | 0x17));
+ _pio_control(port, mask);
+}
diff --git a/sw/z80/kernel/include/drivers/ctc.h b/sw/z80/kernel/include/drivers/ctc.h
new file mode 100644
index 0000000..488e02b
--- /dev/null
+++ b/sw/z80/kernel/include/drivers/ctc.h
@@ -0,0 +1,6 @@
+#ifndef __CTC_H__
+#define __CTC_H__
+
+void ctc_control()
+
+#endif /* __CTC_H__ */ \ No newline at end of file
diff --git a/sw/z80/kernel/include/drivers/pio.h b/sw/z80/kernel/include/drivers/pio.h
index 5d289ca..0df2ed0 100644
--- a/sw/z80/kernel/include/drivers/pio.h
+++ b/sw/z80/kernel/include/drivers/pio.h
@@ -7,25 +7,27 @@
#define PIO_A 0
#define PIO_B 1
-#define PIO_MODE_0 0
-#define PIO_MODE_1 1
-#define PIO_MODE_2 2
-#define PIO_MODE_3 3
+#define PIO_MODE_BYTE_IN 0
+#define PIO_MODE_BYTE_OUT 1
+#define PIO_MODE_BYTE_BI 2
+#define PIO_MODE_BIT_IO 3
#define PIO_INT_ACTIVE_HIGH (1<<5)
#define PIO_INT_AND_MODE (1<<6)
#define PIO_INT_ENABLE (1<<7)
-void _pio_data(int port, uint8_t data);
-void _pio_command(int port, uint8_t cmd);
+inline void _pio_data(int port, uint8_t data);
+inline void _pio_control(int port, uint8_t cmd);
+
+void pio_set_mode(int port, int mode, uint8_t io);
-void pio_set_mode(int port, int mode);
void pio_set_interrupts(int port, int control);
-void pio_set_interrupts_mask(int port, uint8_t mask);
-void pio_set_io(int port, uint8_t io);
+void pio_set_interrupts_mask(int port, int control, uint8_t mask);
// uint8_t pio_read_data(int port);
+uint8_t pio_read(int port);
+void pio_write(int port, uint8_t data);
inline int pio_read_pin(int port, uint8_t pin);
inline void pio_write_pin(int port, uint8_t pin);
diff --git a/sw/z80/kernel/include/fs/fs.h b/sw/z80/kernel/include/fs/fs.h
index b92303d..ad20adb 100644
--- a/sw/z80/kernel/include/fs/fs.h
+++ b/sw/z80/kernel/include/fs/fs.h
@@ -44,7 +44,7 @@ struct fs_inode
#define FS_INODE_ROOT(inode) {inode.dev = 0xff; inode.inode = 0x0}
#define FS_INODE_NULL(inode) {inode.dev = 0x80; inode.inode = 0x0}
-#define FS_USE_ROM(inode) inode.dev == 0x7f
+#define FS_USE_ROM(inode) {inode.dev == 0x7f}
/* get block seek in current device */
devsize_t fs_block(blk_t block);
diff --git a/sw/z80/kernel/include/memory.h b/sw/z80/kernel/include/memory.h
index 45fc325..67c4b88 100644
--- a/sw/z80/kernel/include/memory.h
+++ b/sw/z80/kernel/include/memory.h
@@ -6,6 +6,7 @@
/* maximum number of pages on the system */
#define PAGES_MAX_COUNT 32
+#define PAGE_SIZE 1000
/* in our system there are only 16 pages since only 64KB can be addressed
* to optimize the memory management in ROM and RAM only pages from this set
@@ -31,17 +32,18 @@
#define ADDR_PAGE_14 0xE000
#define ADDR_PAGE_15 0xF000
+#define ADDR_PAGE_FIRST ADDR_PAGE_8
+#define ADDR_PAGE_LAST ADDR_PAGE_15
+
struct page
{
- uint used :1;
- pid_t pid; // process owner of the page
+ pid_t pid; // process owner of the page (0 if free)
uint16_t addr; // physical address
};
-extern struct page pages_table[PAGES_MAX_COUNT];
-
int mmu_write_table(void);
+int page_new(void);
int page_map(int page, int pid, uint16_t addr);
int page_unmap(int page);
diff --git a/sw/z80/kernel/include/process.h b/sw/z80/kernel/include/process.h
index d7aa7fd..3b0c843 100644
--- a/sw/z80/kernel/include/process.h
+++ b/sw/z80/kernel/include/process.h
@@ -9,6 +9,12 @@
*/
#define PROC_COUNT 2
+/* the pid is defined with a single byte (pid_t is uint8_t), because of that
+ * there cannot be more than 255 processes open at the same time. this is a
+ * limitation but for our purposes is more than enough
+ */
+#define PID_COUNT_MAX 255
+
struct executable
{
void *text;
@@ -19,19 +25,12 @@ struct executable
struct process
{
- uint blocked :1; // process is waiting for hardware or locked
- uint running :1; // pid is used
- struct page pages[4]; // pages used by the process
- // TODO: implement quick callback?
+ uint blocked :1; // process is waiting for hardware or locked
+ uint running :1; // pid is used
+ uint pages; // number of pages used by the process
+ struct page page[4]; // pages used by the process
};
-/* the pid is defined with a single byte (pid_t is uint8_t), because of that
- * there cannot be more than 255 processes open at the same time. this is a
- * limitation but for our purposes is more than enough
- */
-extern struct process proc_table[255];
-extern struct process *current_proc;
-
pid_t newpid(void);
int fork(void);
diff --git a/sw/z80/kernel/include/syscall.h b/sw/z80/kernel/include/syscall.h
deleted file mode 100644
index 29941c9..0000000
--- a/sw/z80/kernel/include/syscall.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __SYS_CALL_H__
-#define __SYS_CALL_H__
-
-/*
-* Enable / disable virtual address traslation
-*/
-
-extern void v_addr(uint8_t flag);
-
-/*
-* Programs execution
-*/
-
-extern void prog_exec_0(void);
-extern void prog_exec_1(void);
-
-extern void prog_stop_0(void);
-extern void prog_stop_1(void);
-
-#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h
index c01afb2..c6e620b 100644
--- a/sw/z80/kernel/include/types.h
+++ b/sw/z80/kernel/include/types.h
@@ -3,39 +3,35 @@
/* only types from primitive types are defined in this file */
-#define register_t volatile unsigned char
+typedef volatile unsigned char register_t;
-#define uint unsigned int
+typedef unsigned int uint;
-#define int8_t char
-#define uint8_t unsigned char
-#define int16_t int
-#define uint16_t unsigned short int
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef int int16_t;
+typedef unsigned int uint16_t;
+typedef long int int32_t;
+typedef unsigned long int uint32_t;
-#define uint32_t unsigned long int
+typedef uint16_t size_t;
+typedef int16_t ssize_t;
-#define size_t uint16_t
-#define ssize_t int16_t
-#define pid_t uint8_t
+typedef uint8_t pid_t;
+typedef uint16_t ino_t;
-#define ino_t uint16_t
+typedef uint8_t dev_t;
+typedef uint32_t devsize_t;
+typedef uint8_t fd_t;
+typedef uint16_t blk_t;
+typedef uint8_t user_t;
-#define dev_t uint8_t
-#define devsize_t uint32_t
-
-#define fd_t uint8_t
-
-#define blk_t uint16_t
-
-#define user_t int8_t
-
-typedef struct
-{
+typedef struct {
uint8_t member[3];
} uint24_t;
-#define fsize_t uint32_t
+typedef uint32_t fsize_t;
typedef struct
{
diff --git a/sw/z80/kernel/memory.c b/sw/z80/kernel/memory.c
index bcda3c3..cda62ca 100644
--- a/sw/z80/kernel/memory.c
+++ b/sw/z80/kernel/memory.c
@@ -1,13 +1,13 @@
#include "memory.h"
-struct page pages_table[PAGES_MAX_COUNT];
+static struct page pages_table[PAGES_MAX_COUNT];
int mmu_write_table(void)
{
int i;
for (i = 0; i < PAGES_MAX_COUNT; i++) {
- if (pages_table[i].used) {
+ if (pages_table[i].pid != 0) {
// write to mmu table
}
}
@@ -15,18 +15,37 @@ int mmu_write_table(void)
return 0;
}
+int page_new(void)
+{
+ int i, addr, used;
+ for (addr = ADDR_PAGE_FIRST; addr < ADDR_PAGE_LAST; addr += PAGE_SIZE) {
+ used = 0;
+
+ for (i = 0; i < PAGES_MAX_COUNT; i++) {
+ if (page_map[i].addr == addr) {
+ used = 1;
+ break;
+ }
+ }
+
+ if (!used)
+ return i;
+ }
+
+ return -1;
+}
+
int page_map(int page, int pid, uint16_t addr)
{
if (page >= PAGES_MAX_COUNT)
return -1;
- if (pages_table[page].used)
+ if (pages_table[page].pid != 0)
return -2;
pages_table[page].addr = addr;
pages_table[page].pid = pid;
- pages_table[page].used = 1;
return 0;
}
@@ -35,10 +54,11 @@ int page_unmap(int page)
if (page >= PAGES_MAX_COUNT)
return -1;
- if (pages_table[page].used == 0)
+ if (pages_table[page].pid == 0)
return -2;
- pages_table[page].used = 0;
+ pages_table[page].pid = 0;
+ pages_table[page].addr = 0;
return 0;
}
diff --git a/sw/z80/kernel/process.c b/sw/z80/kernel/process.c
index 49b86b8..049c88c 100644
--- a/sw/z80/kernel/process.c
+++ b/sw/z80/kernel/process.c
@@ -1,16 +1,48 @@
#include "process.h"
-struct process proc_table[255];
+static struct process proc_table[PID_COUNT_MAX];
+static struct process *current_proc;
pid_t newpid(void)
{
+ int i;
static pid_t last_pid = 0;
- return ++last_pid;
+
+ for (i = 0; i < PID_COUNT_MAX; i++, last_pid++) {
+ if (last_pid == PID_COUNT_MAX) {
+ last_pid = 0;
+ continue;
+ }
+
+ if (!proc_table[last_pid].running)
+ break;
+ }
+
+ if (i >= PID_COUNT_MAX)
+ return 0;
+
+ return last_pid;
}
int fork(void)
{
-
+ int i, p;
+ pid_t child_pid = newpid();
+
+ if (child_pid == 0)
+ return -1;
+
+
+ for (i = 0; i < current_proc.pages; i++) {
+ p = page_new();
+
+ if (p == -1) {
+
+ return -2;
+ }
+
+ proc_table[child_pid].page[i] = p;
+ }
}
int exec(char *path, char *args)
diff --git a/sw/z80/libc/string.c b/sw/z80/libc/string.c
index 9dd56cc..57b3a7f 100644
--- a/sw/z80/libc/string.c
+++ b/sw/z80/libc/string.c
@@ -1,11 +1,11 @@
#include "string.h"
-void * memset(void *dest, const int8_t src, size_t n) {
+void *memset(void *dest, const int8_t src, size_t n) {
- void *dp = dest;
+ char *dp = (char *) dest;
while (n--)
- *dp++ = src;
+ *(dp++) = src;
return dest;
}
@@ -22,16 +22,14 @@ void *memcpy(void *dest, void *src, size_t n)
return dest;
}
-int8_t memcmp(const void *s1, const void *s2, size_t n) {
-
- uint8_t u1, u2;
-
- for ( ; n--; s1++, s2++) {
+int8_t memcmp(void *s1, void *s2, size_t n)
+{
+ char *u1 = (char *) s1;
+ char *u2 = (char *) s2;
- u1 = *s1;
- u2 = *s2;
+ for ( ; n--; u1++, u2++) {
- if (u1 != u2)
+ if (*u1 != *u2)
return u1 - u2;
}
diff --git a/sw/z80/makefile b/sw/z80/makefile
index 5047824..5ab7e93 100644
--- a/sw/z80/makefile
+++ b/sw/z80/makefile
@@ -20,6 +20,7 @@ CFLAGS := -mz80 \
-I kernel/include \
-I kernel/include/drivers \
-I libc/include \
+ --opt-code-size \
-DDEBUG
LDFLAGS := -mz80 --no-std-crt0 crt0.rel \
@@ -43,7 +44,7 @@ crt0.rel: crt0.s
sdasz80 -o $<
dirs:
- mkdir -p build build/kernel build/libc
+ mkdir -p build build/kernel build/libc build/kernel/drivers
dis: $(BINARY)
@# z80dasm -a -l -g 0h $< -o build/$(OSNAME).s
diff --git a/sw/z80_test/crt0.s b/sw/z80_test/crt0.s
new file mode 100644
index 0000000..7701ca6
--- /dev/null
+++ b/sw/z80_test/crt0.s
@@ -0,0 +1,103 @@
+;--------------------------------------------------------------------------
+; crt0.s - Generic crt0.s for a Z80
+;
+; Copyright (C) 2000, Michael Hope
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module crt0
+ .globl _main
+
+ .area _HEADER (ABS)
+ ;; Reset vector
+ .org 0
+ jp init
+
+ .org 0x08
+ reti
+ .org 0x10
+ reti
+ .org 0x18
+ reti
+ .org 0x20
+ reti
+ .org 0x28
+ reti
+ .org 0x30
+ reti
+ .org 0x38
+ reti
+
+ .org 0x100
+init:
+ ;; Set stack pointer directly above top of memory.
+ ld sp,#0xFFFF
+
+ ;; Initialise global variables
+ call gsinit
+ call _main
+ jp _exit
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _CODE
+ .area _INITIALIZER
+ .area _GSINIT
+ .area _GSFINAL
+
+ .area _DATA
+ .area _INITIALIZED
+ .area _BSEG
+ .area _BSS
+ .area _HEAP
+
+ .area _CODE
+
+__clock::
+ ld a,#2
+ rst 0x08
+ ret
+
+_exit::
+ ;; Exit - special code to the emulator
+ ld a,#0
+ rst 0x08
+1$:
+ halt
+ jr 1$
+
+ .area _GSINIT
+gsinit::
+ ; ld bc, #l__INITIALIZER
+ ld a, b
+ or a, c
+ jr Z, gsinit_next
+ ; ld de, #s__INITIALIZED
+ ; ld hl, #s__INITIALIZER
+ ldir
+gsinit_next:
+
+ .area _GSFINAL
+ ret
+
diff --git a/sw/z80_test/ctc.c b/sw/z80_test/ctc.c
new file mode 100644
index 0000000..3a4e7d5
--- /dev/null
+++ b/sw/z80_test/ctc.c
@@ -0,0 +1,7 @@
+#include "ctc.h"
+
+void ctc_control()
+{
+
+}
+
diff --git a/sw/z80_test/ctc.h b/sw/z80_test/ctc.h
new file mode 100644
index 0000000..c6b3150
--- /dev/null
+++ b/sw/z80_test/ctc.h
@@ -0,0 +1,6 @@
+#ifndef __CTC_H__
+#define __CTC_H__
+
+void ctc_control();
+
+#endif /* __CTC_H__ */ \ No newline at end of file
diff --git a/sw/z80_test/devices.h b/sw/z80_test/devices.h
new file mode 100644
index 0000000..a846f9b
--- /dev/null
+++ b/sw/z80_test/devices.h
@@ -0,0 +1,15 @@
+#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 0x4100
+#define ADDR_DEV_PIO 0x4200
+
+#define ADDR_DEV_MMU
+
+#define ADDR_DEV_RAM 0x8000
+
+#endif
diff --git a/sw/z80_test/main.c b/sw/z80_test/main.c
new file mode 100644
index 0000000..d2e1d8e
--- /dev/null
+++ b/sw/z80_test/main.c
@@ -0,0 +1,11 @@
+#include "usart.h"
+
+void main(void)
+{
+ usart_init(USART_BAUDRATE_1200, USART_PARITY_EVEN, USART_STOP_BITS_1);
+ usart_write("Hello, World!\n", 13);
+
+ while(1) {
+ usart_write("done\n", 5);
+ }
+}
diff --git a/sw/z80_test/makefile b/sw/z80_test/makefile
new file mode 100644
index 0000000..6f054ae
--- /dev/null
+++ b/sw/z80_test/makefile
@@ -0,0 +1,52 @@
+####
+# source code settings
+#
+OSNAME := sample
+
+CSOURCES := $(wildcard *.c)
+
+OBJECTS := $(patsubst %.c,build/%.rel,$(CSOURCES))
+HEXFILE := build/$(OSNAME).hex
+BINARY := build/$(OSNAME).bin
+
+###
+# compiler settings
+
+CC := sdcc
+
+CFLAGS := -mz80 \
+ -I . \
+ -DDEBUG
+
+LDFLAGS := -mz80 --no-std-crt0 build/crt0.rel \
+ --std-c89 -pedantic \
+ --code-loc 0x0800 --data-loc 0x2000
+
+.PHONY: dirs dis clean
+all: $(BINARY)
+
+# build binary
+$(BINARY): $(OBJECTS) dirs
+ $(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE)
+ @# xxd -r -p $(HEXFILE) $(BINARY)
+ @# makebin -s 16384 $(HEXFILE) $(BINARY)
+ makebin -s 8192 $(HEXFILE) $(BINARY)
+
+$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs build/crt0.rel
+ @printf "\n"
+ $(CC) $(CFLAGS) -c $< -o $@
+
+build/crt0.rel: crt0.s
+ sdasz80 -o $<
+ @mv crt0.rel build/
+
+dirs:
+ mkdir -p build
+
+dis: $(BINARY)
+ @# z80dasm -a -l -g 0h $< -o build/$(OSNAME).s
+ dz80 -b -n $<
+
+clean:
+ - rm -rd build/*
+ - rm crt0.rel
diff --git a/sw/z80_test/pio.c b/sw/z80_test/pio.c
new file mode 100644
index 0000000..5ca9149
--- /dev/null
+++ b/sw/z80_test/pio.c
@@ -0,0 +1,40 @@
+#include "pio.h"
+
+static uint8_t *pio_port = (uint8_t *) ADDR_DEV_PIO;
+static uint8_t *pio_ctrl = (uint8_t *) (ADDR_DEV_PIO + 2);
+
+inline void _pio_data(int port, uint8_t data)
+{
+ *(pio_port + port) = data;
+}
+
+inline void _pio_control(int port, uint8_t cmd)
+{
+ *(pio_ctrl + port) = cmd;
+}
+
+void pio_set_mode(int port, int mode, uint8_t io)
+{
+ // 0x0F is a control sequence to set mode
+ _pio_control(port, ((mode << 6) | 0x0F));
+
+ // this mode requires an additional argument that sets
+ // a mode for each pin
+ if (mode == PIO_MODE_BIT_IO) {
+ _pio_control(port, io);
+ }
+}
+
+void pio_set_interrupts(int port, int control)
+{
+ // 0x07 is a control sequence to set interrupts
+ _pio_control(port, (control | 0x07));
+}
+
+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
+ _pio_control(port, (control | 0x17));
+ _pio_control(port, mask);
+}
diff --git a/sw/z80_test/pio.h b/sw/z80_test/pio.h
new file mode 100644
index 0000000..0df2ed0
--- /dev/null
+++ b/sw/z80_test/pio.h
@@ -0,0 +1,37 @@
+#ifndef __PIO_H__
+#define __PIO_H__
+
+#include "devices.h"
+#include "types.h"
+
+#define PIO_A 0
+#define PIO_B 1
+
+#define PIO_MODE_BYTE_IN 0
+#define PIO_MODE_BYTE_OUT 1
+#define PIO_MODE_BYTE_BI 2
+#define PIO_MODE_BIT_IO 3
+
+#define PIO_INT_ACTIVE_HIGH (1<<5)
+#define PIO_INT_AND_MODE (1<<6)
+#define PIO_INT_ENABLE (1<<7)
+
+
+inline void _pio_data(int port, uint8_t data);
+inline void _pio_control(int port, uint8_t cmd);
+
+void pio_set_mode(int port, int mode, uint8_t io);
+
+void pio_set_interrupts(int port, int control);
+void pio_set_interrupts_mask(int port, int control, uint8_t mask);
+
+// uint8_t pio_read_data(int port);
+uint8_t pio_read(int port);
+void pio_write(int port, uint8_t data);
+
+inline int pio_read_pin(int port, uint8_t pin);
+inline void pio_write_pin(int port, uint8_t pin);
+
+// TODO: implement mode (in/out/both) and interrupt vector
+
+#endif // __PIO_H__
diff --git a/sw/z80_test/types.h b/sw/z80_test/types.h
new file mode 100644
index 0000000..815fc68
--- /dev/null
+++ b/sw/z80_test/types.h
@@ -0,0 +1,13 @@
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+/* only types from primitive types are defined in this file */
+
+typedef volatile unsigned char register_t;
+
+typedef unsigned int uint;
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef int int16_t;
+typedef unsigned int uint16_t;
+#endif
diff --git a/sw/z80_test/usart.c b/sw/z80_test/usart.c
new file mode 100644
index 0000000..9ec6dbd
--- /dev/null
+++ b/sw/z80_test/usart.c
@@ -0,0 +1,91 @@
+#include "usart.h"
+
+static struct _usart_device *_usart = (struct _usart_device *) ADDR_DEV_USART;
+
+void usart_set_baudrate(uint16_t baudrate)
+{
+ // enable latch access
+ _usart->LCR.divisor_latch_access = 1;
+ _usart->buffer = 0x00FF & baudrate; // LSBs
+ memcpy(&_usart->IER, &(baudrate >>8), 1);
+ // _usart->IER = 0x00FF & (baudrate >> 8); // MSBs
+ _usart->LCR.divisor_latch_access = 0;
+}
+
+void usart_set_parity(int mode)
+{
+ if (mode == USART_PARITY_EVEN) {
+ _usart->LCR.even_parity = 1;
+ }
+ else if (mode == USART_PARITY_ODD) {
+ _usart->LCR.even_parity = 0;
+ }
+
+ _usart->LCR.parity = (mode == USART_PARITY_NONE) ? 0 : 1;
+}
+
+void usart_set_stop_bits(int count)
+{
+ _usart->LCR.stop_bits = (count == USART_STOP_BITS_1) ? 0 : 1;
+}
+
+void usart_word_length(int length)
+{
+ _usart->LCR.word_length = length;
+}
+
+void usart_set_autoflow(int mode)
+{
+ _usart->MCR.autoflow = (mode == USART_AUTOFLOW_OFF) ? 0 : 1;
+ _usart->MCR.data_terminal_ready = (mode == USART_AUTOFLOW_ALL);
+}
+
+inline void usart_init(uint16_t baudrate, int parity, int stop_bits)
+{
+ usart_set_baudrate(baudrate);
+ usart_set_parity(parity);
+ usart_set_stop_bits(stop_bits);
+ usart_set_autoflow(USART_AUTOFLOW_OFF);
+}
+
+void usart_transmit(uint8_t data)
+{
+ _usart->buffer = data;
+ while (_usart->LSR.transmitter_holder_empty == 0); // wait
+}
+
+uint8_t usart_receive()
+{
+ return _usart->buffer;
+}
+
+int usart_write(uint8_t *data, size_t size)
+{
+ uint8_t *dp = data;
+
+ while (size--) {
+ _usart->buffer = *(dp++);
+ while (_usart->LSR.transmitter_empty);
+ }
+
+ // TODO: do something that actually counts for sent bytes
+ return size;
+}
+
+int usart_read(uint8_t *buffer, size_t count)
+{
+ uint8_t *bp = buffer;
+ size_t read_count = 0;
+
+ while (count--) {
+ *(bp++) = _usart->buffer;
+ // check for errors
+ if (_usart->LSR.framing_error || _usart->LSR.parity_error) {
+ bp--; // delete last byte (?)
+ } else {
+ read_count++;
+ }
+ }
+
+ return read_count;
+}
diff --git a/sw/z80_test/usart.h b/sw/z80_test/usart.h
new file mode 100644
index 0000000..b85ee3e
--- /dev/null
+++ b/sw/z80_test/usart.h
@@ -0,0 +1,155 @@
+#ifndef __USART_H__
+#define __USART_H__
+
+#include "types.h"
+#include "devices.h"
+
+#include "string.h"
+
+// baudrate clock divisors
+// values from TL16C550C datasheet (table 9 for 1.8432 MHz crystal)
+#define USART_BAUDRATE_50 2304
+#define USART_BAUDRATE_75 1536
+#define USART_BAUDRATE_110 1047
+#define USART_BAUDRATE_134_5 857
+#define USART_BAUDRATE_150 768
+#define USART_BAUDRATE_300 384
+#define USART_BAUDRATE_600 192
+#define USART_BAUDRATE_1200 96
+#define USART_BAUDRATE_1800 64
+#define USART_BAUDRATE_2000 58
+#define USART_BAUDRATE_2400 48
+#define USART_BAUDRATE_3600 32
+#define USART_BAUDRATE_4800 24
+#define USART_BAUDRATE_7200 16
+#define USART_BAUDRATE_9600 12
+#define USART_BAUDRATE_19200 6
+#define USART_BAUDRATE_38400 3
+#define USART_BAUDRATE_56000 3
+
+// parity
+#define USART_PARITY_NONE 0
+#define USART_PARITY_EVEN 1
+#define USART_PARITY_ODD 2
+
+// stop bits
+#define USART_STOP_BITS_1 10
+#define USART_STOP_BITS_15 15
+#define USART_STOP_BITS_2 20
+
+// word lenght
+#define USART_WORD_LENGTH_5 0
+#define USART_WORD_LENGTH_6 1
+#define USART_WORD_LENGTH_7 2
+#define USART_WORD_LENGTH_8 3
+
+// autoflow
+#define USART_AUTOFLOW_ALL 3
+#define USART_AUTOFLOW_CTS 2
+#define USART_AUTOFLOW_OFF 0
+
+/* stuctures for usart registers */
+struct IER
+{
+ volatile uint received_data_interrupt :1;
+ volatile uint transmitter_empty_interrupt :1;
+ volatile uint receiver_line_status_interrupt :1;
+ volatile uint modem_status_interrupt :1;
+ volatile uint reserved :4;
+};
+
+struct IIR
+{
+ volatile uint interrupt_pending :1;
+ volatile uint interrupt_id :3;
+ volatile uint reserved :2;
+ volatile uint fifos :2;
+};
+
+struct FCR
+{
+ volatile uint fifo_enable :1;
+ volatile uint receiver_fifo_rst :1;
+ volatile uint trasmitter_fifo_rst :1;
+ volatile uint dma_mode_select :1;
+ volatile uint reserved :1;
+ volatile uint receiver_trigger :2;
+};
+
+struct LCR
+{
+ volatile uint word_length :2;
+ volatile uint stop_bits :1;
+ volatile uint parity :1;
+ volatile uint even_parity :1;
+ volatile uint stick_parity :1;
+ volatile uint break_control :1;
+ volatile uint divisor_latch_access :1;
+};
+
+struct MCR
+{
+ volatile uint data_terminal_ready :1;
+ volatile uint request_to_send :1;
+ volatile uint out1;
+ volatile uint out2;
+ volatile uint loop;
+ volatile uint autoflow :1;
+ volatile uint reserved :2;
+};
+
+struct LSR
+{
+ volatile uint data_ready :1;
+ volatile uint overrun_error :1;
+ volatile uint parity_error :1;
+ volatile uint framing_error :1;
+ volatile uint break_interrupt :1;
+ volatile uint transmitter_holder_empty :1;
+ volatile uint transmitter_empty :1;
+ volatile uint fifo_recv_error :1;
+};
+
+struct MSR
+{
+ volatile uint delta_cts :1;
+ volatile uint delta_data_set_ready :1;
+ volatile uint trailing_edge_ring_indicator :1;
+ volatile uint delta_data_carrier_detect :1;
+ volatile uint clear_to_send :1;
+ volatile uint data_set_ready :1;
+ volatile uint ring_indicator :1;
+ volatile uint data_carrier_detect :1;
+};
+
+/* this structure is only for internal usage */
+struct _usart_device
+{
+ register_t buffer; // also used as LSB for divisor latch
+ struct IER IER;
+ struct IIR IIR;
+ struct FCR FCR;
+ struct LCR LCR;
+ struct MCR MCR;
+ struct LSR LSR;
+ struct MSR MSR;
+ register_t scratch;
+};
+
+
+// setup functions (wrappers)
+void usart_set_baudrate(uint16_t baudrate);
+void usart_set_parity(int mode);
+void usart_set_stop_bits(int count);
+void usart_set_word_length(int length);
+void usart_set_autoflow(int mode);
+
+inline void usart_init(uint16_t baudrate, int parity, int stop_bits);
+
+void usart_transmit(uint8_t data);
+uint8_t usart_receive();
+
+int usart_write(uint8_t *data, size_t size);
+int usart_read(uint8_t *buffer, size_t count);
+
+#endif // __USART__H__