micropack: experimenting with some smallness ideas
authorAlan Cox <alan@linux.intel.com>
Mon, 15 Jun 2015 22:13:32 +0000 (23:13 +0100)
committerAlan Cox <alan@linux.intel.com>
Mon, 15 Jun 2015 22:13:32 +0000 (23:13 +0100)
Kernel/platform-micropack/Makefile
Kernel/platform-micropack/config.h
Kernel/platform-micropack/devtty.c [new file with mode: 0644]

index e6d3d87..e4100b5 100644 (file)
@@ -1,6 +1,6 @@
 
-DSRCS = ../dev/z80pack/devlpr.c ../dev/z80pack/devtty.c ../dev/z80pack/devfd.c
-CSRCS = devices.c main.c
+DSRCS = ../dev/z80pack/devlpr.c ../dev/z80pack/devfd.c
+CSRCS = devices.c main.c devtty.c
 
 ASRCS = crt0.s z80pack.s
 ASRCS += tricks.s commonmem.s
index 41584d8..9141e6d 100644 (file)
@@ -41,9 +41,9 @@
 #define CMDLINE        NULL      /* Location of root dev name */
 
 /* Device parameters */
-#define NUM_DEV_TTY 3
+#define NUM_DEV_TTY 1
 
 #define TTYDEV   BOOT_TTY /* Device used by kernel for messages, panics */
 #define SWAPDEV  (256 + 1)  /* Device for swapping. (z80pack drive J) */
-#define NBUFS    6        /* Number of block buffers */
+#define NBUFS    5        /* Number of block buffers */
 #define NMOUNTS         2        /* Number of mounts at a time */
diff --git a/Kernel/platform-micropack/devtty.c b/Kernel/platform-micropack/devtty.c
new file mode 100644 (file)
index 0000000..cf62e54
--- /dev/null
@@ -0,0 +1,64 @@
+#include <kernel.h>
+#include <kdata.h>
+#include <printf.h>
+#include <stdbool.h>
+#include <tty.h>
+#include <devtty.h>
+
+__sfr __at 0 tty1stat;
+__sfr __at 1 tty1data;
+
+char tbuf1[TTYSIZ];
+
+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 },
+};
+
+/* Write to system console */
+void kputchar(char c)
+{
+    /* handle CRLF */
+    if(c=='\n')
+        tty_putc(1, '\r');
+    tty_putc(1, c);
+}
+
+char tty_writeready(uint8_t minor)
+{
+    used(minor);
+    return 1;
+}
+
+void tty_putc(uint8_t minor, unsigned char c)
+{
+    used(minor);
+    tty1data = c;
+}
+
+void tty_sleeping(uint8_t minor)
+{
+    used(minor);
+}
+
+/* Called every timer tick */
+void tty_pollirq(void)
+{
+    unsigned char c;   /* sdcc bug workaround */
+    while(tty1stat) {
+        c = tty1data;
+        tty_inproc(1, c);
+    }
+}    
+
+void tty_setup(uint8_t minor)
+{
+    used(minor);
+}
+
+/* For the moment */
+int tty_carrier(uint8_t minor)
+{
+    used(minor);
+    return 1;
+}