changeset 20594:4c0bc9b71395

10200 loader: spinconsole updates Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: John Levon <john.levon@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
author Toomas Soome <tsoome@me.com>
date Thu, 02 Nov 2017 15:42:20 +0200
parents 996d7a50ea16
children 90242035d8ac
files usr/src/boot/sys/boot/i386/libi386/spinconsole.c
diffstat 1 files changed, 32 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/boot/sys/boot/i386/libi386/spinconsole.c	Thu Jan 26 02:46:55 2017 +0200
+++ b/usr/src/boot/sys/boot/i386/libi386/spinconsole.c	Thu Nov 02 15:42:20 2017 +0200
@@ -63,46 +63,64 @@
 static void
 spinc_probe(struct console *cp)
 {
-	cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
+	int i;
+	struct console *parent;
+
+	if (cp->c_private == NULL) {
+		for (i = 0; consoles[i] != NULL; i++)
+			if (strcmp(consoles[i]->c_name, "text") == 0)
+				break;
+		cp->c_private = consoles[i];
+	}
+
+	parent = cp->c_private;
+	if (parent != NULL)
+		parent->c_probe(cp);
 }
 
 static int
-spinc_init(struct console *cp __unused, int arg __unused)
+spinc_init(struct console *cp, int arg)
 {
-	return(0);
+	struct console *parent;
+
+	parent = cp->c_private;
+	if (parent != NULL)
+		return (parent->c_init(cp, arg));
+	else
+		return (0);
 }
 
 static void
-spinc_putchar(struct console *cp __unused, int c __unused)
+spinc_putchar(struct console *cp, int c __unused)
 {
 	static unsigned tw_chars = 0x5C2D2F7C;    /* "\-/|" */
-	static time_t lasttime;
-	int i;
+	static time_t lasttime = 0;
+	struct console *parent;
 	time_t now;
 
 	now = time(NULL);
 	if (now < (lasttime + 1))
 		return;
 	lasttime = now;
-	for (i = 0; consoles[i] != NULL; i++)
-		if (strcmp(consoles[i]->c_name, "text") == 0)
-			break;
-	if (consoles[i] == NULL)
+	parent = cp->c_private;
+	if (parent == NULL)
 		return;
 
-	consoles[i]->c_out(consoles[i], (char)tw_chars);
-	consoles[i]->c_out(consoles[i], '\b');
+	parent->c_out(parent, (char)tw_chars);
+	parent->c_out(parent, '\b');
 	tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24);
 }
 
 static int
 spinc_getchar(struct console *cp __unused)
 {
-	return(-1);
+
+	return (-1);
 }
 
 static int
 spinc_ischar(struct console *cp __unused)
 {
-	return(0);
+
+	return (0);
 }