I wanted to make CVM's forth use the Grid subsystem, but doing so would break the stage binary. Hence, this split.master
@@ -1,3 +1,4 @@ | |||||
/blkfs | /blkfs | ||||
/forth | /forth | ||||
/stage | /stage | ||||
/forth.bin |
@@ -13,22 +13,25 @@ $(BLKPACK): | |||||
$(BLKUNPACK): $(BLKPACK) | $(BLKUNPACK): $(BLKPACK) | ||||
stage: stage.c $(OBJS) blkfs | stage: stage.c $(OBJS) blkfs | ||||
$(CC) -DBLKFS_PATH=\"`pwd`/blkfs\" stage.c $(OBJS) -o $@ | |||||
$(CC) -DFBIN_PATH=\"`pwd`/stage.bin\" -DBLKFS_PATH=\"`pwd`/blkfs\" stage.c $(OBJS) -o $@ | |||||
blkfs: $(BLKPACK) | blkfs: $(BLKPACK) | ||||
$(BLKPACK) ../blk > $@ | $(BLKPACK) ../blk > $@ | ||||
forth: forth.c $(OBJS) | |||||
$(CC) -DBLKFS_PATH=\"`pwd`/blkfs\" forth.c $(OBJS) -lcurses -o $@ | |||||
forth.bin: stage common.fs forth.fs blkfs | |||||
cat common.fs forth.fs | ./stage > $@ | |||||
forth: forth.c $(OBJS) forth.bin | |||||
$(CC) -DFBIN_PATH=\"`pwd`/forth.bin\" -DBLKFS_PATH=\"`pwd`/blkfs\" forth.c $(OBJS) -lcurses -o $@ | |||||
vm.o: vm.c blkfs | vm.o: vm.c blkfs | ||||
$(CC) -DFBIN_PATH=\"`pwd`/forth.bin\" -c -o vm.o vm.c | |||||
$(CC) -c -o vm.o vm.c | |||||
.PHONY: updatebootstrap | .PHONY: updatebootstrap | ||||
updatebootstrap: stage xcomp.fs pack | |||||
./stage < xcomp.fs > new.bin | |||||
mv new.bin forth.bin | |||||
updatebootstrap: stage common.fs stage.fs pack | |||||
cat common.fs stage.fs | ./stage > new.bin | |||||
mv new.bin stage.bin | |||||
.PHONY: pack | .PHONY: pack | ||||
pack: | pack: | ||||
@@ -40,4 +43,4 @@ unpack: | |||||
.PHONY: clean | .PHONY: clean | ||||
clean: | clean: | ||||
rm -f $(TARGETS) *.o blkfs | |||||
rm -f $(TARGETS) *.o forth.bin blkfs |
@@ -13,11 +13,12 @@ Running `make` will yield `forth` and `stage` executables. | |||||
## Usage | ## Usage | ||||
To play around Collapse OS, you'll want to run `./forth`. Type `0 LIST` for | |||||
help. | |||||
To play around Collapse OS, you'll want to run `./forth`. Refer to | |||||
`doc/intro.txt` for help. | |||||
The program is a curses interface with a limited, fixed size so that it can | The program is a curses interface with a limited, fixed size so that it can | ||||
provide a AT-XY interface. | |||||
provide a AT-XY interface. If you wish to change the size of that screen, you | |||||
need to modify COLS and LINES in both `forth.c` and `forth.fs`. | |||||
You can get a REPL by launching the program with [`rlwrap(1)`][rlwrap] like | You can get a REPL by launching the program with [`rlwrap(1)`][rlwrap] like | ||||
this: | this: | ||||
@@ -29,7 +30,7 @@ this: | |||||
If the `forth` executable works badly (hangs, spew garbage, etc.), | If the `forth` executable works badly (hangs, spew garbage, etc.), | ||||
it's probably because you've broken your bootstrap binary. It's easy to | it's probably because you've broken your bootstrap binary. It's easy to | ||||
mistakenly break. To verify if you've done that, look at your git status. If | mistakenly break. To verify if you've done that, look at your git status. If | ||||
`forth.bin` is modified, try resetting it and then run `make clean all`. Things | |||||
`stage.bin` is modified, try resetting it and then run `make clean all`. Things | |||||
should go better afterwards. | should go better afterwards. | ||||
A modified `blkfs` can also break things (although even with a completely broken | A modified `blkfs` can also break things (although even with a completely broken | ||||
@@ -40,7 +41,6 @@ If that doesn't work, there's also the nuclear option of `git reset --hard` | |||||
and `git clean -fxd`. | and `git clean -fxd`. | ||||
If that still doesn't work, it might be because the current commit you're on | If that still doesn't work, it might be because the current commit you're on | ||||
is broken, but that is rather rare: the repo on Github is plugged on Travis | |||||
and it checks that everything is smooth. | |||||
is broken, but that is rather rare. | |||||
[rlwrap]: https://linux.die.net/man/1/rlwrap | [rlwrap]: https://linux.die.net/man/1/rlwrap |
@@ -1,3 +1,5 @@ | |||||
( This is xcomp code that is common to both stage and forth | |||||
binaries. ) | |||||
0xff00 CONSTANT RS_ADDR | 0xff00 CONSTANT RS_ADDR | ||||
0xfffa CONSTANT PS_ADDR | 0xfffa CONSTANT PS_ADDR | ||||
RS_ADDR 0x80 - CONSTANT SYSVARS | RS_ADDR 0x80 - CONSTANT SYSVARS | ||||
@@ -71,7 +73,6 @@ H@ 4 + XCURRENT ! ( make next CODE have 0 prev field ) | |||||
0x37 CODE TICKS | 0x37 CODE TICKS | ||||
0x38 CODE ROT> | 0x38 CODE ROT> | ||||
353 LOAD ( xcomp core ) | 353 LOAD ( xcomp core ) | ||||
: (emit) 0 PC! ; | |||||
: (key) 0 PC@ ; | : (key) 0 PC@ ; | ||||
: EFS@ | : EFS@ | ||||
1 3 PC! ( read ) | 1 3 PC! ( read ) | ||||
@@ -83,16 +84,4 @@ H@ 4 + XCURRENT ! ( make next CODE have 0 prev field ) | |||||
256 /MOD 3 PC! 3 PC! ( blkid ) | 256 /MOD 3 PC! 3 PC! ( blkid ) | ||||
BLK( 256 /MOD 3 PC! 3 PC! ( dest ) | BLK( 256 /MOD 3 PC! 3 PC! ( dest ) | ||||
; | ; | ||||
: COLS 80 ; : LINES 32 ; | |||||
: AT-XY 6 PC! ( y ) 5 PC! ( x ) ; | |||||
390 LOAD ( xcomp core high ) | |||||
(entry) _ | |||||
( Update LATEST ) | |||||
PC ORG @ 8 + ! | |||||
," BLK$ " | |||||
," ' EFS@ BLK@* ! " | |||||
," ' EFS! BLK!* ! " | |||||
EOT, | |||||
ORG @ 256 /MOD 2 PC! 2 PC! | |||||
H@ 256 /MOD 2 PC! 2 PC! | |||||
( fork between stage and forth begins here ) |
@@ -8,6 +8,9 @@ | |||||
#ifndef BLKFS_PATH | #ifndef BLKFS_PATH | ||||
#error BLKFS_PATH needed | #error BLKFS_PATH needed | ||||
#endif | #endif | ||||
#ifndef FBIN_PATH | |||||
#error FBIN_PATH needed | |||||
#endif | |||||
#define WCOLS 80 | #define WCOLS 80 | ||||
#define WLINES 32 | #define WLINES 32 | ||||
#define STDIO_PORT 0x00 | #define STDIO_PORT 0x00 | ||||
@@ -77,7 +80,7 @@ static void iowr_sety(uint8_t val) | |||||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
{ | { | ||||
VM *vm = VM_init(BLKFS_PATH); | |||||
VM *vm = VM_init(FBIN_PATH, BLKFS_PATH); | |||||
if (!vm) { | if (!vm) { | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -0,0 +1,15 @@ | |||||
: (emit) 0 PC! ; | |||||
: COLS 80 ; : LINES 32 ; | |||||
: AT-XY 6 PC! ( y ) 5 PC! ( x ) ; | |||||
390 LOAD ( xcomp core high ) | |||||
(entry) _ | |||||
( Update LATEST ) | |||||
PC ORG @ 8 + ! | |||||
," BLK$ " | |||||
," ' EFS@ BLK@* ! " | |||||
," ' EFS! BLK!* ! " | |||||
EOT, | |||||
ORG @ 256 /MOD 2 PC! 2 PC! | |||||
H@ 256 /MOD 2 PC! 2 PC! | |||||
@@ -6,6 +6,9 @@ | |||||
#ifndef BLKFS_PATH | #ifndef BLKFS_PATH | ||||
#error BLKFS_PATH needed | #error BLKFS_PATH needed | ||||
#endif | #endif | ||||
#ifndef FBIN_PATH | |||||
#error FBIN_PATH needed | |||||
#endif | |||||
#define RAMSTART 0 | #define RAMSTART 0 | ||||
#define STDIO_PORT 0x00 | #define STDIO_PORT 0x00 | ||||
// To know which part of RAM to dump, we listen to port 2, which at the end of | // To know which part of RAM to dump, we listen to port 2, which at the end of | ||||
@@ -45,9 +48,9 @@ static void iowr_here(uint8_t val) | |||||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
{ | { | ||||
if (argc < 2) { | if (argc < 2) { | ||||
vm = VM_init(BLKFS_PATH); | |||||
vm = VM_init(FBIN_PATH, BLKFS_PATH); | |||||
} else { | } else { | ||||
vm = VM_init(argv[1]); | |||||
vm = VM_init(FBIN_PATH, argv[1]); | |||||
} | } | ||||
if (vm == NULL) { | if (vm == NULL) { | ||||
return 1; | return 1; | ||||
@@ -0,0 +1,11 @@ | |||||
: (emit) 0 PC! ; | |||||
390 LOAD ( xcomp core high ) | |||||
(entry) _ | |||||
( Update LATEST ) | |||||
PC ORG @ 8 + ! | |||||
," BLK$ " | |||||
," ' EFS@ BLK@* ! " | |||||
," ' EFS! BLK!* ! " | |||||
EOT, | |||||
ORG @ 256 /MOD 2 PC! 2 PC! | |||||
H@ 256 /MOD 2 PC! 2 PC! |
@@ -12,10 +12,6 @@ | |||||
// 5 - dest addr LSB | // 5 - dest addr LSB | ||||
#define BLK_PORT 0x03 | #define BLK_PORT 0x03 | ||||
#ifndef FBIN_PATH | |||||
#error FBIN_PATH needed | |||||
#endif | |||||
static VM vm; | static VM vm; | ||||
static uint64_t blkop = 0; // 5 bytes | static uint64_t blkop = 0; // 5 bytes | ||||
static FILE *blkfp; | static FILE *blkfp; | ||||
@@ -295,7 +291,8 @@ static void native(NativeWord func) { | |||||
vm.nativew[vm.nativew_count++] = func; | vm.nativew[vm.nativew_count++] = func; | ||||
} | } | ||||
VM* VM_init(char *blkfs_path) { | |||||
VM* VM_init(char *bin_path, char *blkfs_path) | |||||
{ | |||||
fprintf(stderr, "Using blkfs %s\n", blkfs_path); | fprintf(stderr, "Using blkfs %s\n", blkfs_path); | ||||
blkfp = fopen(blkfs_path, "r+"); | blkfp = fopen(blkfs_path, "r+"); | ||||
if (!blkfp) { | if (!blkfp) { | ||||
@@ -309,7 +306,7 @@ VM* VM_init(char *blkfs_path) { | |||||
return NULL; | return NULL; | ||||
} | } | ||||
fseek(blkfp, 0, SEEK_SET); | fseek(blkfp, 0, SEEK_SET); | ||||
FILE *bfp = fopen(FBIN_PATH, "r"); | |||||
FILE *bfp = fopen(bin_path, "r"); | |||||
if (!bfp) { | if (!bfp) { | ||||
fprintf(stderr, "Can't open forth.bin\n"); | fprintf(stderr, "Can't open forth.bin\n"); | ||||
return NULL; | return NULL; | ||||
@@ -47,7 +47,7 @@ typedef struct { | |||||
bool oflw; | bool oflw; | ||||
} VM; | } VM; | ||||
VM* VM_init(char *blkfs_path); | |||||
VM* VM_init(char *bin_path, char *blkfs_path); | |||||
void VM_deinit(); | void VM_deinit(); | ||||
bool VM_steps(int n); | bool VM_steps(int n); | ||||
void VM_memdump(); | void VM_memdump(); | ||||
@@ -4,8 +4,8 @@ git clean -fxd | |||||
make -C tests | make -C tests | ||||
# verify that forth.bin is stable | |||||
cp cvm/forth.bin ref.bin | |||||
# verify that stage.bin is stable | |||||
cp cvm/stage.bin ref.bin | |||||
make -C cvm updatebootstrap | make -C cvm updatebootstrap | ||||
cmp cvm/forth.bin ref.bin | |||||
cmp cvm/stage.bin ref.bin | |||||
rm ref.bin | rm ref.bin |