recipes/rc2014/sdcard: mount filesystem!

This commit is contained in:
Virgil Dupras 2019-05-28 13:13:34 -04:00
parent 312e95479e
commit 6b1679c811
5 changed files with 79 additions and 19 deletions

1
recipes/rc2014/sdcard/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
cfsin/helo

View File

@ -1,4 +1,4 @@
TARGETS = os.bin
TARGETS = os.bin cfsin/helo
TOOLS = ../../../tools
ZASM = $(TOOLS)/emul/zasm/zasm
CFSPACK = $(TOOLS)/cfspack/cfspack
@ -6,6 +6,7 @@ CFSPACK = $(TOOLS)/cfspack/cfspack
.PHONY: all
all: $(TARGETS) sdcard.cfs
os.bin: glue.asm
cfsin/helo: helo.asm
$(TARGETS):
$(ZASM) < $< > $@

View File

@ -98,5 +98,35 @@ you're ready to load your contents with `load d` (load the 13 bytes that you
wrote to your sd card earlier. You can then `peek d` and see that your
"Hello World!\n" got loaded in memory!
## Mounting a filesystem from the SD card
The Makefile compiles `helo.asm` in `cfsin` and then packs `cfsin` into a CFS
filesystem into the `sdcard.cfs` file. That can be mounted by Collapse OS!
$ cat sdcard.cfs > /dev/sdX
Then, you insert your SD card in your SPI relay and go:
Collapse OS
> mptr 9000
9000
> sdci
> bsel 1
> fson
> fls
helo
hello.txt
> fopn 0 helo
> load 10
> peek 10
210690C3030048656C6C6F210D0A0000
> call 00 0000
Hello!
>
Now let that sink in for a minute. You've just mounted a filesystem on a SD
card, loaded a file from it in memory and executed that file, all that on a
kernel that weights less than 3 kilobytes!
[schematic]: spirelay/spirelay.pdf
[inspiration]: https://www.ecstaticlyrics.com/electronics/SPI/fast_z80_interface.html

View File

@ -5,20 +5,14 @@
.equ ACIA_CTL 0x80 ; Control and status. RS off.
.equ ACIA_IO 0x81 ; Transmit. RS on.
jp init
jp init ; 3 bytes
; *** JUMP TABLE ***
; Why not use this unused space between 0x03 and 0x38 for a jump table?
jp printstr
jp printHex
jp sdcInitialize
jp sdcSendRecv
jp sdcWaitResp
jp sdcCmd
jp sdcCmdR1
jp sdcCmdR7
jp sdcReadBlk
jp sdcSetBlkSize
; *** Jump Table ***
jp printstr
jp fsOpen
jp fsSeek
jp fsTell
jp fsGetC
; interrupt hook
.fill 0x38-$
@ -29,21 +23,28 @@ jp aciaInt
.equ ACIA_RAMSTART RAMSTART
#include "acia.asm"
.equ BLOCKDEV_RAMSTART ACIA_RAMEND
.equ BLOCKDEV_COUNT 2
.equ BLOCKDEV_COUNT 3
#include "blockdev.asm"
; List of devices
.dw aciaGetC, aciaPutC, 0, 0
.dw sdcGetC, 0, 0, 0
.dw sdcGetC, 0, sdcSeek, sdcTell
.dw blk2GetC, blk2PutC, blk2Seek, blk2Tell
#include "blockdev_cmds.asm"
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
#include "stdio.asm"
.equ SHELL_RAMSTART STDIO_RAMEND
.equ SHELL_EXTRA_CMD_COUNT 4
.equ FS_RAMSTART STDIO_RAMEND
.equ FS_HANDLE_COUNT 1
#include "fs.asm"
#include "fs_cmds.asm"
.equ SHELL_RAMSTART FS_RAMEND
.equ SHELL_EXTRA_CMD_COUNT 8
#include "shell.asm"
.dw sdcInitializeCmd, blkBselCmd, blkSeekCmd, sdcInitializeCmd
.dw sdcInitializeCmd, blkBselCmd, blkSeekCmd
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
.equ SDC_RAMSTART SHELL_RAMEND
.equ SDC_PORT_CSHIGH 6
@ -67,3 +68,20 @@ init:
ei
jp shellLoop
; *** blkdev 2: file handle 0 ***
blk2GetC:
ld de, FS_HANDLES
jp fsGetC
blk2PutC:
ld de, FS_HANDLES
jp fsPutC
blk2Seek:
ld de, FS_HANDLES
jp fsSeek
blk2Tell:
ld de, FS_HANDLES
jp fsTell

View File

@ -0,0 +1,10 @@
; prints "Hello!" on screen
.equ printstr 0x03
.org 0x9000
ld hl, sHello
jp printstr ; return
sHello:
.db "Hello!", 0x0d, 0x0a, 0