mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 23:28: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:
parent
f884918d73
commit
8d3da4c0de
@ -1,4 +1,4 @@
|
|||||||
TARGETS = forth stage
|
TARGETS = forth stage blkfs
|
||||||
OBJS = emul.o libz80/libz80.o
|
OBJS = emul.o libz80/libz80.o
|
||||||
BIN2C = ../tools/bin2c
|
BIN2C = ../tools/bin2c
|
||||||
BLKPACK = ../tools/blkpack
|
BLKPACK = ../tools/blkpack
|
||||||
@ -18,17 +18,14 @@ $(BLKUNPACK): $(BLKPACK)
|
|||||||
forth-bin.h: $(BIN2C)
|
forth-bin.h: $(BIN2C)
|
||||||
$(BIN2C) KERNEL < forth.bin > $@
|
$(BIN2C) KERNEL < forth.bin > $@
|
||||||
|
|
||||||
stage: stage.c $(OBJS) forth-bin.h blkfs-bin.h
|
stage: stage.c $(OBJS) forth-bin.h
|
||||||
$(CC) stage.c $(OBJS) -o $@
|
$(CC) stage.c -DBLKFS_PATH=\"`pwd`/blkfs\" $(OBJS) -o $@
|
||||||
|
|
||||||
blkfs: $(BLKPACK)
|
blkfs: $(BLKPACK)
|
||||||
$(BLKPACK) ../blk > $@
|
$(BLKPACK) ../blk > $@
|
||||||
|
|
||||||
blkfs-bin.h: blkfs $(BIN2C)
|
forth: forth.c $(OBJS) forth-bin.h
|
||||||
$(BIN2C) BLKFS < blkfs > $@
|
$(CC) forth.c -DBLKFS_PATH=\"`pwd`/blkfs\" $(OBJS) -lncurses -o $@
|
||||||
|
|
||||||
forth: forth.c $(OBJS) forth-bin.h blkfs-bin.h
|
|
||||||
$(CC) forth.c $(OBJS) -lncurses -o $@
|
|
||||||
|
|
||||||
libz80/libz80.o: libz80/z80.c
|
libz80/libz80.o: libz80/z80.c
|
||||||
$(MAKE) -C libz80/codegen opcodes
|
$(MAKE) -C libz80/codegen opcodes
|
||||||
@ -39,7 +36,7 @@ emul.o: emul.c
|
|||||||
|
|
||||||
|
|
||||||
.PHONY: updatebootstrap
|
.PHONY: updatebootstrap
|
||||||
updatebootstrap: stage xcomp.fs
|
updatebootstrap: stage xcomp.fs pack
|
||||||
./stage < xcomp.fs > forth.bin
|
./stage < xcomp.fs > forth.bin
|
||||||
|
|
||||||
.PHONY: pack
|
.PHONY: pack
|
||||||
@ -52,5 +49,4 @@ unpack:
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGETS) emul.o *-bin.h stage{1,2}.bin blkfs
|
rm -f $(TARGETS) emul.o *-bin.h blkfs
|
||||||
$(MAKE) -C ../tools clean
|
|
||||||
|
15
emul/forth.c
15
emul/forth.c
@ -5,7 +5,6 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include "emul.h"
|
#include "emul.h"
|
||||||
#include "forth-bin.h"
|
#include "forth-bin.h"
|
||||||
#include "blkfs-bin.h"
|
|
||||||
|
|
||||||
// in sync with glue.asm
|
// in sync with glue.asm
|
||||||
#define RAMSTART 0x900
|
#define RAMSTART 0x900
|
||||||
@ -83,13 +82,15 @@ static void iowr_blkdata(uint8_t val)
|
|||||||
|
|
||||||
int run()
|
int run()
|
||||||
{
|
{
|
||||||
blkfp = fopen("blkfs", "r+");
|
#ifdef BLKFS_PATH
|
||||||
if (blkfp) {
|
fprintf(stderr, "Using blkfs %s\n", BLKFS_PATH);
|
||||||
fprintf(stderr, "Using blkfs file\n");
|
blkfp = fopen(BLKFS_PATH, "r+");
|
||||||
} else {
|
if (!blkfp) {
|
||||||
blkfp = fmemopen((char*)BLKFS, sizeof(BLKFS), "r");
|
fprintf(stderr, "Can't open\n");
|
||||||
fprintf(stderr, "Using in-memory read-only blkfs\n");
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
blkfp = NULL;
|
||||||
|
#endif
|
||||||
Machine *m = emul_init();
|
Machine *m = emul_init();
|
||||||
m->ramstart = RAMSTART;
|
m->ramstart = RAMSTART;
|
||||||
m->iord[STDIO_PORT] = iord_stdio;
|
m->iord[STDIO_PORT] = iord_stdio;
|
||||||
|
17
emul/stage.c
17
emul/stage.c
@ -3,7 +3,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "emul.h"
|
#include "emul.h"
|
||||||
#include "forth-bin.h"
|
#include "forth-bin.h"
|
||||||
#include "blkfs-bin.h"
|
|
||||||
|
#ifndef BLKFS_PATH
|
||||||
|
#error BLKFS_PATH needed
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Staging binaries
|
/* Staging binaries
|
||||||
|
|
||||||
@ -37,7 +40,7 @@ static int running;
|
|||||||
static uint16_t start_here = 0;
|
static uint16_t start_here = 0;
|
||||||
static uint16_t end_here = 0;
|
static uint16_t end_here = 0;
|
||||||
static uint16_t blkid = 0;
|
static uint16_t blkid = 0;
|
||||||
static unsigned int blkpos = 0;
|
static FILE *blkfp;
|
||||||
|
|
||||||
static uint8_t iord_stdio()
|
static uint8_t iord_stdio()
|
||||||
{
|
{
|
||||||
@ -65,16 +68,22 @@ static void iowr_blk(uint8_t val)
|
|||||||
{
|
{
|
||||||
blkid <<= 8;
|
blkid <<= 8;
|
||||||
blkid |= val;
|
blkid |= val;
|
||||||
blkpos = blkid * 1024;
|
fseek(blkfp, blkid*1024, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t iord_blkdata()
|
static uint8_t iord_blkdata()
|
||||||
{
|
{
|
||||||
return BLKFS[blkpos++];
|
return getc(blkfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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();
|
Machine *m = emul_init();
|
||||||
m->ramstart = RAMSTART;
|
m->ramstart = RAMSTART;
|
||||||
m->iord[STDIO_PORT] = iord_stdio;
|
m->iord[STDIO_PORT] = iord_stdio;
|
||||||
|
Loading…
Reference in New Issue
Block a user