n8vem-mark4: add support for console on PropIO v2 board.
authorAnthony DeStefano <adx@fastmail.fm>
Mon, 5 Jan 2015 00:36:23 +0000 (19:36 -0500)
committerWill Sowerbutts <will@sowerbutts.com>
Mon, 5 Jan 2015 01:33:22 +0000 (01:33 +0000)
Kernel/platform-n8vem-mark4/config.h
Kernel/platform-n8vem-mark4/devtty.c
Kernel/platform-n8vem-mark4/devtty.h
Kernel/platform-n8vem-mark4/main.c

index 5a85b73..3866b4a 100644 (file)
 #define SWAPTOP            0xFF00      /* can we stop at the top? not sure how. let's stop short. */
 #define MAX_SWAPS      10          /* Well, that depends really, hmmmmmm. Pick a number, any number. */
 
-#define BOOT_TTY (512 + 1)/* Set this to default device for stdio, stderr */
-                          /* In this case, the default is the first TTY device */
-
 /* We need a tidier way to do this from the loader */
 #define CMDLINE        (0x0081)  /* Location of root dev name */
 
-/* Device parameters */
-#define NUM_DEV_TTY 2
-
-#define TTYDEV   BOOT_TTY /* Device used by kernel for messages, panics */
 //#define SWAPDEV  (256 + 1)  /* Device for swapping. (z80pack drive J) */
 #define NBUFS    10       /* Number of block buffers */
 #define NMOUNTS         4        /* Number of mounts at a time */
 /* We have a DS1302, we can read the time of day from it */
 #define CONFIG_RTC
 #define CONFIG_RTC_INTERVAL 30 /* deciseconds between reading RTC seconds counter */
+
+/* We have a PropIOv2 board */
+#define CONFIG_PROPIO2
+#define PROPIO2_IO_BASE                0xA8
+
+/* Device parameters */
+#ifdef CONFIG_PROPIO2
+       #define NUM_DEV_TTY 3
+
+       /* PropIO as the console */
+       #define BOOT_TTY (512 + 3)
+#else
+       #define NUM_DEV_TTY 2
+
+       /* ANSI0 as the console */
+       #define BOOT_TTY (512 + 1)
+#endif
+
+#define TTYDEV   BOOT_TTY /* Device used by kernel for messages, panics */
index ed2a231..fce0303 100644 (file)
 char tbuf1[TTYSIZ];
 char tbuf2[TTYSIZ];
 
+#ifdef CONFIG_PROPIO2
+char tbufp[TTYSIZ];
+
+__sfr __at (PROPIO2_IO_BASE + 0x00) PROPIO2_STAT;
+__sfr __at (PROPIO2_IO_BASE + 0x01) PROPIO2_TERM;
+#endif
+
 struct  s_queue  ttyinq[NUM_DEV_TTY+1] = {       /* ttyinq[0] is never used */
     {   NULL,    NULL,    NULL,    0,        0,       0    },
     {   tbuf1,   tbuf1,   tbuf1,   TTYSIZ,   0,   TTYSIZ/2 },
     {   tbuf2,   tbuf2,   tbuf2,   TTYSIZ,   0,   TTYSIZ/2 },
+#ifdef CONFIG_PROPIO2
+    {   tbufp,   tbufp,   tbufp,   TTYSIZ,   0,   TTYSIZ/2 },
+#endif
 };
 
 void tty_setup(uint8_t minor)
@@ -42,6 +52,14 @@ void tty_pollirq_asci1(void)
     }
 }
 
+#ifdef CONFIG_PROPIO2
+void tty_poll_propio2(void)
+{
+    while(PROPIO2_STAT & 0x20)
+        tty_inproc(3, PROPIO2_TERM);
+}
+#endif
+
 void tty_putc(uint8_t minor, unsigned char c)
 {
     switch(minor){
@@ -53,6 +71,12 @@ void tty_putc(uint8_t minor, unsigned char c)
             while(!(ASCI_STAT1 & 2));
             ASCI_TDR1 = c;
             break;
+#ifdef CONFIG_PROPIO2
+        case 3:
+            while(!(PROPIO2_STAT & 0x10));
+            PROPIO2_TERM = c;
+            break;
+#endif
     }
 }
 
@@ -65,8 +89,7 @@ bool tty_writeready(uint8_t minor)
 /* kernel writes to system console -- never sleep! */
 void kputchar(char c)
 {
-    tty_putc(1, c);
+    tty_putc(TTYDEV - 512, c);
     if(c == '\n')
-        tty_putc(1, '\r');
+        tty_putc(TTYDEV - 512, '\r');
 }
-
index 3a499c0..ea9f1c8 100644 (file)
@@ -4,4 +4,8 @@ void tty_putc(uint8_t minor, unsigned char c);
 bool tty_writeready(uint8_t minor);
 void tty_pollirq_asci0(void);
 void tty_pollirq_asci1(void);
+
+#ifdef CONFIG_PROPIO2
+void tty_poll_propio2(void);
+#endif
 #endif
index 49aaed3..7a73a35 100644 (file)
@@ -16,6 +16,11 @@ void z180_timer_interrupt(void)
     a = TIME_TMDR0L;
     a = TIME_TCR;
 
+#ifdef CONFIG_PROPIO2
+    /* The PropIO2 does not have an interrupt on keypress. */
+    tty_poll_propio2();
+#endif
+
     timer_interrupt();
 }