Dusk OS is a 32-bit Forth running on i386 and ARM CPUs and big brother to Collapse OS. Its primary purpose is to be maximally useful during the first stage of civilizational collapse, that is, when we can't produce modern computers anymore but that there's still many modern computers still around.
It does so by aggressively prioritizing simplicity at the cost of unorthodox constraints, while also aiming to make power users happy.
Dusk OS innovates by having an "almost C" compiler allowing it to piggy-back on UNIX C code, through a modest porting effort, to reach its goals and stay true to its design constraints with a minimal effort.
This is Dusk OS' source code and the rest of the README assumes that you want to run it. To read more about why this OS exists, see its website. To see where it's going, you can look at the roadmap.
Dusk is designed to run on bare metal and to build itself from itself. However,
it's also possible to build Dusk from any POSIX platform using Dusk's C VM from
posix/vm.c
. This VM implements a Forth that can interpret the whole of Dusk's
Forth code, but this VM is CPU-agnostic and has its own simplistic bytecode.
That is enough to generate bare metal images for any of its target platforms, so that's why it exists. To build this VM, you need:
Running make
will yield a ./dusk
binary which if opened, provides an
interactive prompt.
Documentation lives in fs/doc
. You can begin with doc/index. Type
bye
to quit.
Dusk OS expects a non-canonical raw input. With a regular TTY, your input will be buffered and echoed twice and reads to it will be blocking. We don't want that. To avoid that, you can invoke it like this:
(stty -icanon -echo min 0; ./dusk; stty icanon echo)
make run
does this for you.
Running Dusk under the POSIX VM is fine, but severly limited: the filesystem is read-only and there is no Grid (text UI system) or Screen (graphical system).
To see a fully-featured Dusk, it's better to run it on an actual machine or, if
you're in a hurry, under QEMU. You can do the latter with make pcrun
.
Dusk is self-hosting and has the ability to create its own FAT. However, through
the POSIX VM, this process is quite slow and after a few times, you might tire
of waiting after this process. If you install mtools, things will
speed up. If mcopy
is present on the host, the Makefile will pick it up and
use it instead of using Dusk's FAT tools. This is much faster.
To deploy Dusk on a real machine, it's a bit more involving and you should read
doc/deploy.txt
.
Dusk OS has a peculiar target: WASM on a modern browser. It's represented as a graphical console with a fully functional Dusk OS prompt in a browser tab.
To build, you need AssemblyScript, which needs, ahem, NPM. Build instructions:
npm -g install assemblyscript
make wasm.img
cd wasm && make
wasm/index.html
.wasm/kernel.wasm
.wasm.img
Note that the WASM target is much, much slower than other Dusk OS targets.
Some Dusk OS targets, such as the PC and WASM targets, have graphical capabilities as well as varvara bindings for it. To have an idea of what graphics look like, you can try this on one of these targets:
f<< tests/manual/uxn/sprite.fs
This will:
tests/manual/uxn/sprite.tal
(a copy of the official screen.tal
)sprite.tal
You now have it running. There is also a mouse cursor that you can move around. Press Escape to return to prompt. You can try the same thing with:
tests/manual/uxn/mandel.fs
tests/manual/uxn/ctrl.fs
tests/manual/uxn/mouse.fs
text/left.fs
The Collapse OS project lives inside Dusk OS which has a compatibility layer allowing it to run Forth code in "Collapse OS mode", which makes it the simplest way around to bootstrap a seed Collapse OS binary.
To be sure: Collapse OS is fully self-hosting and doesn't need Dusk OS to build itself, but if you don't already have a Collapse OS environment handy, then you need a way to craft your first Collapse OS image. Dusk OS is this way.
Collapse OS itself doesn't contain any machine-specific code so it can't, by itself, build an image for a real machine. That machine-specific code live in different repositories all around. This is the list of known Collapse OS ports to real machines:
If you know of other ports out there, please get in touch, we'll add links here.
The idea is eventually to have virtual machines (that is, machines with simplistic virtual hardware that doesn't map to anything that exists physically) for each supported CPU that is emulated from within Dusk OS, but this hasn't been done yet. These virtual machines will live directly in the "core" Collapse OS and will serve as development testbeds.