1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 19:38:05 +11:00

emul: stop embedding blkfs in binaries

Instead, embed absolute path to blkfs. Having to rebuild the stage
binary at every change in blkfs is getting tedious.
This commit is contained in:
Virgil Dupras 2020-05-23 09:36:10 -04:00
parent f884918d73
commit 8d3da4c0de
3 changed files with 28 additions and 22 deletions

View File

@ -1,4 +1,4 @@
TARGETS = forth stage
TARGETS = forth stage blkfs
OBJS = emul.o libz80/libz80.o
BIN2C = ../tools/bin2c
BLKPACK = ../tools/blkpack
@ -18,17 +18,14 @@ $(BLKUNPACK): $(BLKPACK)
forth-bin.h: $(BIN2C)
$(BIN2C) KERNEL < forth.bin > $@
stage: stage.c $(OBJS) forth-bin.h blkfs-bin.h
$(CC) stage.c $(OBJS) -o $@
stage: stage.c $(OBJS) forth-bin.h
$(CC) stage.c -DBLKFS_PATH=\"`pwd`/blkfs\" $(OBJS) -o $@
blkfs: $(BLKPACK)
$(BLKPACK) ../blk > $@
blkfs-bin.h: blkfs $(BIN2C)
$(BIN2C) BLKFS < blkfs > $@
forth: forth.c $(OBJS) forth-bin.h blkfs-bin.h
$(CC) forth.c $(OBJS) -lncurses -o $@
forth: forth.c $(OBJS) forth-bin.h
$(CC) forth.c -DBLKFS_PATH=\"`pwd`/blkfs\" $(OBJS) -lncurses -o $@
libz80/libz80.o: libz80/z80.c
$(MAKE) -C libz80/codegen opcodes
@ -39,7 +36,7 @@ emul.o: emul.c
.PHONY: updatebootstrap
updatebootstrap: stage xcomp.fs
updatebootstrap: stage xcomp.fs pack
./stage < xcomp.fs > forth.bin
.PHONY: pack
@ -52,5 +49,4 @@ unpack:
.PHONY: clean
clean:
rm -f $(TARGETS) emul.o *-bin.h stage{1,2}.bin blkfs
$(MAKE) -C ../tools clean
rm -f $(TARGETS) emul.o *-bin.h blkfs

View File

@ -5,7 +5,6 @@
#include <termios.h>
#include "emul.h"
#include "forth-bin.h"
#include "blkfs-bin.h"
// in sync with glue.asm
#define RAMSTART 0x900
@ -83,13 +82,15 @@ static void iowr_blkdata(uint8_t val)
int run()
{
blkfp = fopen("blkfs", "r+");
if (blkfp) {
fprintf(stderr, "Using blkfs file\n");
} else {
blkfp = fmemopen((char*)BLKFS, sizeof(BLKFS), "r");
fprintf(stderr, "Using in-memory read-only blkfs\n");
#ifdef BLKFS_PATH
fprintf(stderr, "Using blkfs %s\n", BLKFS_PATH);
blkfp = fopen(BLKFS_PATH, "r+");
if (!blkfp) {
fprintf(stderr, "Can't open\n");
}
#else
blkfp = NULL;
#endif
Machine *m = emul_init();
m->ramstart = RAMSTART;
m->iord[STDIO_PORT] = iord_stdio;

View File

@ -3,7 +3,10 @@
#include <unistd.h>
#include "emul.h"
#include "forth-bin.h"
#include "blkfs-bin.h"
#ifndef BLKFS_PATH
#error BLKFS_PATH needed
#endif
/* Staging binaries
@ -37,7 +40,7 @@ static int running;
static uint16_t start_here = 0;
static uint16_t end_here = 0;
static uint16_t blkid = 0;
static unsigned int blkpos = 0;
static FILE *blkfp;
static uint8_t iord_stdio()
{
@ -65,16 +68,22 @@ static void iowr_blk(uint8_t val)
{
blkid <<= 8;
blkid |= val;
blkpos = blkid * 1024;
fseek(blkfp, blkid*1024, SEEK_SET);
}
static uint8_t iord_blkdata()
{
return BLKFS[blkpos++];
return getc(blkfp);
}
int main(int argc, char *argv[])
{
fprintf(stderr, "Using blkfs %s\n", BLKFS_PATH);
blkfp = fopen(BLKFS_PATH, "r+");
if (!blkfp) {
fprintf(stderr, "Can't open\n");
return 1;
}
Machine *m = emul_init();
m->ramstart = RAMSTART;
m->iord[STDIO_PORT] = iord_stdio;