plus3boot: simple tool to checksum a plus3 boot block and make it bootable
authorAlan Cox <alan@linux.intel.com>
Fri, 30 Nov 2018 00:29:54 +0000 (00:29 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 30 Nov 2018 00:29:54 +0000 (00:29 +0000)
Kernel/cpu-z80/image.mk
Kernel/tools/plus3boot.c [new file with mode: 0644]

index 3a3e8e5..f98eb6b 100644 (file)
@@ -23,6 +23,8 @@ tools/flat2z80: tools/flat2z80.c
 
 tools/makedck: tools/makedck.c
 
+tools/plus3boot: tools/plus3boot.c
+
 tools/raw2mgt: tools/raw2mgt.c
 
 tools/bankld/sdldz80:
@@ -38,7 +40,7 @@ tools/trslabel: tools/trslabel.c
 fuzix.ihx: target $(OBJS) platform-$(TARGET)/fuzix.lnk tools/bankld/sdldz80
        $(CROSS_LD) -n -k $(LIBZ80) -f platform-$(TARGET)/fuzix.lnk
 
-fuzix.bin: fuzix.ihx tools/bihx tools/analysemap tools/memhogs tools/binman tools/bintomdv tools/binmunge tools/bin2sna tools/bin2z80 cpm-loader/cpmload.bin tools/flat2z80 tools/makejv3 tools/trslabel tools/visualize tools/raw2mgt tools/cartman tools/makedck
+fuzix.bin: fuzix.ihx tools/bihx tools/analysemap tools/memhogs tools/binman tools/bintomdv tools/binmunge tools/bin2sna tools/bin2z80 cpm-loader/cpmload.bin tools/flat2z80 tools/makejv3 tools/trslabel tools/visualize tools/raw2mgt tools/cartman tools/makedck tools/plus3boot
        -cp hogs.txt hogs.txt.old
        tools/memhogs <fuzix.map |sort -nr >hogs.txt
        head -5 hogs.txt
diff --git a/Kernel/tools/plus3boot.c b/Kernel/tools/plus3boot.c
new file mode 100644 (file)
index 0000000..c617645
--- /dev/null
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+int main(int argc, char *argv[])
+{
+    uint8_t buf[512];
+    uint8_t *p = buf;
+    uint8_t sum = 0;
+    
+    if (fread(buf, 512, 1, stdin) != 1) {
+        fprintf(stderr, "boot block too short.\n");
+        exit(1);
+    }
+    while(p < buf + 512)
+        sum += *p++;
+    sum = ~sum;
+    sum += 4;
+    buf[15] = sum;
+    if (fwrite(buf, 512, 1, stdout) != 1) {
+        fprintf(stderr, "boot block write error.\n");
+        exit(1);
+    }
+    return 0;
+}
\ No newline at end of file