commit ee4c507adc3749f743eb91b5bd9013508b449390
parent d963d52fda765b54e5894cfdd314d3f4a791563e
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 29 Jun 2022 14:53:46 -0400
fatfs and ramdrive: first steps
Diffstat:
10 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/.build.yml b/.build.yml
@@ -2,6 +2,7 @@ image: debian/stable
arch: amd64
packages:
- nasm
+ - mtools
- build-essential
tasks:
- build: |
diff --git a/.gitignore b/.gitignore
@@ -1,2 +1,3 @@
/dusk
+/fatfs
*.o
diff --git a/Makefile b/Makefile
@@ -1,10 +1,15 @@
TARGETS = dusk
all: $(TARGETS)
-dusk: dusk.asm boot.fs
+dusk: dusk.asm boot.fs fatfs
nasm -f elf32 dusk.asm -o dusk.o
ld -m elf_i386 dusk.o -o $@
+fatfs: fs
+ dd if=/dev/zero of=$@ bs=4M count=1
+ mformat -i $@ ::
+ mcopy -sQ -i $@ fs/* ::
+
.PHONY: run
run: dusk
stty -icanon -echo; ./dusk ; stty icanon echo
diff --git a/README.md b/README.md
@@ -129,6 +129,7 @@ To build Dusk OS, you need:
* GNU binutils
* nasm
* A x86-compatible Linux kernel to run this on
+* [mtools][6]
Run `make` and then run `./dusk`. You'll get a prompt. Documentation is lacking
for now, you'll have to look at the source to have an idea of available
@@ -152,3 +153,4 @@ You might be interested in [this thread from the mailing list][5].
[3]: https://sr.ht/~vdupras/duskos
[4]: https://sr.ht/~vdupras/duskos/lists
[5]: https://lists.sr.ht/~vdupras/duskos-discuss/%3C87czew8rir.fsf%40valley.vpn%3E
+[6]: https://www.gnu.org/software/mtools/
diff --git a/dusk.asm b/dusk.asm
@@ -82,6 +82,7 @@ rootfspath: db "fs", 0
wnfstr: db " word not found"
uflwstr: db "stack underflow"
wordexpstr: db "word expected"
+fatfs: incbin "fatfs"
SECTION .text
GLOBAL _start
@@ -567,6 +568,10 @@ defword 'heremax', 7, word_heremax
pspush heremax
ret
+defword 'fatfs(', 6, word_fatfsaddr
+ pspush fatfs
+ ret
+
defword 'compiling', 9, word_compiling
sysval compiling
diff --git a/fs/drv/ramdrive.fs b/fs/drv/ramdrive.fs
@@ -0,0 +1,13 @@
+\ Drive in RAM
+
+\ This implements the "drive" protocol, which for now is undocumented, on top
+\ of an area in RAM.
+
+512 const RAMDRVSECSZ
+0 value ramdrv(
+
+: _addr ( blkno -- a ) RAMDRVSECSZ * ramdrv( + ;
+: ramdrv@ ( blkno buf -- )
+ swap _addr swap ( src buf ) RAMDRVSECSZ move ;
+: ramdrv! ( blkno buf -- )
+ swap _addr ( buf dst ) RAMDRVSECSZ move ;
diff --git a/fs/fs/boot.fs b/fs/fs/boot.fs
@@ -0,0 +1,11 @@
+\ boot filesystem implementation
+
+\ This is a subset of a FAT16 implementation. It is designed to be embedded
+\ right after "boot.fs" and provide the means to continue bootstrapping on.
+
+\ Its goal is to provide fopen and fread, nothing more. The rest of the FAT16
+\ implementation is in drv/fat16
+
+\ This unit has access to a very small set of words, that it, words implemented
+\ by boot.fs as well as the "drive" protocol, which is implemented by a driver
+\ that is inserted between boot.fs and this unit.
diff --git a/fs/tests/all.fs b/fs/tests/all.fs
@@ -1,5 +1,6 @@
\ Run all test suites
f<< tests/kernel.fs
f<< tests/lib/all.fs
+f<< tests/drv/all.fs
f<< tests/asm.fs
f<< tests/cc/all.fs
diff --git a/fs/tests/drv/all.fs b/fs/tests/drv/all.fs
@@ -0,0 +1,2 @@
+\ Run all drv test suites
+f<< tests/drv/ramdrive.fs
diff --git a/fs/tests/drv/ramdrive.fs b/fs/tests/drv/ramdrive.fs
@@ -0,0 +1,9 @@
+?f<< tests/harness.fs
+?f<< drv/ramdrive.fs
+\ requires sys/scratch
+testbegin
+\ Tests for drv/ramdrive
+fatfs( to ramdrv(
+0 here ramdrv@
+here $36 + 8 []>str S" FAT16 " #s=
+testend