[Midnightbsd-cvs] src [8335] trunk/sys/boot/i386: add detection of serial console presense
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 18:55:29 EDT 2016
Revision: 8335
http://svnweb.midnightbsd.org/src/?rev=8335
Author: laffer1
Date: 2016-09-17 18:55:29 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
add detection of serial console presense
Modified Paths:
--------------
trunk/sys/boot/i386/boot2/boot2.c
trunk/sys/boot/i386/boot2/lib.h
trunk/sys/boot/i386/boot2/sio.S
trunk/sys/boot/i386/btx/btx/btx.S
trunk/sys/boot/i386/gptboot/gptboot.c
trunk/sys/boot/i386/zfsboot/zfsboot.c
Modified: trunk/sys/boot/i386/boot2/boot2.c
===================================================================
--- trunk/sys/boot/i386/boot2/boot2.c 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/boot2/boot2.c 2016-09-17 22:55:29 UTC (rev 8335)
@@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/boot/i386/boot2/boot2.c,v 1.3 2011/12/18 19:09:49 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
/* $FreeBSD: src/sys/boot/i386/boot2/boot2.c,v 1.83.2.5.2.1 2008/11/25 02:59:29 kensmith Exp $ */
#include <sys/param.h>
@@ -418,8 +418,10 @@
}
ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
- if (ioctrl & IO_SERIAL)
- sio_init(115200 / comspeed);
+ if (ioctrl & IO_SERIAL) {
+ if (sio_init(115200 / comspeed) != 0)
+ ioctrl &= ~IO_SERIAL;
+ }
} else {
for (q = arg--; *q && *q != '('; q++);
if (*q) {
Modified: trunk/sys/boot/i386/boot2/lib.h
===================================================================
--- trunk/sys/boot/i386/boot2/lib.h 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/boot2/lib.h 2016-09-17 22:55:29 UTC (rev 8335)
@@ -17,8 +17,8 @@
* $FreeBSD$
*/
-void sio_init(int) __attribute__((regparm (3)));
-void sio_flush(void);
+int sio_init(int) __attribute__((regparm (3)));
+int sio_flush(void);
void sio_putc(int) __attribute__((regparm (3)));
int sio_getc(void);
int sio_ischar(void);
Modified: trunk/sys/boot/i386/boot2/sio.S
===================================================================
--- trunk/sys/boot/i386/boot2/sio.S 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/boot2/sio.S 2016-09-17 22:55:29 UTC (rev 8335)
@@ -24,7 +24,7 @@
.globl sio_getc
.globl sio_ischar
-/* void sio_init(int div) */
+/* int sio_init(int div) */
sio_init: pushl %eax
movw $SIO_PRT+0x3,%dx # Data format reg
@@ -43,12 +43,16 @@
call sio_flush
ret
-/* void sio_flush(void) */
+/* int sio_flush(void) */
-sio_flush.0: call sio_getc.1 # Get character
-sio_flush: call sio_ischar # Check for character
- jnz sio_flush.0 # Till none
- ret # To caller
+sio_flush: xorl %eax,%eax # Return value
+ xorl %ecx,%ecx # Timeout
+ movb $0x80,%ch # counter
+sio_flush.1: call sio_ischar # Check for character
+ jz sio_flush.2 # Till none
+ loop sio_flush.1 # or counter is zero
+ movb $1, %al # Exhausted all tries
+sio_flush.2: ret # To caller
/* void sio_putc(int c) */
Modified: trunk/sys/boot/i386/btx/btx/btx.S
===================================================================
--- trunk/sys/boot/i386/btx/btx/btx.S 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/btx/btx/btx.S 2016-09-17 22:55:29 UTC (rev 8335)
@@ -812,7 +812,7 @@
.set SIO_DIV,(115200/SIOSPD) # 115200 / SPD
/*
- * void sio_init(void)
+ * int sio_init(void)
*/
sio_init: movw $SIO_PRT+0x3,%dx # Data format reg
movb $SIO_FMT|0x80,%al # Set format
@@ -828,14 +828,19 @@
movb $0x3,%al # Set RTS,
outb %al,(%dx) # DTR
incl %edx # Line status reg
+ call sio_getc.1 # Get character
/*
- * void sio_flush(void)
+ * int sio_flush(void)
*/
-sio_flush.0: call sio_getc.1 # Get character
-sio_flush: call sio_ischar # Check for character
- jnz sio_flush.0 # Till none
- ret # To caller
+sio_flush: xorl %eax,%eax # Return value
+ xorl %ecx,%ecx # Timeout
+ movb $0x80,%ch # counter
+sio_flush.1: call sio_ischar # Check for character
+ jz sio_flush.2 # Till none
+ loop sio_flush.1 # or counter is zero
+ movb $1, %al # Exhausted all tries
+sio_flush.2: ret # To caller
/*
* void sio_putc(int c)
Modified: trunk/sys/boot/i386/gptboot/gptboot.c
===================================================================
--- trunk/sys/boot/i386/gptboot/gptboot.c 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/gptboot/gptboot.c 2016-09-17 22:55:29 UTC (rev 8335)
@@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/boot/i386/gptboot/gptboot.c,v 1.3 2011/12/18 19:09:49 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
#include <sys/param.h>
#include <sys/gpt.h>
@@ -380,8 +380,10 @@
}
ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
- if (ioctrl & IO_SERIAL)
- sio_init(115200 / comspeed);
+ if (ioctrl & IO_SERIAL) {
+ if (sio_init(115200 / comspeed) != 0)
+ ioctrl &= ~IO_SERIAL;
+ }
} else {
for (q = arg--; *q && *q != '('; q++);
if (*q) {
Modified: trunk/sys/boot/i386/zfsboot/zfsboot.c
===================================================================
--- trunk/sys/boot/i386/zfsboot/zfsboot.c 2016-09-17 22:55:09 UTC (rev 8334)
+++ trunk/sys/boot/i386/zfsboot/zfsboot.c 2016-09-17 22:55:29 UTC (rev 8335)
@@ -785,8 +785,10 @@
}
ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
- if (ioctrl & IO_SERIAL)
- sio_init(115200 / comspeed);
+ if (ioctrl & IO_SERIAL) {
+ if (sio_init(115200 / comspeed) != 0)
+ ioctrl &= ~IO_SERIAL;
+ }
} if (c == '?') {
dnode_phys_t dn;
More information about the Midnightbsd-cvs
mailing list