Turn it into a binary memory image, then apply shuffle the high 4K so the loader
unpacks it off the disk image properly.
tools/make4x6 >font4x6.c
clean:
- rm -f $(OBJS) $(JUNK) fuzix.cdb fuzix.com fuzix.tmp platform fuzix.bin fuzix.map fuzix.noi fuzix.ihx common.ihx common.bin relocs.dat core *~ include/*~ version.c tools/make4x6 tools/analysemap tools/memhogs tools/binman tools/bihx tools/bintomdv tools/chkmdv tools/decbdragon hogs.txt hogs.txt.old tools/*~
+ rm -f $(OBJS) $(JUNK) fuzix.cdb fuzix.com fuzix.tmp platform fuzix.bin fuzix.map fuzix.noi fuzix.ihx common.ihx common.bin relocs.dat core *~ include/*~ version.c tools/make4x6 tools/analysemap tools/memhogs tools/binman tools/bihx tools/bintomdv tools/chkmdv tools/decbdragon tools/decb-image hogs.txt hogs.txt.old tools/*~
+$(MAKE) -C platform-$(TARGET) clean
+$(MAKE) -C cpm-loader clean
+$(MAKE) -C tools/bankld clean
-fuzix.bin: target $(OBJS) tools/decbdragon
+fuzix.bin: target $(OBJS) tools/decbdragon tools/decb-image
+make -C platform-$(TARGET) image
export BITS=16
tools/decbdragon: tools/decbdragon.c
+tools/decb-image: tools/decb-image.c
+
../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \
../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \
devtty.o libc.o ../vt.o
-# FIXME: need to then convert the decb into an image for the IDE disk booter
+ ../tools/decb-image <../fuzix.bin fuzix.img
+ # Repack the high 4K where the loader wants it
+ dd if=fuzix.img of=fuzix.tmp bs=1024 skip=60
+ dd if=fuzix.tmp of=fuzix.img bs=1024 seek=32 conv=notrunc
bootfuz.bin: bootloader.s
lwasm -r -b -obootfuz.bin bootloader.s
define lensympat __sectionlen_%s__
section .istack load 0x0000
section .vectors load 0x0100
-section .udata load 0xFD00
section .start load 0x0400
section .text
section .text2
section .common
section .text3
section .discard load 0x9000
+section .udata load 0xFD00
entry start
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/*
+ * Turn a DECB file into a 64K raw memory dump
+ */
+
+static enum {
+ NEW_BLOCK,
+ PREAMBLE_1,
+ PREAMBLE_2,
+ PREAMBLE_3,
+ PREAMBLE_4,
+ POSTAMBLE_1,
+ POSTAMBLE_2,
+ POSTAMBLE_3,
+ POSTAMBLE_4,
+ DONE,
+ BYTESTREAM
+} state = NEW_BLOCK;
+
+static unsigned char image[65536];
+
+static void write_image(char *path)
+{
+ int fd = creat(path, 0666);
+ if (fd == -1) {
+ perror(path);
+ exit(1);
+ }
+ if (write(fd, image, 65536) != 65536) {
+ perror(path);
+ exit(1);
+ }
+ if (close(fd) != 0) {
+ perror(path);
+ exit(1);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int c;
+ unsigned int base, size;
+
+ if (argc != 2) {
+ fprintf(stderr, "%s [image]\n", argv[0]);
+ exit(1);
+ }
+ while(state != DONE && (c = getchar()) != EOF) {
+ switch(state) {
+ case NEW_BLOCK:
+ if (c == 0xFF) {
+ state = POSTAMBLE_1;
+ break;
+ }
+ if (c == 0x00) {
+ state = PREAMBLE_1;
+ break;
+ }
+ fprintf(stderr, "Corrupt DECB (%d)\n", c);
+ exit(1);
+ break;
+
+ case POSTAMBLE_1:
+ if (c != 0x00) {
+ fprintf(stderr, "DECB postamble byte 0 not 0x00\n");
+ exit(1);
+ }
+ state = POSTAMBLE_2;
+ break;
+ case POSTAMBLE_2:
+ if (c != 0x00) {
+ fprintf(stderr, "DECB postamble byte 2 not 0x00\n");
+ exit(1);
+ }
+ state = POSTAMBLE_3;
+ break;
+ case POSTAMBLE_3:
+ state = POSTAMBLE_4;
+ break;
+ case POSTAMBLE_4:
+ state = DONE;
+ break;
+
+ case PREAMBLE_1:
+ size = c << 8;
+ state = PREAMBLE_2;
+ break;
+ case PREAMBLE_2:
+ size += c;
+ state = PREAMBLE_3;
+ break;
+ case PREAMBLE_3:
+ base = c << 8;
+ state = PREAMBLE_4;
+ break;
+ case PREAMBLE_4:
+ base += c;
+ state = BYTESTREAM;
+ if (base + size > 65535) {
+ fprintf(stderr, "Oversized image\n");
+ exit(1);
+ }
+ break;
+ case BYTESTREAM:
+ if (image[base])
+ fprintf(stderr, "Overwrite at 0x%X\n", base);
+ image[base++] = c;
+ size--;
+ if (size == 0)
+ state = NEW_BLOCK;
+ break;
+ default:
+ fprintf(stderr, "State machine horked.\n");
+ exit(1);
+ }
+ }
+ if (state != DONE) {
+ fprintf(stderr, "Unexpected EOF in state %d\n", state);
+ exit(1);
+ }
+ write_image(argv[1]);
+ exit(0);
+}