From 7fad3b0c90a80e93771818ce2666fb7d081ed45c Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 19 May 2019 11:19:41 -0400 Subject: [PATCH] Move /parts/z80 to /kernel Let go of that "meta os" thing. it's not as meta as I made it sound like. It's a kernel. --- README.md | 8 +++++--- apps/README.md | 8 +++++++- {parts/z80 => kernel}/README.md | 19 ++++++------------- {parts/z80 => kernel}/acia.asm | 0 {parts/z80 => kernel}/blockdev.asm | 0 {parts/z80 => kernel}/blockdev_cmds.asm | 0 {parts/z80 => kernel}/core.asm | 0 {parts/z80 => kernel}/fs.asm | 0 {parts/z80 => kernel}/fs_cmds.asm | 0 {parts/z80 => kernel}/mmap.asm | 0 {parts/z80 => kernel}/parse.asm | 0 {parts/z80 => kernel}/sdc.asm | 0 {parts/z80 => kernel}/shell.asm | 0 {parts/z80 => kernel}/stdio.asm | 0 parts/README.md | 11 ----------- parts/avr/README.md | 15 --------------- tools/emul/Makefile | 8 ++++---- tools/tests/Makefile | 2 +- tools/tests/unit/runtests.sh | 4 ++-- tools/tests/zasm/runtests.sh | 4 ++-- 20 files changed, 27 insertions(+), 52 deletions(-) rename {parts/z80 => kernel}/README.md (69%) rename {parts/z80 => kernel}/acia.asm (100%) rename {parts/z80 => kernel}/blockdev.asm (100%) rename {parts/z80 => kernel}/blockdev_cmds.asm (100%) rename {parts/z80 => kernel}/core.asm (100%) rename {parts/z80 => kernel}/fs.asm (100%) rename {parts/z80 => kernel}/fs_cmds.asm (100%) rename {parts/z80 => kernel}/mmap.asm (100%) rename {parts/z80 => kernel}/parse.asm (100%) rename {parts/z80 => kernel}/sdc.asm (100%) rename {parts/z80 => kernel}/shell.asm (100%) rename {parts/z80 => kernel}/stdio.asm (100%) delete mode 100644 parts/README.md delete mode 100644 parts/avr/README.md diff --git a/README.md b/README.md index de92b2e..e7405c0 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,9 @@ in a couple of decades, build a new IC fab (or bring an old one back to life). The project is progressing well and I already have a working shell (see `doc` to see what it can do) on a classic RC2014. Highlights: -* Extremely flexible: this is not an OS, but a meta OS. You build your own OS - through glue code. +* Extremely flexible: Kernel parts are written as loosely knit modules that + are bound through glue code. This makes the kernel adaptable to many unforseen + situations. * 2K binary (but size vary wildly depending on what parts you include. 2K is for a shell using all parts). * Built with minimal tooling: only [scas][scas] is needed @@ -101,7 +102,8 @@ to see what it can do) on a classic RC2014. Highlights: There's very little done so far, but here's how it's organized: -* `parts`: Pieces of code to be assembled by the user into an OS. +* `kernel`: Pieces of code to be assembled by the user into a kernel. +* `apps`: Pieces of code to be assembled into "userspace" application. * `recipes`: collection of recipes that assemble parts together on a specific machine. * `doc`: User guide for when you've successfully installed Collapse OS. diff --git a/apps/README.md b/apps/README.md index 02d5a9b..5ec9992 100644 --- a/apps/README.md +++ b/apps/README.md @@ -1,3 +1,9 @@ # User applications -This folder contains code designed to be loaded and ran in RAM. +This folder contains code designed to be "userspace" application. Unlike the +kernel, which always stay in memory. Those apps here will more likely be loaded +in RAM from storage, ran, then discarded so that another userspace program can +be run. + +That doesn't mean that you can't include that code in your kernel though, but +you will typically not want to do that. diff --git a/parts/z80/README.md b/kernel/README.md similarity index 69% rename from parts/z80/README.md rename to kernel/README.md index 7d8fcd6..015162d 100644 --- a/parts/z80/README.md +++ b/kernel/README.md @@ -1,8 +1,9 @@ -# Z80 Parts +# Kernel -Bits and pieces of code that you can assemble to build an OS for your machine. +Bits and pieces of code that you can assemble to build a kernel for your +machine. -These parts are made to be glued together in a single `main.asm` file you write +These parts are made to be glued together in a single `glue.asm` file you write yourself. As of now, the z80 assembler code is written to be assembled with [scas][scas], @@ -39,15 +40,7 @@ Thus, code that glue parts together coould look like: The asm code used in these parts is heavily dependent on what scas offers. I try to be as "low-tech" as possible because the implementation of the assembler -to be implemented for the z80 will likely be more limited. For example, I try -to avoid macros. - -One exception, however, is for the routine hooks (`SHELL_GETC` for example). At -first, I wanted to assign a label to a const (`SHELL_GETC .equ aciaGetC` for -example), but it turns out that scas doesn't support this (but it could: label -addresses are known at compile time and thus can be consts (maybe at the cost -of an extra pass though)). I went for macros instead, but that doesn't mean -that the z80 assembler will need to support macros. It just need to support -labels-as-consts. +to be implemented for the z80 will likely be more limited. For example, we don't +use macros. [scas]: https://github.com/KnightOS/scas diff --git a/parts/z80/acia.asm b/kernel/acia.asm similarity index 100% rename from parts/z80/acia.asm rename to kernel/acia.asm diff --git a/parts/z80/blockdev.asm b/kernel/blockdev.asm similarity index 100% rename from parts/z80/blockdev.asm rename to kernel/blockdev.asm diff --git a/parts/z80/blockdev_cmds.asm b/kernel/blockdev_cmds.asm similarity index 100% rename from parts/z80/blockdev_cmds.asm rename to kernel/blockdev_cmds.asm diff --git a/parts/z80/core.asm b/kernel/core.asm similarity index 100% rename from parts/z80/core.asm rename to kernel/core.asm diff --git a/parts/z80/fs.asm b/kernel/fs.asm similarity index 100% rename from parts/z80/fs.asm rename to kernel/fs.asm diff --git a/parts/z80/fs_cmds.asm b/kernel/fs_cmds.asm similarity index 100% rename from parts/z80/fs_cmds.asm rename to kernel/fs_cmds.asm diff --git a/parts/z80/mmap.asm b/kernel/mmap.asm similarity index 100% rename from parts/z80/mmap.asm rename to kernel/mmap.asm diff --git a/parts/z80/parse.asm b/kernel/parse.asm similarity index 100% rename from parts/z80/parse.asm rename to kernel/parse.asm diff --git a/parts/z80/sdc.asm b/kernel/sdc.asm similarity index 100% rename from parts/z80/sdc.asm rename to kernel/sdc.asm diff --git a/parts/z80/shell.asm b/kernel/shell.asm similarity index 100% rename from parts/z80/shell.asm rename to kernel/shell.asm diff --git a/parts/z80/stdio.asm b/kernel/stdio.asm similarity index 100% rename from parts/z80/stdio.asm rename to kernel/stdio.asm diff --git a/parts/README.md b/parts/README.md deleted file mode 100644 index 9e5afe2..0000000 --- a/parts/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Parts - -Pieces of code that you can assemble together to make your machine work as you -want them to work. - -Collapse OS is built around the z80, but it doesn't mean that your machine can't -mix and match microcontrollers. This is why this folder is subdivided by -architectures. - -Obviously, different architectures can't be assembled together in the same -binary, but they can nevertheless be made to work well together. diff --git a/parts/avr/README.md b/parts/avr/README.md deleted file mode 100644 index b49c02e..0000000 --- a/parts/avr/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# AVR parts - -The idea with the AVR parts is that you will design peripherals plugged into -your z80 that are controlled by AVR microcontrollers. - -AVR is a large family and although they all work more-or-less the same, -assembler code for one model can't be directly used on another model. Despite -this, parts are only written once. If the model you have on hand doesn't match, -you'll have to translate yourself. - -There are also tons of possible variants to some of those parts. You could want -to implement a feature with a certain set of supporting ICs that aren't the -same as implemented in the part. We can't possibly cover all combinations. We -won't. We'll try to have a good variety of problems we solve so that you have -good material for mix-and-matching your own solution. diff --git a/tools/emul/Makefile b/tools/emul/Makefile index 4e7a933..1e7742b 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -2,7 +2,7 @@ TARGETS = shell/shell zasm/zasm runbin/runbin KERNEL_HEADERS = shell/kernel.h zasm/kernel.h USER_HEADERS = zasm/user.h CFSPACK = ../cfspack/cfspack -PARTS = ../../parts/z80 +KERNEL = ../../kernel APPS = ../../apps .PHONY: all @@ -11,12 +11,12 @@ all: $(TARGETS) shell/kernel.h: shell/shell_.asm zasm/kernel.h: zasm/glue.asm $(KERNEL_HEADERS): - scas -o - -I $(PARTS) -I $(APPS) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null + scas -o - -I $(KERNEL) -I $(APPS) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null zasm/includes.cfs: $(CFSPACK) rm -rf zasm/includes - cp -r ../../parts/z80 zasm/includes - cp -r ../../apps/zasm zasm/includes/zasm + cp -r $(KERNEL) zasm/includes + cp -r $(APPS)/zasm zasm/includes/zasm find zasm/includes -name *.md -delete find zasm/includes -type f -exec sed -i -e 's/;.*//g' {} \; $(CFSPACK) zasm/includes > $@ diff --git a/tools/tests/Makefile b/tools/tests/Makefile index 563aa51..44890ad 100644 --- a/tools/tests/Makefile +++ b/tools/tests/Makefile @@ -1,4 +1,4 @@ -EMULDIR = ../../tools/emul +EMULDIR = ../emul .PHONY: run run: diff --git a/tools/tests/unit/runtests.sh b/tools/tests/unit/runtests.sh index cabf70a..ef6b07b 100755 --- a/tools/tests/unit/runtests.sh +++ b/tools/tests/unit/runtests.sh @@ -4,13 +4,13 @@ set -e set -o pipefail SCAS=scas -PARTS=../../../parts/z80 +KERNEL=../../../kernel APPS=../../../apps RUNBIN=../../emul/runbin/runbin for fn in *.asm; do echo "Running test ${fn}" - if ! ${SCAS} -I ${PARTS} -I ${APPS} -o - ${fn} | ${RUNBIN}; then + if ! ${SCAS} -I ${KERNEL} -I ${APPS} -o - ${fn} | ${RUNBIN}; then echo "failed with code ${PIPESTATUS[1]}" exit 1 fi diff --git a/tools/tests/zasm/runtests.sh b/tools/tests/zasm/runtests.sh index 144c1ca..d7b82db 100755 --- a/tools/tests/zasm/runtests.sh +++ b/tools/tests/zasm/runtests.sh @@ -4,13 +4,13 @@ set -e TMPFILE=$(mktemp) SCAS=scas -PARTS=../../../parts/z80 +KERNEL=../../../kernel APPS=../../../apps ZASM=../../emul/zasm/zasm ASMFILE=${APPS}/zasm/instr.asm cmpas() { - EXPECTED=$($SCAS -I ${PARTS} -I ${APPS} -o - "$1" | xxd) + EXPECTED=$($SCAS -I ${KERNEL} -I ${APPS} -o - "$1" | xxd) ACTUAL=$(cat $1 | $ZASM | xxd) if [ "$ACTUAL" == "$EXPECTED" ]; then echo ok