duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit bf64567e2fb0e616a17ece781e92f1a099607145
parent 143213085e61761669a8b2ec0fe97cd658f28771
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed,  5 Jul 2023 11:32:29 -0400

posix: optionally use mcopy instead of Dusk's FAT tools if present

This makes PC and RPi builds much, much, much faster.

Diffstat:
MMakefile | 6++++++
MREADME.md | 7+++++++
Mbuildpc.fs | 2+-
Mbuildrpi.fs | 2+-
Mfs/xcomp/tools.fs | 13++++++++-----
Asyncfs.fs | 7+++++++
6 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -3,6 +3,10 @@ BOOTFS_SRC = fs/xcomp/bootlo.fs posix/glue.fs fs/xcomp/boothi.fs ALLSRCS = $(shell find fs) QEMU_FLAGS = -accel kvm -accel tcg -rtc base=utc QEMU_DRVOPTS = format=raw,index=0,if=ide +SYNCFS_CMD = if command -v mcopy; then \ + rm fs/init.fs; mcopy -sQ -i $@ fs/* :: ; $(MAKE) fs/init.fs; else \ + echo "mtools not installed, using Dusk's FAT tools"; \ + echo 'S" $@"' | cat - syncfs.fs | ./dusk; fi all: $(TARGETS) fs/init.fs: posix/init.fs fs/xcomp/init.fs @@ -20,6 +24,7 @@ dis: posix/dis.c pc.img: dusk $(ALLSRCS) dd if=/dev/zero of=$@ bs=512 count=2880 ./dusk < buildpc.fs + $(SYNCFS_CMD) .PHONY: pcrun pcrun: pc.img @@ -45,6 +50,7 @@ rpifat.img: dusk $(ALLSRCS) # also builds rpikernel.img dd if=/dev/zero of=$@ bs=1K count=2048 touch rpikernel.img ./dusk < buildrpi.fs + $(SYNCFS_CMD) # To quit, you have to first drop to QEMU monitor through CTRL+A then 'c', and # then type "quit" (or use QEMU's monitor for debugging). diff --git a/README.md b/README.md @@ -53,6 +53,12 @@ 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][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`. @@ -96,3 +102,4 @@ Press Escape to return to prompt. You can try the same thing with: [docs]: fs/doc/index.txt [duskcc]: fs/doc/cc/index.txt [varvara]: https://wiki.xxiivv.com/site/varvara.html +[mtools]: https://www.gnu.org/software/mtools/ diff --git a/buildpc.fs b/buildpc.fs @@ -2,7 +2,7 @@ f<< /xcomp/i386/pc/build.fs S" pc.img" mountImage ( drv ) value mydrv -mydrv 2796 setupFAT value myfat +mydrv 2796 createFAT value myfat mydrv setupMBR mydrv DriveFile :new $200 over File :seek spitBoot S" /xcomp/i386/pc/init.fs" S" /xcomp/init.fs" myfat combineInit diff --git a/buildrpi.fs b/buildrpi.fs @@ -5,6 +5,6 @@ S" rpikernel.img" mountImage ( drv ) const mydrv mydrv DriveFile :new spitBoot S" rpifat.img" mountImage ( drv ) const mydrv -mydrv 2796 setupFAT value myfat +mydrv 2796 createFAT value myfat S" /xcomp/arm/rpi/init.fs" S" /xcomp/init.fs" myfat combineInit bye diff --git a/fs/xcomp/tools.fs b/fs/xcomp/tools.fs @@ -54,11 +54,14 @@ LF value _last \ $00 to fatopts drvnum ( drv ) dup FAT newFAT12 FAT :mountvolume ; -: copyfs ( srcfs dstfs -- ) 0 Path :new swap 0 Path :new Path :copydir ; - -: setupFAT ( drv clustercnt -- fat ) - ." creating FAT and copying files\n" - createFAT bootfs :self over copyfs ; +\ Like Path :copydir, but doesn't copy files (init.fs) at the root +: copyfs ( srcfs dstfs -- ) + 0 Path :new swap 0 Path :new >r >r \ V1=src V2=dst + V1 Path :iter + Path :i Path :info dup FSInfo dir? if ( info ) + V2 Path id swap FSInfo name V2 Path fs Filesystem :?newdir ( id ) + V2 Path fs swap Path :new Path :i Path :copydir then + next 2rdrop ; : spitfile ( fpath dst -- ) >r curpath :find# Path :open begin ( fc ) diff --git a/syncfs.fs b/syncfs.fs @@ -0,0 +1,7 @@ +\ expects an image name in PS top with an already created FAT in it +f<< /xcomp/tools.fs + +( imgname ) mountImage ( drv ) value mydrv +mydrv FAT :mountvolume value myfat +bootfs :self myfat copyfs +bye