1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 12:18:07 +11:00

Parametrize zasm linux bin's include CFS file

... instead of embedding it in the binary itself. Additionally, add a
"zasm.sh" wrapper to faciliate zasm calls on a linux machine.
This commit is contained in:
Virgil Dupras 2019-06-02 15:50:59 -04:00
parent 37a167562c
commit 22e990ed89
11 changed files with 44 additions and 22 deletions

View File

@ -1,5 +1,5 @@
TARGET = os.bin
ZASM = ../../tools/emul/zasm/zasm
ZASM = ../../tools/zasm.sh
.PHONY: all
all: $(TARGET)

View File

@ -11,6 +11,7 @@ jp init
.fill 0x38-$
jp aciaInt
#include "err.h"
#include "core.asm"
#include "parse.asm"
.equ ACIA_RAMSTART RAMSTART

View File

@ -1,6 +1,6 @@
TARGETS = os.bin cfsin/helo
TOOLS = ../../../tools
ZASM = $(TOOLS)/emul/zasm/zasm
ZASM = $(TOOLS)/zasm.sh
CFSPACK = $(TOOLS)/cfspack/cfspack
.PHONY: all

View File

@ -1,7 +1,5 @@
# Accessing a MicroSD card
**Status: work in progress.**
SD cards are great because they are accessible directly. No supporting IC is
necessary. The easiest way to access them is through the SPI protocol.

View File

@ -20,6 +20,7 @@ jp sdcSendRecv
.fill 0x38-$
jp aciaInt
#include "err.h"
#include "core.asm"
#include "parse.asm"
.equ ACIA_RAMSTART RAMSTART

View File

@ -3,12 +3,13 @@ CFSPACK = ../cfspack/cfspack
KERNEL = ../../kernel
APPS = ../../apps
ZASMBIN = zasm/zasm
INCCFS = zasm/includes.cfs
.PHONY: all
all: $(TARGETS)
shell/kernel.h: shell/shell_.asm $(ZASMBIN)
$(ZASMBIN) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
shell/kernel.h: shell/shell_.asm $(ZASMBIN) $(INCCFS)
$(ZASMBIN) $(INCCFS) < $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
zasm/kernel.h: zasm/kernel.bin
./bin2c.sh KERNEL < $< | tee $@ > /dev/null
@ -16,7 +17,7 @@ zasm/kernel.h: zasm/kernel.bin
zasm/user.h: zasm/zasm.bin
./bin2c.sh USERSPACE < $< | tee $@ > /dev/null
zasm/includes.cfs: $(CFSPACK)
$(INCCFS): $(CFSPACK)
rm -rf zasm/includes
cp -r $(KERNEL) zasm/includes
cp -r $(APPS)/zasm zasm/includes/zasm
@ -26,11 +27,8 @@ zasm/includes.cfs: $(CFSPACK)
$(CFSPACK) zasm/includes > $@
rm -rf zasm/includes
zasm/includes.h: zasm/includes.cfs
./bin2c.sh FSDEV < $< | tee $@ > /dev/null
shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK)
$(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h
$(ZASMBIN): zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h
runbin/runbin: runbin/runbin.c libz80/libz80.o
$(TARGETS):
$(CC) $< libz80/libz80.o -o $@
@ -43,9 +41,9 @@ $(CFSPACK):
make -C ../cfspack
.PHONY: updatebootstrap
updatebootstrap: $(ZASMBIN)
$(ZASMBIN) < zasm/glue.asm > zasm/kernel.bin
$(ZASMBIN) < $(APPS)/zasm/glue.asm > zasm/zasm.bin
updatebootstrap: $(ZASMBIN) $(INCCFS)
$(ZASMBIN) $(INCCFS) < zasm/glue.asm > zasm/kernel.bin
$(ZASMBIN) $(INCCFS) < $(APPS)/zasm/glue.asm > zasm/zasm.bin
# Sometimes, when developing zasm, stuff get messed up and it's hard to unmess
# because zasm's brake-up ends up in its bootstrap bins. Sure, we can revert

View File

@ -3,12 +3,14 @@
#include "../libz80/z80.h"
#include "kernel.h"
#include "user.h"
#include "includes.h"
/* zasm reads from a specified blkdev, assemble the file and writes the result
* in another specified blkdev. In our emulator layer, we use stdin and stdout
* as those specified blkdevs.
*
* This executable takes one argument: the path to a .cfs file to use for
* includes.
*
* Because the input blkdev needs support for Seek, we buffer it in the emulator
* layer.
*
@ -152,8 +154,12 @@ static void mem_write(int unused, uint16_t addr, uint8_t val)
mem[addr] = val;
}
int main()
int main(int argc, char *argv[])
{
if (argc > 2) {
fprintf(stderr, "Too many args\n");
return 1;
}
// initialize memory
for (int i=0; i<sizeof(KERNEL); i++) {
mem[i] = KERNEL[i];
@ -161,10 +167,21 @@ int main()
for (int i=0; i<sizeof(USERSPACE); i++) {
mem[i+USER_CODE] = USERSPACE[i];
}
for (int i=0; i<sizeof(FSDEV); i++) {
fsdev[i] = FSDEV[i];
fsdev_size = 0;
if (argc == 2) {
FILE *fp = fopen(argv[1], "r");
if (fp == NULL) {
fprintf(stderr, "Can't open file %s\n", argv[1]);
return 1;
}
int c = fgetc(fp);
while (c != EOF) {
fsdev[fsdev_size] = c;
fsdev_size++;
c = fgetc(fp);
}
fclose(fp);
}
fsdev_size = sizeof(FSDEV);
// read stdin in buffer
inpt_size = 0;
inpt_ptr = 0;

View File

@ -3,7 +3,7 @@
set -e
set -o pipefail
ZASM=../../emul/zasm/zasm
ZASM=../../zasm.sh
RUNBIN=../../emul/runbin/runbin
for fn in *.asm; do

View File

@ -2,7 +2,7 @@
# no "set -e" because we test errors
ZASM=../../emul/zasm/zasm
ZASM=../../zasm.sh
chkerr() {
echo "Check that '$1' results in error $2"

View File

@ -6,7 +6,7 @@ TMPFILE=$(mktemp)
SCAS=scas
KERNEL=../../../kernel
APPS=../../../apps
ZASM=../../emul/zasm/zasm
ZASM=../../zasm.sh
ASMFILE=${APPS}/zasm/instr.asm
cmpas() {

7
tools/zasm.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# wrapper around ./emul/zasm/zasm that prepares includes CFS prior to call
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ZASMBIN="${DIR}/emul/zasm/zasm"
INCCFS="${DIR}/emul/zasm/includes.cfs"
"${ZASMBIN}" "${INCCFS}"