Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Nov 2009 03:55:42 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199855 - in head/sys/boot: forth i386/libi386 i386/loader pc98/loader
Message-ID:  <200911270355.nAR3tgqp001311@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Fri Nov 27 03:55:42 2009
New Revision: 199855
URL: http://svn.freebsd.org/changeset/base/199855

Log:
  Add new loader console type: "spinconsole". This console selects the
  video console which doesn't take any input from keyboard and hides
  all output replacing it with ``spinning'' character (useful for
  embedded products and custom installations).
  
  Sponsored by:	Sippy Software, Inc.

Added:
  head/sys/boot/i386/libi386/spinconsole.c
     - copied, changed from r199821, head/sys/boot/i386/libi386/nullconsole.c
Modified:
  head/sys/boot/forth/loader.conf.5
  head/sys/boot/i386/libi386/Makefile
  head/sys/boot/i386/libi386/vidconsole.c
  head/sys/boot/i386/loader/conf.c
  head/sys/boot/pc98/loader/conf.c

Modified: head/sys/boot/forth/loader.conf.5
==============================================================================
--- head/sys/boot/forth/loader.conf.5	Fri Nov 27 02:47:49 2009	(r199854)
+++ head/sys/boot/forth/loader.conf.5	Fri Nov 27 03:55:42 2009	(r199855)
@@ -180,10 +180,15 @@ serial port speed setting.
 .Dq comconsole
 selects serial console,
 .Dq vidconsole
-selects the video console, and
+selects the video console,
 .Dq nullconsole
 selects a mute console
-(useful for systems with neither a video console nor a serial port).
+(useful for systems with neither a video console nor a serial port), and
+.Dq spinconsole
+selects the video console which prevents any input and hides all output
+replacing it with
+.Dq spinning
+character (useful for embedded products and such).
 .It Va kernel
 .Pq Dq Pa /boot/kernel/kernel
 .It Va loader_conf_files

Modified: head/sys/boot/i386/libi386/Makefile
==============================================================================
--- head/sys/boot/i386/libi386/Makefile	Fri Nov 27 02:47:49 2009	(r199854)
+++ head/sys/boot/i386/libi386/Makefile	Fri Nov 27 03:55:42 2009	(r199855)
@@ -8,7 +8,7 @@ SRCS=	biosacpi.c bioscd.c biosdisk.c bio
 	comconsole.c devicename.c elf32_freebsd.c \
 	elf64_freebsd.c \
 	i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
-	smbios.c time.c vidconsole.c amd64_tramp.S
+	smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
 
 # Enable PXE TFTP or NFS support, not both.
 .if defined(LOADER_TFTP_SUPPORT)

Copied and modified: head/sys/boot/i386/libi386/spinconsole.c (from r199821, head/sys/boot/i386/libi386/nullconsole.c)
==============================================================================
--- head/sys/boot/i386/libi386/nullconsole.c	Thu Nov 26 08:49:46 2009	(r199821, copy source)
+++ head/sys/boot/i386/libi386/spinconsole.c	Fri Nov 27 03:55:42 2009	(r199855)
@@ -1,8 +1,8 @@
 /*-
- * nullconsole.c
+ * spinconsole.c
  *
- * Author: Doug Ambrisko <ambrisko@whistle.com>
- * Copyright (c) 2000 Whistle Communications, Inc.
+ * Author: Maksym Sobolyev <sobomax@sippysoft.com>
+ * Copyright (c) 2009 Sippy Software, Inc.
  * All rights reserved.
  * 
  * Subject to the following obligations and disclaimer of warranty, use and
@@ -41,48 +41,66 @@ __FBSDID("$FreeBSD$");
 #include <stand.h>
 #include <bootstrap.h>
 
-static void	nullc_probe(struct console *cp);
-static int	nullc_init(int arg);
-static void	nullc_putchar(int c);
-static int	nullc_getchar(void);
-static int	nullc_ischar(void);
-
-struct console nullconsole = {
-	"nullconsole",
-	"null port",
+extern void get_pos(int *x, int *y);
+extern void curs_move(int *_x, int *_y, int x, int y);
+extern void vidc_biosputchar(int c);
+
+static void	spinc_probe(struct console *cp);
+static int	spinc_init(int arg);
+static void	spinc_putchar(int c);
+static int	spinc_getchar(void);
+static int	spinc_ischar(void);
+
+struct console spinconsole = {
+	"spinconsole",
+	"spin port",
 	0,
-	nullc_probe,
-	nullc_init,
-	nullc_putchar,
-	nullc_getchar,
-	nullc_ischar
+	spinc_probe,
+	spinc_init,
+	spinc_putchar,
+	spinc_getchar,
+	spinc_ischar
 };
 
 static void
-nullc_probe(struct console *cp)
+spinc_probe(struct console *cp)
 {
 	cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
 }
 
 static int
-nullc_init(int arg)
+spinc_init(int arg)
 {
 	return(0);
 }
 
 static void
-nullc_putchar(int c)
+spinc_putchar(int c)
 {
+	static int curx, cury;
+	static unsigned tw_chars = 0x5C2D2F7C;    /* "\-/|" */
+        static time_t lasttime;
+	time_t now;
+
+        now = time(NULL);
+        if (now < (lasttime + 1))
+            return;
+        lasttime = now;
+	get_pos(&curx, &cury);
+	if (curx > 0)
+		curs_move(&curx, &cury, curx - 1, cury);
+	vidc_biosputchar((char)tw_chars);
+	tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24);
 }
 
 static int
-nullc_getchar(void)
+spinc_getchar(void)
 {
 	return(-1);
 }
 
 static int
-nullc_ischar(void)
+spinc_ischar(void)
 {
 	return(0);
 }

Modified: head/sys/boot/i386/libi386/vidconsole.c
==============================================================================
--- head/sys/boot/i386/libi386/vidconsole.c	Fri Nov 27 02:47:49 2009	(r199854)
+++ head/sys/boot/i386/libi386/vidconsole.c	Fri Nov 27 03:55:42 2009	(r199855)
@@ -57,8 +57,8 @@ static int	vidc_started;
 void		end_term(void);
 void		bail_out(int c);
 void		vidc_term_emu(int c);
-void		get_pos(void);
-void		curs_move(int x, int y);
+void		get_pos(int *x, int *y);
+void		curs_move(int *_x, int *_y, int x, int y);
 void		write_char(int c, int fg, int bg);
 void		scroll_up(int rows, int fg, int bg);
 void		CD(void);
@@ -110,8 +110,8 @@ vidc_init(int arg)
 #ifdef TERM_EMU
     /* Init terminal emulator */
     end_term();
-    get_pos();
-    curs_move(curx, cury);
+    get_pos(&curx, &cury);
+    curs_move(&curx, &cury, curx, cury);
     fg_c = DEFAULT_FGCOLOR;
     bg_c = DEFAULT_BGCOLOR;
 #endif
@@ -120,7 +120,7 @@ vidc_init(int arg)
     return (0);	/* XXX reinit? */
 }
 
-static void
+void
 vidc_biosputchar(int c)
 {
 
@@ -151,7 +151,7 @@ vidc_rawputchar(int c)
 	    return;
 	case '\r':
 	    curx = 0;
-	    curs_move(curx, cury);
+	    curs_move(&curx, &cury, curx, cury);
 	    return;
 	case '\n':
 	    cury++;
@@ -159,13 +159,13 @@ vidc_rawputchar(int c)
 		scroll_up(1, fg_c, bg_c);
 		cury--;
 	    } else {
-		curs_move(curx, cury);
+		curs_move(&curx, &cury, curx, cury);
 	    }
 	    return;
 	case '\b':
 	    if (curx > 0) {
 		curx--;
-		curs_move(curx, cury);
+		curs_move(&curx, &cury, curx, cury);
 		/* write_char(' ', fg_c, bg_c); XXX destructive(!) */
 		return;
 	    }
@@ -183,7 +183,7 @@ vidc_rawputchar(int c)
 		cury--;
 	    }
 	}
-	curs_move(curx, cury);
+	curs_move(&curx, &cury, curx, cury);
 #endif
     }
 }
@@ -194,7 +194,7 @@ vidc_rawputchar(int c)
  * curx and cury appropriately.
  */
 void
-get_pos(void)
+get_pos(int *x, int *y)
 {
 
     v86.ctl = 0;
@@ -202,13 +202,13 @@ get_pos(void)
     v86.eax = 0x0300;
     v86.ebx = 0x0;
     v86int();
-    curx = v86.edx & 0x00ff;
-    cury = (v86.edx & 0xff00) >> 8;
+    *x = v86.edx & 0x00ff;
+    *y = (v86.edx & 0xff00) >> 8;
 }
 
 /* Move cursor to x rows and y cols (0-based). */
 void
-curs_move(int x, int y)
+curs_move(int *_x, int *_y, int x, int y)
 {
 
     v86.ctl = 0;
@@ -217,8 +217,8 @@ curs_move(int x, int y)
     v86.ebx = 0x0;
     v86.edx = ((0x00ff & y) << 8) + (0x00ff & x);
     v86int();
-    curx = x;
-    cury = y;
+    *_x = x;
+    *_y = y;
     /* If there is ctrl char at this position, cursor would be invisible.
      * Make it a space instead.
      */
@@ -277,7 +277,7 @@ void
 CD(void)
 {
 
-    get_pos();
+    get_pos(&curx, &cury);
     if (curx > 0) {
 	v86.ctl = 0;
 	v86.addr = 0x10;
@@ -312,7 +312,7 @@ CM(void)
 	args[0]--;
     if (args[1] > 0)
 	args[1]--;
-    curs_move(args[1], args[0]);
+    curs_move(&curx, &cury, args[1], args[0]);
     end_term();
 }
 

Modified: head/sys/boot/i386/loader/conf.c
==============================================================================
--- head/sys/boot/i386/loader/conf.c	Fri Nov 27 02:47:49 2009	(r199854)
+++ head/sys/boot/i386/loader/conf.c	Fri Nov 27 03:55:42 2009	(r199855)
@@ -128,6 +128,7 @@ extern struct console comconsole;
 extern struct console dconsole;
 #endif
 extern struct console nullconsole;
+extern struct console spinconsole;
 
 struct console *consoles[] = {
     &vidconsole,
@@ -136,6 +137,7 @@ struct console *consoles[] = {
     &dconsole,
 #endif
     &nullconsole,
+    &spinconsole,
     NULL
 };
 

Modified: head/sys/boot/pc98/loader/conf.c
==============================================================================
--- head/sys/boot/pc98/loader/conf.c	Fri Nov 27 02:47:49 2009	(r199854)
+++ head/sys/boot/pc98/loader/conf.c	Fri Nov 27 03:55:42 2009	(r199855)
@@ -100,11 +100,13 @@ struct file_format *file_formats[] = {
 extern struct console vidconsole;
 extern struct console comconsole;
 extern struct console nullconsole;
+extern struct console spinconsole;
 
 struct console *consoles[] = {
     &vidconsole,
     &comconsole,
     &nullconsole,
+    &spinconsole,
     NULL
 };
 



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