tbblue: add UART minor loader fix
authorAlan Cox <alan@linux.intel.com>
Fri, 4 Jan 2019 19:30:43 +0000 (19:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 4 Jan 2019 19:30:43 +0000 (19:30 +0000)
Still working over the code and reviewing, not yet ready for testing

(need to sort a different 8K paged platform first to test the core 8K code
better)

Kernel/platform-tbblue/config.h
Kernel/platform-tbblue/devtty.c
Kernel/platform-tbblue/devtty.h
Kernel/platform-tbblue/load-esx.s
Kernel/platform-tbblue/main.c

index 797fcda..e48399d 100644 (file)
 #define VT_BOTTOM      23
 
 
-
 /*
  *     Define the program loading area (needs to match kernel.def)
  */
 #define PROGBASE    0x0000  /* Base of user  */
 #define PROGLOAD    0x0100  /* Load and run here */
-#define PROGTOP     0xE000  /* Top of program, base of U_DATA stash */
-#define PROC_SIZE   56             /* Memory needed per process including stash */
+#define PROGTOP     0xE000  /* Top of program, base of U_DATA */
+#define PROC_SIZE   56             /* Memory needed per process */
 
 /*
  *     Definitions for swapping - we don't need swap!
@@ -50,8 +49,8 @@
 
 /* What is the maximum number of /dev/hd devices we have. In theory right now
    it's actually 1 - the SD interface */
-#define MAX_BLKDEV     2
-/* Select IDE disk support, and PPIDE (parallel port IDE) as the interface */
+#define MAX_BLKDEV     1
+/* SD card, single card only */
 #define CONFIG_SD
 #define SD_DRIVE_COUNT 1
 
 
 /* This can optionally be set to force a default baud rate, eg if the system
    console should match a firmware set rate */
-#define TTY_INIT_BAUD B38400   /* To match ROMWBW */
-
+#define TTY_INIT_BAUD B115200  /* Console is 'fast' */
index 5e7dc53..4d27660 100644 (file)
 #include <input.h>
 #include <devinput.h>
 
-char tbuf1[TTYSIZ];
+__sfr __banked __at 0x133B uart_status;                /* Read */
+__sfr __banked __at 0x133B uart_tx;            /* Write */
+__sfr __banked __at 0x143B uart_rx;            /* Read */
+__sfr __banked __at 0x143B uart_baud;          /* Write */
+
+static char tbuf1[TTYSIZ];
+static char tbuf2[TTYSIZ];
 
 uint8_t vtattr_cap = VTA_INVERSE|VTA_FLASH|VTA_UNDERLINE;
 extern uint8_t curattr;
@@ -22,18 +28,27 @@ static tcflag_t console_mask[4] = {
        _LSYS
 };
 
+static tcflag_t serial_mask[4] = {
+       _ISYS,
+       _OSYS,
+       _CSYS|CBAUD,
+       _LSYS
+};
+
 tcflag_t *termios_mask[NUM_DEV_TTY + 1] = {
        NULL,
-       console_mask
+       console_mask,
+       serial_mask,
 };
 
 
 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},
 };
 
-/* tty1 is the screen */
+/* tty1 is the screen, tty2 is the simple UART on the FPGA */
 
 /* Output for the system console (kprintf etc) */
 void kputchar(char c)
@@ -43,37 +58,61 @@ void kputchar(char c)
        tty_putc(0, c);
 }
 
-/* Both console and debug port are always ready */
 ttyready_t tty_writeready(uint8_t minor)
 {
-       minor;
-       return TTY_READY_NOW;
+       if (minor == 1)
+               return TTY_READY_NOW;
+       // FIXME 
+       return TTY_READY_NOW;   // TTY_READY_SOON
 }
 
 void tty_putc(uint8_t minor, unsigned char c)
 {
-       minor;
-       vtoutput(&c, 1);
+       if (minor == 1)
+               vtoutput(&c, 1);
+       else
+               uart_tx = c;
+}
+
+void tty_polluart(void)
+{
+       while (!(uart_status & 1))
+               tty_inproc(2, uart_rx);
 }
 
 int tty_carrier(uint8_t minor)
 {
-       minor;
+       used(minor);
        return 1;
 }
 
+/* Both ports are fixed configuration but the serial
+   can switch baud rate */
 void tty_setup(uint8_t minor, uint8_t flags)
 {
-       minor;
+       uint8_t baud = ttydata[2].termios.c_cflag & CBAUD;
+       if (minor == 1)
+               return;
+       if (baud < B2400) {
+               baud = 0;
+               ttydata[2].termios.c_cflag &= ~CBAUD;
+               ttydata[2].termios.c_cflag |= B2400;
+       } else
+               baud -= B2400;
+       /* The hardware baud rates line up with our definitions from 2400 up
+          but in reverse order */
+       uart_baud = 6 - baud;
+       
 }
 
 void tty_sleeping(uint8_t minor)
 {
-       minor;
+       used(minor);
 }
 
 void tty_data_consumed(uint8_t minor)
 {
+       used(minor);
 }
 
 
@@ -81,7 +120,7 @@ void tty_data_consumed(uint8_t minor)
 uint16_t cursorpos;
 
 /* For now we only support 64 char mode - we should add the mode setting
-   logic an dother modes FIXME */
+   logic another modes FIXME */
 static struct display specdisplay = {
        0,
        512, 192,
@@ -93,20 +132,8 @@ static struct display specdisplay = {
        0
 };
 
-static struct videomap specmap = {
-       0,
-       0,
-       0x4000,
-       14336,
-       0,
-       0,
-       0,
-       MAP_FBMEM|MAP_FBMEM_SIMPLE
-};
-
 /*
- *     Graphics ioctls. Very minimal for this platform. It's a single fixed
- *     mode with direct memory mapping.
+ *     Graphics ioctls. Not yet updated to reflect TBBlue at all
  */
 int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
 {
@@ -115,10 +142,6 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
        switch(arg) {
        case GFXIOC_GETINFO:
                return uput(&specdisplay, ptr, sizeof(struct display));
-       case GFXIOC_MAP:
-               return uput(&specmap, ptr, sizeof(struct videomap));
-       case GFXIOC_UNMAP:
-               return 0;
        case GFXIOC_WAITVB:
                /* Our system clock is vblank */
                timer_wait++;
index 40a67f5..a6355bc 100644 (file)
@@ -4,6 +4,8 @@
 void tty_pollirq(void);
 static void keydecode(void);
 
+extern void tty_polluart(void);
+
 #define KEY_ROWS       8
 #define KEY_COLS       5
 extern uint8_t keymap[8];
index 48d1138..c2d98a8 100644 (file)
@@ -69,16 +69,14 @@ load16k:
        ld bc,#0x243B
        ld e,#0x56              ; 0xC000 mapping register
        out (c),e
-       inc b
+       inc b                   ; to data port
        out (c),a               ; Page requested
-       inc b
-       out (c),b               ; MMU register 7
        dec b                   ; back to control port
        inc e                   ; next register
        inc a                   ; next page
-       out (c),e
-       inc b
-       out (c),a
+       out (c),e               ; 0xE000 mapping register
+       inc b                   ; back to data port
+       out (c),a               ; page
 
        ld a,(handle)           ; Load 16K into that page
        ld bc,#0x4000
index cd8de9e..701eae4 100644 (file)
@@ -22,6 +22,7 @@ uint8_t timer_wait;
 void platform_interrupt(void)
 {
  tty_pollirq();
+ tty_polluart();
  timer_interrupt();
  poll_input();
  if (timer_wait)