Module Name:    src
Committed By:   mlelstv
Date:           Sat Oct 17 11:18:18 UTC 2009

Modified Files:
        src/sys/arch/amiga/stand/bootblock/boot: Makefile console.c libstubs.h
            libstubs.s

Log Message:
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'.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amiga/stand/bootblock/boot/Makefile
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amiga/stand/bootblock/boot/console.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.39 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.40
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.39	Mon Jan 12 07:42:30 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Sat Oct 17 11:18:17 2009
@@ -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 \

Index: src/sys/arch/amiga/stand/bootblock/boot/console.c
diff -u src/sys/arch/amiga/stand/bootblock/boot/console.c:1.12 src/sys/arch/amiga/stand/bootblock/boot/console.c:1.13
--- src/sys/arch/amiga/stand/bootblock/boot/console.c:1.12	Sun Oct 11 10:00:10 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/console.c	Sat Oct 17 11:18:18 2009
@@ -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;
 }

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.6 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.7
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.6	Mon Apr 28 20:23:13 2008
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.h	Sat Oct 17 11:18:18 2009
@@ -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 *);

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.9 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.10
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.9	Mon Apr 28 20:23:13 2008
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.s	Sat Oct 17 11:18:18 2009
@@ -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,%...@-
+	movl	%pc@(_C_LABEL(SysBase):w),%a6
+	jsr	%a6@(-0x1f8)
+	movl	%...@+,%a6
+	rts
+ENTRY_NOPROFILE(RawPutChar)
+	movl	%a6,%...@-
+	movl	%pc@(_C_LABEL(SysBase):w),%a6
+	movl	%sp@(8),%d0
+	jsr	%a6@(-0x204)
+	movl	%...@+,%a6
+	rts
+ENTRY_NOPROFILE(RawMayGetChar)
+	movl	%a6,%...@-
+	movl	%pc@(_C_LABEL(SysBase):w),%a6
+	jsr	%a6@(-0x1fe)
+	movl	%...@+,%a6
+	rts
+
 #ifndef DOINLINES
 ENTRY_NOPROFILE(CacheClearU)
 	movl	%a6,%...@-

Reply via email to