Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Oct 2012 20:08:29 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241301 - in head/sys/boot/i386: boot2 btx/btx gptboot zfsboot
Message-ID:  <201210062008.q96K8TiX032052@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sat Oct  6 20:08:29 2012
New Revision: 241301
URL: http://svn.freebsd.org/changeset/base/241301

Log:
  add detection of serial console presence to btx and boot2-like blocks
  
  Note that this commit slightly increases size of boot blocks.
  
  Reviewed by:	jhb
  Tested by:	Olivier Cochard-Labbe <olivier@cochard.me>
  MFC after:	26 days

Modified:
  head/sys/boot/i386/boot2/boot2.c
  head/sys/boot/i386/boot2/lib.h
  head/sys/boot/i386/boot2/sio.S
  head/sys/boot/i386/btx/btx/btx.S
  head/sys/boot/i386/gptboot/gptboot.c
  head/sys/boot/i386/zfsboot/zfsboot.c

Modified: head/sys/boot/i386/boot2/boot2.c
==============================================================================
--- head/sys/boot/i386/boot2/boot2.c	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/boot2/boot2.c	Sat Oct  6 20:08:29 2012	(r241301)
@@ -415,8 +415,10 @@ parse()
 	    }
 	    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: head/sys/boot/i386/boot2/lib.h
==============================================================================
--- head/sys/boot/i386/boot2/lib.h	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/boot2/lib.h	Sat Oct  6 20:08:29 2012	(r241301)
@@ -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: head/sys/boot/i386/boot2/sio.S
==============================================================================
--- head/sys/boot/i386/boot2/sio.S	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/boot2/sio.S	Sat Oct  6 20:08:29 2012	(r241301)
@@ -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 @@ sio_init:	pushl %eax
 		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: head/sys/boot/i386/btx/btx/btx.S
==============================================================================
--- head/sys/boot/i386/btx/btx/btx.S	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/btx/btx/btx.S	Sat Oct  6 20:08:29 2012	(r241301)
@@ -812,7 +812,7 @@ putstr: 	lodsb				# Load char
 		.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 @@ sio_init:	movw $SIO_PRT+0x3,%dx		# Data 
 		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: head/sys/boot/i386/gptboot/gptboot.c
==============================================================================
--- head/sys/boot/i386/gptboot/gptboot.c	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/gptboot/gptboot.c	Sat Oct  6 20:08:29 2012	(r241301)
@@ -379,8 +379,10 @@ parse(char *cmdstr, int *dskupdated)
 	    }
 	    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: head/sys/boot/i386/zfsboot/zfsboot.c
==============================================================================
--- head/sys/boot/i386/zfsboot/zfsboot.c	Sat Oct  6 20:04:51 2012	(r241300)
+++ head/sys/boot/i386/zfsboot/zfsboot.c	Sat Oct  6 20:08:29 2012	(r241301)
@@ -785,8 +785,10 @@ parse(void)
 	    }
 	    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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210062008.q96K8TiX032052>