makedck: Make a Timex cartridge dock for the kernel image
authorAlan Cox <alan@linux.intel.com>
Tue, 27 Nov 2018 12:49:04 +0000 (12:49 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 27 Nov 2018 12:49:04 +0000 (12:49 +0000)
Kernel/tools/makedck.c [new file with mode: 0644]

diff --git a/Kernel/tools/makedck.c b/Kernel/tools/makedck.c
new file mode 100644 (file)
index 0000000..08246c8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *     Make a DCK file of the top 32K of a 64K image
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int main(int argc, char *argv[])
+{
+    FILE *in, *out;
+    char buf[32768];
+    if (argc != 3) {
+        fprintf(stderr, "%s image dockfile.\n", argv[0]);
+        exit(1);
+    }
+    in = fopen(argv[1], "r");
+    if (in == NULL) {
+        perror(argv[1]);
+        exit(1);
+    }
+    out = fopen(argv[2], "w");
+    if (out == NULL) {
+        perror(argv[2]);
+        exit(1);
+    }
+    fputc(0, out);             /* Dock */
+    fputc(0x1, out);           /* Low 32K is RAM, data absent */
+    fputc(0x1, out);
+    fputc(0x1, out);
+    fputc(0x1, out);
+    fputc(0x2, out);           /* Next 32K is ROM, data present */
+    fputc(0x2, out);
+    fputc(0x2, out);
+    fputc(0x2, out);
+
+    /* Now the data */
+    if (fread(buf, 32768, 1, in) != 1 ||
+        fread(buf, 32768, 1, in) != 1) {
+            fprintf(stderr, "%s: image '%s' is too short.\n",
+                argv[0], argv[1]);
+            exit(1);
+    }
+    if (fwrite(buf, 32768,1, out) != 1 || fclose(out)) {
+        fprintf(stderr, "%s: short write to '%s'.\n", argv[0], argv[2]);
+        exit(1);
+    }
+    return 0;
+}
+        
\ No newline at end of file