@@ -14,24 +14,12 @@ $(BLKPACK): | |||||
$(BIN2C): $(BLKPACK) | $(BIN2C): $(BLKPACK) | ||||
$(BLKUNPACK): $(BLKPACK) | $(BLKUNPACK): $(BLKPACK) | ||||
stage0.bin: stage2 xcomp.fs | |||||
cat xcomp.fs | ./stage2 > stage0.bin | |||||
stage0-bin.h: stage0.bin $(BIN2C) | |||||
$(BIN2C) KERNEL < stage0.bin > $@ | |||||
stage1: stage.c $(OBJS) stage0-bin.h | |||||
$(CC) stage.c $(OBJS) -o $@ | |||||
stage1dbg: stage.c $(OBJS) stage0-bin.h | |||||
$(CC) -DDEBUG stage.c $(OBJS) -o $@ | |||||
# not dependent on forth.bin to avoid circular deps. | # not dependent on forth.bin to avoid circular deps. | ||||
forth-bin.h: $(BIN2C) | forth-bin.h: $(BIN2C) | ||||
$(BIN2C) KERNEL < forth.bin > $@ | $(BIN2C) KERNEL < forth.bin > $@ | ||||
stage2: stage.c $(OBJS) forth-bin.h blkfs-bin.h | stage2: stage.c $(OBJS) forth-bin.h blkfs-bin.h | ||||
$(CC) -DSTAGE2 stage.c $(OBJS) -o $@ | |||||
$(CC) stage.c $(OBJS) -o $@ | |||||
blkfs: $(BLKPACK) | blkfs: $(BLKPACK) | ||||
$(BLKPACK) ../blk > $@ | $(BLKPACK) ../blk > $@ | ||||
@@ -51,8 +39,8 @@ emul.o: emul.c | |||||
.PHONY: updatebootstrap | .PHONY: updatebootstrap | ||||
updatebootstrap: stage1 stage1.fs | |||||
./stage1 < stage1.fs > forth.bin | |||||
updatebootstrap: stage2 xcomp.fs | |||||
./stage2 < xcomp.fs > forth.bin | |||||
.PHONY: pack | .PHONY: pack | ||||
pack: | pack: | ||||
@@ -2,12 +2,8 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "emul.h" | #include "emul.h" | ||||
#ifdef STAGE2 | |||||
#include "forth-bin.h" | #include "forth-bin.h" | ||||
#include "blkfs-bin.h" | #include "blkfs-bin.h" | ||||
#else | |||||
#include "stage0-bin.h" | |||||
#endif | |||||
/* Staging binaries | /* Staging binaries | ||||
@@ -74,7 +70,6 @@ static void iowr_here(uint8_t val) | |||||
end_here |= val; | end_here |= val; | ||||
} | } | ||||
#ifdef STAGE2 | |||||
static void iowr_blk(uint8_t val) | static void iowr_blk(uint8_t val) | ||||
{ | { | ||||
blkid <<= 8; | blkid <<= 8; | ||||
@@ -86,7 +81,6 @@ static uint8_t iord_blkdata() | |||||
{ | { | ||||
return BLKFS[blkpos++]; | return BLKFS[blkpos++]; | ||||
} | } | ||||
#endif | |||||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
{ | { | ||||
@@ -95,10 +89,8 @@ int main(int argc, char *argv[]) | |||||
m->iord[STDIO_PORT] = iord_stdio; | m->iord[STDIO_PORT] = iord_stdio; | ||||
m->iowr[STDIO_PORT] = iowr_stdio; | m->iowr[STDIO_PORT] = iowr_stdio; | ||||
m->iowr[HERE_PORT] = iowr_here; | m->iowr[HERE_PORT] = iowr_here; | ||||
#ifdef STAGE2 | |||||
m->iowr[BLK_PORT] = iowr_blk; | m->iowr[BLK_PORT] = iowr_blk; | ||||
m->iord[BLKDATA_PORT] = iord_blkdata; | m->iord[BLKDATA_PORT] = iord_blkdata; | ||||
#endif | |||||
// initialize memory | // initialize memory | ||||
for (int i=0; i<sizeof(KERNEL); i++) { | for (int i=0; i<sizeof(KERNEL); i++) { | ||||
m->mem[i] = KERNEL[i]; | m->mem[i] = KERNEL[i]; | ||||
@@ -1,28 +0,0 @@ | |||||
: EFS@ | |||||
256 /MOD 3 PC! 3 PC! | |||||
1024 0 DO | |||||
4 PC@ | |||||
BLK( I + C! | |||||
LOOP | |||||
; | |||||
: EFS! | |||||
256 /MOD 3 PC! 3 PC! | |||||
1024 0 DO | |||||
BLK( I + C@ 4 PC! | |||||
LOOP | |||||
; | |||||
: INIT | |||||
CURRENT @ HERE ! | |||||
BLK$ | |||||
['] EFS@ BLK@* ! | |||||
['] EFS! BLK!* ! | |||||
RDLN$ | |||||
LIT< _sys [entry] | |||||
." Collapse OS" NL | |||||
; | |||||
(entry) _ | |||||
H@ 0x08 BIN+ ! ( update LATEST ) | |||||
," INIT " | |||||
H@ 256 /MOD 2 PC! 2 PC! |
@@ -9,11 +9,32 @@ | |||||
393 LOAD ( xcomp core low ) | 393 LOAD ( xcomp core low ) | ||||
: (emit) 0 PC! ; | : (emit) 0 PC! ; | ||||
: (key) 0 PC@ ; | : (key) 0 PC@ ; | ||||
: EFS@ | |||||
256 /MOD 3 PC! 3 PC! | |||||
1024 0 DO | |||||
4 PC@ | |||||
BLK( I + C! | |||||
LOOP | |||||
; | |||||
: EFS! | |||||
256 /MOD 3 PC! 3 PC! | |||||
1024 0 DO | |||||
BLK( I + C@ 4 PC! | |||||
LOOP | |||||
; | |||||
420 LOAD ( xcomp core high ) | 420 LOAD ( xcomp core high ) | ||||
(entry) _ | (entry) _ | ||||
( Update LATEST ) | ( Update LATEST ) | ||||
PC ORG @ 8 + ! | PC ORG @ 8 + ! | ||||
," CURRENT @ HERE ! " | ," CURRENT @ HERE ! " | ||||
," ' (key) 12 RAM+ ! " | |||||
," : INIT " | |||||
," BLK$ " | |||||
," ['] EFS@ BLK@* ! " | |||||
," ['] EFS! BLK!* ! " | |||||
," RDLN$ " | |||||
," LIT< _sys [entry] " | |||||
," LIT< CollapseOS (print) NL " | |||||
," ; INIT " | |||||
ORG @ 256 /MOD 2 PC! 2 PC! | ORG @ 256 /MOD 2 PC! 2 PC! | ||||
H@ 256 /MOD 2 PC! 2 PC! | H@ 256 /MOD 2 PC! 2 PC! |