mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:48:06 +11:00
Remove recipes/rc2014/zasm
That becomes irrelevant in Forth
This commit is contained in:
parent
44403c3d4c
commit
f19a5e1f71
2
recipes/rc2014/zasm/.gitignore
vendored
2
recipes/rc2014/zasm/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
/cfsin/zasm
|
|
||||||
/cfsin/user.h
|
|
@ -1,30 +0,0 @@
|
|||||||
SHELLAPPS = zasm sdct memt at28w
|
|
||||||
APPTARGETS = ${SHELLAPPS:%=cfsin/%}
|
|
||||||
CFSTARGETS = $(APPTARGETS) cfsin/user.h
|
|
||||||
BASEDIR = ../../..
|
|
||||||
ZASM = $(BASEDIR)/emul/zasm/zasm
|
|
||||||
KERNEL = $(BASEDIR)/kernel
|
|
||||||
APPS = $(BASEDIR)/apps
|
|
||||||
CFSPACK = $(BASEDIR)/tools/cfspack/cfspack
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: os.bin sdcard.cfs
|
|
||||||
|
|
||||||
os.bin: glue.asm
|
|
||||||
$(ZASM) $(KERNEL) $(APPS) < glue.asm > $@
|
|
||||||
|
|
||||||
$(CFSPACK):
|
|
||||||
make -C $(BASEDIR)/tools/cfspack
|
|
||||||
|
|
||||||
sdcard.cfs: $(CFSTARGETS) $(CFSPACK)
|
|
||||||
$(CFSPACK) cfsin > $@
|
|
||||||
|
|
||||||
$(APPTARGETS): $(ZASMBIN)
|
|
||||||
$(ZASM) $(KERNEL) $(APPS) user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@
|
|
||||||
|
|
||||||
cfsin/user.h: user.h
|
|
||||||
cp user.h $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f $(CFSTARGETS) sdcard.cfs os.bin
|
|
@ -1,109 +0,0 @@
|
|||||||
# Assembling binaries
|
|
||||||
|
|
||||||
For a system to be able to self-reproduce, it needs to assemble source z80
|
|
||||||
assembly to binary.
|
|
||||||
|
|
||||||
## Goals
|
|
||||||
|
|
||||||
Have a RC2014 assemble a Collapse OS kernel with its source living on a CFS on
|
|
||||||
a SD card.
|
|
||||||
|
|
||||||
## Gathering parts
|
|
||||||
|
|
||||||
* Same parts as the [SD card recipe](../sdcard).
|
|
||||||
|
|
||||||
## The zasm binary
|
|
||||||
|
|
||||||
To achieve our goal in this recipe, we'll need a zasm binary on the SD card.
|
|
||||||
This zasm binary needs to be compiled with the right jump offsets for the kernel
|
|
||||||
we build in this recipe. These offsets are in `user.h` and are closely in sync
|
|
||||||
with the configuration in `glue.asm`.
|
|
||||||
|
|
||||||
`user.h` is then included in `apps/zasm/glue.asm`.
|
|
||||||
|
|
||||||
The makefile in this recipe takes care of compiling zasm with the proper
|
|
||||||
`user.h` file and place it in `cfsin/zasm`
|
|
||||||
|
|
||||||
## The userland source
|
|
||||||
|
|
||||||
The code we're going to compile is `cfsin/hello.asm`. As you can see, we also
|
|
||||||
include `user.h` in this source code or else `ld hl, sAwesome` would load the
|
|
||||||
wrong offset.
|
|
||||||
|
|
||||||
Because of this, the Makefile takes care of copying `user.h` in our filesystem.
|
|
||||||
|
|
||||||
## Preparing the card and kernel
|
|
||||||
|
|
||||||
After running `make`, you'll end up with `sdcard.cfs` which you can load the
|
|
||||||
same way you did in the SD card recipe.
|
|
||||||
|
|
||||||
You will also have `os.bin`, which you can flash on your EEPROM the same way
|
|
||||||
you already did before.
|
|
||||||
|
|
||||||
## Running it
|
|
||||||
|
|
||||||
Compiling and running `hello.asm` is done very much like in
|
|
||||||
[the shell emulator](../../../doc/zasm.md):
|
|
||||||
|
|
||||||
Collapse OS
|
|
||||||
> sdci
|
|
||||||
> fson
|
|
||||||
> fopen 0 hello.asm
|
|
||||||
> fnew 1 dest
|
|
||||||
> fopen 1 dest
|
|
||||||
> zasm 1 2
|
|
||||||
> dest
|
|
||||||
Assembled from a RC2014
|
|
||||||
>
|
|
||||||
|
|
||||||
That RC2014 is starting to feel powerful now, right?
|
|
||||||
|
|
||||||
## Test your hardware
|
|
||||||
|
|
||||||
Now that you have a fully functional filesystem that can load programs and run
|
|
||||||
them easily, you'll see that this recipe's CFS include a couple of programs
|
|
||||||
besides `zasm`. Among them, there's `sdct` that stress tests reading and
|
|
||||||
writing on the SD card and `memt` that stress tests RAM. You might be
|
|
||||||
interested in running them. Look at their description in `apps/`. All you need
|
|
||||||
to to do run them is to type their name.
|
|
||||||
|
|
||||||
## Assembling the kernel
|
|
||||||
|
|
||||||
Now let's go for something a little more fun! Jiu-jitsu? No, you're not going to
|
|
||||||
learn jiu-jitsu! You're going to assemble the kernel from within your RC2014!
|
|
||||||
|
|
||||||
The makefile doesn't prepare a CFS blob for this, let's learn to build that blob
|
|
||||||
yourself. First of all, we'll need to have what we already had in `sdcard.cfs`
|
|
||||||
because it has `zasm` and `user.h`. But we're going to add the contents of
|
|
||||||
the `/kernel/` directory to it.
|
|
||||||
|
|
||||||
$ cp ../../../kernel/*.{h,asm} cfsin
|
|
||||||
|
|
||||||
You'll also need your glue file:
|
|
||||||
|
|
||||||
$ cp glue.asm cfsin
|
|
||||||
|
|
||||||
You're now ready to re-make your CFS:
|
|
||||||
|
|
||||||
$ rm sdcard.cfs && make
|
|
||||||
|
|
||||||
Now you can write this into your card and boot Collapse OS:
|
|
||||||
|
|
||||||
Collapse OS
|
|
||||||
> sdci
|
|
||||||
> fson
|
|
||||||
> fopn 0 glue.asm
|
|
||||||
> fnew 10 dest
|
|
||||||
> fopen 1 dest
|
|
||||||
> zasm 1 2 # This takes a while. About 7 minutes.
|
|
||||||
> sdcf # success! sdcf flushes SD card buffers to the card.
|
|
||||||
|
|
||||||
Now let's go verify that we assembled the right thing. Pop out the card and
|
|
||||||
plug it in your "modern" computer. Pipe the device directly through `cfsunpack`
|
|
||||||
to unpack the FS into a directory (it will stop reading when it stops seeing
|
|
||||||
CFS blocks):
|
|
||||||
|
|
||||||
$ sudo cat /dev/sdX | ../../../tools/cfspack/cfsunpack cfsout
|
|
||||||
$ cmp cfsout/dest ../os.bin
|
|
||||||
|
|
||||||
They're the same! Your RC2014 assembled a full Collapse OS kernel all by itself!
|
|
@ -1,10 +0,0 @@
|
|||||||
.inc "user.h"
|
|
||||||
|
|
||||||
ld hl, sAwesome
|
|
||||||
call printstr
|
|
||||||
xor a ; success
|
|
||||||
ret
|
|
||||||
|
|
||||||
sAwesome:
|
|
||||||
.db "Assembled from a RC2014", 0x0d, 0x0a, 0
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
|||||||
; classic RC2014 setup (8K ROM + 32K RAM) and a stock Serial I/O module
|
|
||||||
; The RAM module is selected on A15, so it has the range 0x8000-0xffff
|
|
||||||
.equ RAMSTART 0x8000
|
|
||||||
; Kernel RAMEND last check: 0x9933
|
|
||||||
; We allocate at least 0x100 bytes for the stack, which is why we have this
|
|
||||||
; threshold.
|
|
||||||
.equ RAMEND 0x9b00
|
|
||||||
.equ USER_CODE RAMEND ; in sync with user.h
|
|
||||||
.equ ACIA_CTL 0x80 ; Control and status. RS off.
|
|
||||||
.equ ACIA_IO 0x81 ; Transmit. RS on.
|
|
||||||
|
|
||||||
jp init ; 3 bytes
|
|
||||||
|
|
||||||
; *** Jump Table ***
|
|
||||||
jp strncmp
|
|
||||||
jp upcase
|
|
||||||
jp findchar
|
|
||||||
jp blkSel
|
|
||||||
jp blkSet
|
|
||||||
jp fsFindFN
|
|
||||||
jp fsOpen
|
|
||||||
jp fsGetB
|
|
||||||
jp printstr
|
|
||||||
jp printcrlf
|
|
||||||
jp _blkGetB
|
|
||||||
jp _blkPutB
|
|
||||||
jp _blkSeek
|
|
||||||
jp _blkTell
|
|
||||||
jp sdcGetB
|
|
||||||
jp sdcPutB
|
|
||||||
jp blkGetB
|
|
||||||
|
|
||||||
; interrupt hook
|
|
||||||
.fill 0x38-$
|
|
||||||
jp aciaInt
|
|
||||||
|
|
||||||
; *** cont. ***
|
|
||||||
|
|
||||||
jp stdioPutC
|
|
||||||
|
|
||||||
.inc "err.h"
|
|
||||||
.inc "ascii.h"
|
|
||||||
.inc "blkdev.h"
|
|
||||||
.inc "fs.h"
|
|
||||||
.inc "core.asm"
|
|
||||||
.inc "str.asm"
|
|
||||||
.equ ACIA_RAMSTART RAMSTART
|
|
||||||
.inc "acia.asm"
|
|
||||||
.equ BLOCKDEV_RAMSTART ACIA_RAMEND
|
|
||||||
.equ BLOCKDEV_COUNT 4
|
|
||||||
.inc "blockdev.asm"
|
|
||||||
; List of devices
|
|
||||||
.dw sdcGetB, sdcPutB
|
|
||||||
.dw blk1GetB, blk1PutB
|
|
||||||
.dw blk2GetB, blk2PutB
|
|
||||||
.dw mmapGetB, mmapPutB
|
|
||||||
|
|
||||||
|
|
||||||
.equ MMAP_START 0xe000
|
|
||||||
.inc "mmap.asm"
|
|
||||||
|
|
||||||
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
|
|
||||||
.equ STDIO_GETC aciaGetC
|
|
||||||
.equ STDIO_PUTC aciaPutC
|
|
||||||
.inc "stdio.asm"
|
|
||||||
|
|
||||||
.equ FS_RAMSTART STDIO_RAMEND
|
|
||||||
.equ FS_HANDLE_COUNT 2
|
|
||||||
.inc "fs.asm"
|
|
||||||
|
|
||||||
; *** BASIC ***
|
|
||||||
|
|
||||||
; RAM space used in different routines for short term processing.
|
|
||||||
.equ SCRATCHPAD_SIZE STDIO_BUFSIZE
|
|
||||||
.equ SCRATCHPAD FS_RAMEND
|
|
||||||
.inc "lib/util.asm"
|
|
||||||
.inc "lib/ari.asm"
|
|
||||||
.inc "lib/parse.asm"
|
|
||||||
.inc "lib/fmt.asm"
|
|
||||||
.equ EXPR_PARSE parseLiteralOrVar
|
|
||||||
.inc "lib/expr.asm"
|
|
||||||
.inc "basic/util.asm"
|
|
||||||
.inc "basic/parse.asm"
|
|
||||||
.inc "basic/tok.asm"
|
|
||||||
.equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
|
|
||||||
.inc "basic/var.asm"
|
|
||||||
.equ BUF_RAMSTART VAR_RAMEND
|
|
||||||
.inc "basic/buf.asm"
|
|
||||||
.inc "basic/blk.asm"
|
|
||||||
.inc "basic/sdc.asm"
|
|
||||||
.equ BFS_RAMSTART BUF_RAMEND
|
|
||||||
.inc "basic/fs.asm"
|
|
||||||
.equ BAS_RAMSTART BFS_RAMEND
|
|
||||||
.inc "basic/main.asm"
|
|
||||||
|
|
||||||
.equ SDC_RAMSTART BAS_RAMEND
|
|
||||||
.equ SDC_PORT_CSHIGH 6
|
|
||||||
.equ SDC_PORT_CSLOW 5
|
|
||||||
.equ SDC_PORT_SPI 4
|
|
||||||
.inc "sdc.asm"
|
|
||||||
|
|
||||||
.out SDC_RAMEND
|
|
||||||
|
|
||||||
init:
|
|
||||||
di
|
|
||||||
ld sp, RAMEND
|
|
||||||
im 1
|
|
||||||
call aciaInit
|
|
||||||
call fsInit
|
|
||||||
call basInit
|
|
||||||
ld hl, basFindCmdExtra
|
|
||||||
ld (BAS_FINDHOOK), hl
|
|
||||||
|
|
||||||
xor a
|
|
||||||
ld de, BLOCKDEV_SEL
|
|
||||||
call blkSel
|
|
||||||
|
|
||||||
ei
|
|
||||||
jp basStart
|
|
||||||
|
|
||||||
basFindCmdExtra:
|
|
||||||
ld hl, basFSCmds
|
|
||||||
call basFindCmd
|
|
||||||
ret z
|
|
||||||
ld hl, basBLKCmds
|
|
||||||
call basFindCmd
|
|
||||||
ret z
|
|
||||||
ld hl, basSDCCmds
|
|
||||||
call basFindCmd
|
|
||||||
ret z
|
|
||||||
jp basPgmHook
|
|
||||||
|
|
||||||
; *** blkdev 1: file handle 0 ***
|
|
||||||
|
|
||||||
blk1GetB:
|
|
||||||
ld ix, FS_HANDLES
|
|
||||||
jp fsGetB
|
|
||||||
|
|
||||||
blk1PutB:
|
|
||||||
ld ix, FS_HANDLES
|
|
||||||
jp fsPutB
|
|
||||||
|
|
||||||
; *** blkdev 2: file handle 1 ***
|
|
||||||
|
|
||||||
blk2GetB:
|
|
||||||
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
|
||||||
jp fsGetB
|
|
||||||
|
|
||||||
blk2PutB:
|
|
||||||
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
|
||||||
jp fsPutB
|
|
@ -1,23 +0,0 @@
|
|||||||
.org 0x9b00
|
|
||||||
|
|
||||||
; *** JUMP TABLE ***
|
|
||||||
.equ strncmp 0x03
|
|
||||||
.equ upcase @+3
|
|
||||||
.equ findchar @+3
|
|
||||||
.equ blkSel @+3
|
|
||||||
.equ blkSet @+3
|
|
||||||
.equ fsFindFN @+3
|
|
||||||
.equ fsOpen @+3
|
|
||||||
.equ fsGetB @+3
|
|
||||||
.equ printstr @+3
|
|
||||||
.equ printcrlf @+3
|
|
||||||
.equ _blkGetB @+3
|
|
||||||
.equ _blkPutB @+3
|
|
||||||
.equ _blkSeek @+3
|
|
||||||
.equ _blkTell @+3
|
|
||||||
.equ sdcGetB @+3
|
|
||||||
.equ sdcPutB @+3
|
|
||||||
.equ blkGetB @+3
|
|
||||||
|
|
||||||
; *** cont. ***
|
|
||||||
.equ stdioPutC 0x3b
|
|
Loading…
Reference in New Issue
Block a user