zxuno: add some helpers for putting the ZX Uno into 14Mhz mode etc
authorAlan Cox <alan@linux.intel.com>
Fri, 1 Mar 2019 22:11:33 +0000 (22:11 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 1 Mar 2019 22:11:33 +0000 (22:11 +0000)
From a Fuzix perspective we want to turn on all the features regardless

Kernel/dev/zx/zxuno.c [new file with mode: 0644]
Kernel/dev/zx/zxuno.h [new file with mode: 0644]

diff --git a/Kernel/dev/zx/zxuno.c b/Kernel/dev/zx/zxuno.c
new file mode 100644 (file)
index 0000000..15a5817
--- /dev/null
@@ -0,0 +1,99 @@
+#include <kernel.h>
+#include <printf.h>
+#include <zxuno.h>
+
+extern uint8_t fuller, kempston, kmouse, kempston_mbmask;
+
+/*
+ *     Support routines for the ZX Uno. Can be built into _DISCARD.
+ *
+ *     Turn on all the I/O devices and mark them present
+ *     Set the CPU to 14Mhz
+ *     Check for 50 v 60Hz (only 50 works right now)
+ *     Turn on the video and MMU modes
+ *
+ *     We don't do anything with the MMU and video.
+ */
+
+__sfr __banked __at 0xfc3b uno_ctrl;
+__sfr __banked __at 0xfd3b uno_data;
+
+uint8_t probe_zxuno(void)
+{
+       uint8_t n;
+       uint8_t c;
+       uno_ctrl = 0xff;
+       uno_data = 0x00;
+
+       /* Check if Uno is present */
+       for (n = 0; n < 64; n++) {
+               c = uno_data;
+               if (c == 0)
+                       return 1;
+               if (c < 32 || c > 127)
+                       return 0;
+       }
+       return 0;
+}
+
+/* Turn on all the I/O devices, and fire up the turbos */
+
+void configure_zxuno(void)
+{
+       uint8_t c;
+
+       uno_ctrl = 0xFF;
+       uno_data = 0x00;
+
+       kputs("ZX Uno Detected\n");
+       for (c = 0; c < 64; c++)
+               kputchar(uno_data);
+       kputchar('\n');
+       
+       uno_ctrl = 0;
+       if (uno_data & 0x80)
+               kputs("Warning: ZX Uno configuration is locked.\n");
+       else {
+               c = uno_data;
+               /* Contention off, Pentagon timing (as best), NMI off,
+                  DIVMMC on */
+               c &= ~0x10;     
+               c |= 0x66;
+               uno_data = c;
+       }
+       uno_ctrl = 6;
+       uno_data = 0x12;        /* Plug in stick is Kempston, alt is fuller */
+       kempston = 1;
+       fuller = 1;
+       kmouse = 1;
+
+       /* Vroooomm.... */      
+       uno_ctrl = 0x0B;
+       c = uno_data;
+       c &= 0x3C;
+       c |= 0x80;              /* 14MHz (don't set C0!!!) */
+       uno_data = c;
+
+       uno_ctrl = 0x0D;
+       c = uno_data;
+       c &= ~0x80;             /* SD on */
+       c |= 0x40;              /* Horizontal MMU and Timex video on
+                                  (although we don't use them yet) */
+       uno_data = c;
+
+       uno_ctrl = 0x0F;
+       c = uno_data;
+       c &= 0xF8;              /* ULAplus, Radistano, Timex on */
+       uno_data = c;
+
+       /* FIXME: do we need to set radasctrl |= 3 */
+       uno_ctrl = 0xFB;
+       if (uno_data & 1)       /* 60 HZ */
+               kputs("Warning 60Hz not yet supported.\n");
+}
+
+uint8_t locked_zxuno(void)
+{
+       uno_ctrl = 0;
+       return uno_data & 0x80;
+}
diff --git a/Kernel/dev/zx/zxuno.h b/Kernel/dev/zx/zxuno.h
new file mode 100644 (file)
index 0000000..f59c31e
--- /dev/null
@@ -0,0 +1,3 @@
+extern uint8_t probe_zxuno(void);
+extern void configure_zxuno(void);
+extern uint8_t locked_zxuno(void);