Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga/stand/bootblock/boot Add a serial console mod...



details:   https://anonhg.NetBSD.org/src/rev/b0580b023e42
branches:  trunk
changeset: 748220:b0580b023e42
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Oct 17 11:18:17 2009 +0000

description:
Add a serial console mode for the bootblock. In this mode all console
output will be echoed to the serial port and input will be accepted
from either keyboard or serial port. The bootblock serial console is
limited to 9600bps 8N1 as it uses the AmigaOS kernel debug routines.

To enable this you have to uncomment the SERCONSOLE define in
boot/Makefile.

Also note that the handling of a serial console in the kernel is
independent of this, you need to a build a kernel with 'options
SERCONSOLE'.

diffstat:

 sys/arch/amiga/stand/bootblock/boot/Makefile   |   3 +-
 sys/arch/amiga/stand/bootblock/boot/console.c  |  56 ++++++++++++++++++++-----
 sys/arch/amiga/stand/bootblock/boot/libstubs.h |   6 ++-
 sys/arch/amiga/stand/bootblock/boot/libstubs.s |  22 +++++++++-
 4 files changed, 73 insertions(+), 14 deletions(-)

diffs (179 lines):

diff -r 9b801808214b -r b0580b023e42 sys/arch/amiga/stand/bootblock/boot/Makefile
--- a/sys/arch/amiga/stand/bootblock/boot/Makefile      Sat Oct 17 10:29:29 2009 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/Makefile      Sat Oct 17 11:18:17 2009 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.39 2009/01/12 07:42:30 tsutsui Exp $
+#      $NetBSD: Makefile,v 1.40 2009/10/17 11:18:17 mlelstv Exp $
 
 .include <bsd.sys.mk>          # for HOST_SH
 
@@ -51,6 +51,7 @@
 #XX#DEFS = -D_STANDALONE -DINSECURE -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR 
 DEFS = -D_STANDALONE -DINSECURE 
 DEFS += -D__INTERNAL_LIBSA_CREAD
+#DEFS += -DSERCONSOLE
 SOBJS += cread.o
 
 #XX#SOBJS += adler32.o crc32.o inflate.o trees.o \
diff -r 9b801808214b -r b0580b023e42 sys/arch/amiga/stand/bootblock/boot/console.c
--- a/sys/arch/amiga/stand/bootblock/boot/console.c     Sat Oct 17 10:29:29 2009 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/console.c     Sat Oct 17 11:18:17 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: console.c,v 1.12 2009/10/11 10:00:10 mlelstv Exp $ */
+/* $NetBSD: console.c,v 1.13 2009/10/17 11:18:18 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -115,6 +115,10 @@
        if (OpenDevice("timer.device", 0, (struct AmigaIO*)mc->tmior, 0))
                goto err;
 
+#ifdef SERCONSOLE
+       RawIOInit();
+#endif
+
        ConsoleBase = mc;
        return 0;
 
@@ -183,6 +187,11 @@
        mc->cnior->length = 1;
        mc->cnior->buf = &buf;
        mc->cnior->cmd = Cmd_Wr;
+
+#ifdef SERCONSOLE
+       RawPutChar((int32_t)c);
+#endif
+
        (void)DoIO(mc->cnior);
 }
 
@@ -194,6 +203,12 @@
        mc->cnior->length = -1;
        mc->cnior->buf = s;
        mc->cnior->cmd = Cmd_Wr;
+
+#ifdef SERCONSOLE
+       while (*s)
+               RawPutChar(*s++);
+#endif
+
        (void)DoIO(mc->cnior);
 }
 
@@ -201,8 +216,12 @@
 getchar(void)
 {
        struct AmigaIO *ior;
-       char c = -1;
+       char c = '\n';
        struct Console *mc = ConsoleBase;
+       unsigned long ticks;
+#ifdef SERCONSOLE
+       int32_t r;
+#endif
 
        mc->cnior->length = 1;
        mc->cnior->buf = &c;
@@ -210,22 +229,37 @@
 
        SendIO(mc->cnior);
 
-       if (timelimit) {
+       ticks = 10 * timelimit;
+       do {
+               if (timelimit == 0)
+                       ticks = 2;
+
                mc->tmior->cmd = Cmd_Addtimereq;
-               mc->tmior->secs = timelimit;
-               mc->tmior->usec = 2; /* Paranoid */
+               mc->tmior->secs = 0;
+               mc->tmior->usec = 100000;
                SendIO((struct AmigaIO *)mc->tmior);
 
                ior = WaitPort(mc->cnmp);
-               if (ior == mc->cnior)
+               if (ior == mc->cnior) {
                        AbortIO((struct AmigaIO *)mc->tmior);
-               else /* if (ior == mc->tmior) */ {
-                       AbortIO(mc->cnior);
-                       c = '\n';
+                       ticks = 1;
+               } else /* if (ior == mc->tmior) */ {
+#ifdef SERCONSOLE
+                       r = RawMayGetChar();
+                       if (r != -1) {
+                               c = r;
+                               ticks = 1;
+                       }
+#endif
+                       if (ticks == 1)
+                               AbortIO((struct AmigaIO *)mc->cnior);
                }
                WaitIO((struct AmigaIO *)mc->tmior);
-               timelimit = 0;
-       }
+
+               --ticks;
+       } while (ticks != 0);
+       timelimit = 0;
+
        (void)WaitIO(mc->cnior);
        return c;
 }
diff -r 9b801808214b -r b0580b023e42 sys/arch/amiga/stand/bootblock/boot/libstubs.h
--- a/sys/arch/amiga/stand/bootblock/boot/libstubs.h    Sat Oct 17 10:29:29 2009 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/libstubs.h    Sat Oct 17 11:18:17 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.h,v 1.6 2008/04/28 20:23:13 martin Exp $ */
+/* $NetBSD: libstubs.h,v 1.7 2009/10/17 11:18:18 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -55,6 +55,10 @@
 void AbortIO(struct AmigaIO *);
 u_int8_t WaitIO(struct AmigaIO *);
 
+void RawIOInit(void);
+int32_t RawPutChar(int32_t c);
+int32_t RawMayGetChar(void);
+
 int OpenDevice(const char *, u_int32_t, struct AmigaIO *, u_int32_t);
 #ifdef _PRIMARY_BOOT
 void CloseDevice(struct AmigaIO *);
diff -r 9b801808214b -r b0580b023e42 sys/arch/amiga/stand/bootblock/boot/libstubs.s
--- a/sys/arch/amiga/stand/bootblock/boot/libstubs.s    Sat Oct 17 10:29:29 2009 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/libstubs.s    Sat Oct 17 11:18:17 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.s,v 1.9 2008/04/28 20:23:13 martin Exp $ */
+/* $NetBSD: libstubs.s,v 1.10 2009/10/17 11:18:18 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -161,6 +161,26 @@
        movl    %d0,%a0                 | Comply with ELF ABI
        rts
 
+ENTRY_NOPROFILE(RawIOInit)
+       movl    %a6,%sp@-
+       movl    %pc@(_C_LABEL(SysBase):w),%a6
+       jsr     %a6@(-0x1f8)
+       movl    %sp@+,%a6
+       rts
+ENTRY_NOPROFILE(RawPutChar)
+       movl    %a6,%sp@-
+       movl    %pc@(_C_LABEL(SysBase):w),%a6
+       movl    %sp@(8),%d0
+       jsr     %a6@(-0x204)
+       movl    %sp@+,%a6
+       rts
+ENTRY_NOPROFILE(RawMayGetChar)
+       movl    %a6,%sp@-
+       movl    %pc@(_C_LABEL(SysBase):w),%a6
+       jsr     %a6@(-0x1fe)
+       movl    %sp@+,%a6
+       rts
+
 #ifndef DOINLINES
 ENTRY_NOPROFILE(CacheClearU)
        movl    %a6,%sp@-



Home | Main Index | Thread Index | Old Index