From eaa754aaf5f3f5f4426b06c51f40f75db6ba6fae Mon Sep 17 00:00:00 2001 From: Anthony DeStefano Date: Sun, 4 Jan 2015 19:36:23 -0500 Subject: [PATCH] n8vem-mark4: add support for console on PropIO v2 board. --- Kernel/platform-n8vem-mark4/config.h | 26 ++++++++++++++++++------- Kernel/platform-n8vem-mark4/devtty.c | 29 +++++++++++++++++++++++++--- Kernel/platform-n8vem-mark4/devtty.h | 4 ++++ Kernel/platform-n8vem-mark4/main.c | 5 +++++ 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/Kernel/platform-n8vem-mark4/config.h b/Kernel/platform-n8vem-mark4/config.h index 5a85b73b..3866b4a7 100644 --- a/Kernel/platform-n8vem-mark4/config.h +++ b/Kernel/platform-n8vem-mark4/config.h @@ -32,16 +32,9 @@ #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 */ @@ -63,3 +56,22 @@ /* 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 */ diff --git a/Kernel/platform-n8vem-mark4/devtty.c b/Kernel/platform-n8vem-mark4/devtty.c index ed2a2319..fce0303f 100644 --- a/Kernel/platform-n8vem-mark4/devtty.c +++ b/Kernel/platform-n8vem-mark4/devtty.c @@ -10,10 +10,20 @@ 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'); } - diff --git a/Kernel/platform-n8vem-mark4/devtty.h b/Kernel/platform-n8vem-mark4/devtty.h index 3a499c0c..ea9f1c87 100644 --- a/Kernel/platform-n8vem-mark4/devtty.h +++ b/Kernel/platform-n8vem-mark4/devtty.h @@ -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 diff --git a/Kernel/platform-n8vem-mark4/main.c b/Kernel/platform-n8vem-mark4/main.c index 49aaed35..7a73a359 100644 --- a/Kernel/platform-n8vem-mark4/main.c +++ b/Kernel/platform-n8vem-mark4/main.c @@ -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(); } -- 2.34.1