dragon-nx32: Incorporate drivewire tty
authorTony Jewell <tonyjewell@gmail.com>
Sat, 21 May 2016 21:17:19 +0000 (23:17 +0200)
committerAlan Cox <alan@linux.intel.com>
Sun, 22 May 2016 19:07:27 +0000 (20:07 +0100)
Kernel/platform-dragon-nx32/Makefile
Kernel/platform-dragon-nx32/config.h
Kernel/platform-dragon-nx32/devtty.c
Kernel/platform-dragon-nx32/devtty.h

index bbcb4b6..69fcd8a 100644 (file)
@@ -1,5 +1,5 @@
 
-CSRCS = devlpr.c devtty.c devfd.c
+CSRCS = devlpr.c devtty.c devfd.c ttydw.c
 CSRCS += devices.c main.c libc.c
 
 CDSRCS = discard.c
@@ -50,7 +50,7 @@ image:
        dragon.o mem-nx32.o ../bankfixed.o \
        ../start.o ../version.o ../lowlevel-6809.o \
        tricks.o main.o ../timer.o ../kdata.o devfd.o floppy.o devices.o \
-       drivewire.o devdw.o \
+       drivewire.o devdw.o ttydw.o \
        ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
        ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \
        ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \
index ddc4a1c..64b3aaf 100644 (file)
@@ -62,7 +62,7 @@
 #define CMDLINE        NULL      /* Location of root dev name */
 
 /* Device parameters */
-#define NUM_DEV_TTY 2
+#define NUM_DEV_TTY 4
 #define NDEVS    2        /* Devices 0..NDEVS-1 are capable of being mounted */
                           /*  (add new mountable devices to beginning area.) */
 #define TTYDEV   BOOT_TTY /* Device used by kernel for messages, panics */
 #define NMOUNTS         2        /* Number of mounts at a time */
 #define swap_map(x)    ((uint8_t *)(x))
 
+/* Drivewire Defines */
+
+#define DW_VSER_NUM 1     /* No of Virtual Serial Ports */
+#define DW_VWIN_NUM 1     /* No of Virtual Window Ports */
+#define DW_MIN_OFF  3     /* Minor number offset */
+
 /* Remember to update platform-dragon-nx32/kernel.defs to match */
 
 extern void platform_discard(void);
index 822ab94..2fde9fa 100644 (file)
@@ -7,6 +7,8 @@
 #include <devfd.h>
 #include <vt.h>
 #include <tty.h>
+#include <devdw.h>
+#include <ttydw.h>
 #include <graphics.h>
 
 #undef  DEBUG                  /* UNdefine to delete debug code sequences */
@@ -18,11 +20,16 @@ uint8_t *uart_control = (uint8_t *)0xFF07;  /* ACIA control */
 
 unsigned char tbuf1[TTYSIZ];
 unsigned char tbuf2[TTYSIZ];
+unsigned char tbuf3[TTYSIZ];   /* drivewire VSER 0 */
+unsigned char tbuf4[TTYSIZ];   /* drivewire VWIN 0 */
 
 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}
+       {tbuf2, tbuf2, tbuf2, TTYSIZ, 0, TTYSIZ / 2},
+       /* Drivewire Virtual Serial Ports */
+       {tbuf3, tbuf3, tbuf3, TTYSIZ, 0, TTYSIZ / 2},
+       {tbuf4, tbuf4, tbuf4, TTYSIZ, 0, TTYSIZ / 2},
 };
 
 uint8_t vtattr_cap = VTA_INVERSE|VTA_UNDERLINE|VTA_ITALIC|VTA_BOLD|
@@ -55,6 +62,10 @@ ttyready_t tty_writeready(uint8_t minor)
 
 void tty_putc(uint8_t minor, unsigned char c)
 {
+       if (minor > 2 ) {
+               dw_putc(minor, c);
+               return;
+       }
        if (minor == 1) {
                /* We don't do text except in 256x192 resolution modes */
                if (vmode < 2)
@@ -95,6 +106,10 @@ static uint8_t bitbits[] = {
 void tty_setup(uint8_t minor)
 {
        uint8_t r;
+       if (minor > 2) {
+               dw_vopen(minor);
+               return;
+       }
        if (minor != 2)
                return;
        r = ttydata[2].termios.c_cflag & CBAUD;
@@ -119,6 +134,7 @@ void tty_setup(uint8_t minor)
 
 int tty_carrier(uint8_t minor)
 {
+       if (minor > 2) return dw_carrier( minor );
        /* The serial DCD is status bit 5 but not wired */
        return 1;
 }
@@ -277,6 +293,7 @@ void platform_interrupt(void)
                }
                 fd_timer_tick();
                timer_interrupt();
+               dw_vpoll();
        }
 }
 
@@ -396,6 +413,8 @@ static int gfx_draw_op(uarg_t arg, char *ptr, uint8_t *buf)
 
 int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
 {
+       if (minor > 2)  /* remove once DW get its own ioctl() */
+               return tty_ioctl(minor, arg, ptr);
        if (arg >> 8 != 0x03)
                return vt_ioctl(minor, arg, ptr);
        switch(arg) {
@@ -449,3 +468,11 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
        }
        return -1;
 }
+
+/* A wrapper for tty_close that closes the DW port properly */
+int my_tty_close(uint8_t minor)
+{
+       if (minor > 2 && ttydata[minor].users == 1)
+               dw_vclose(minor);
+       return (tty_close(minor));
+}
index 89b1ac0..92b92df 100644 (file)
@@ -13,4 +13,5 @@ extern void video_cmd(uint8_t *ptr);
 extern void video_read(uint8_t *ptr);
 extern void video_write(uint8_t *ptr);
 
+int my_tty_close( uint8_t minor ); /* wrapper call to close DW ports */
 #endif