Console patch part II...
Ken Smith
kensmith at cse.Buffalo.EDU
Mon Mar 15 21:56:52 PST 2004
Ok, this won't fix Kris's keyboard problem but I think it's the right
patch for the initial problem. As described in the previous message
cninit() needs to be moved.
With a GENERIC kernel this patch seems to work fine, even on the
Ultra-60 that has the Creator-3D on it (but remember, *GENERIC*
kernel so no support for Creator-3D at this point). It's also
working with the Sunblade-100's serial console, and the Ultra-60
if I disconnect the keyboard and use a serial console.
With a custom kernel with the Creator-3D support compiled in and
device adjustments as typically recommended (add sc, uart, puc;
remove sab and zs) the uart code stops working properly. If
you take a look at dev/uart_kbd_sun.c it looks like there is a
lot of unfinished stuff there. I think having the ofw console
opened is putting the keyboard's uart into something other than
its normal default-after-reset state and the uart code isn't
handling that very well. With this kernel if I just press one
key on the keyboard a debug printf() in sunkbd_read_char() starts
to print endlessly (looping there...).
So, I think I need to commit this patch to solve the cninit()
issue and then deal with getting the uart code to properly initialize
the uart for the keyboard.
Comments? Thanks...
Index: dev/ofw/ofw_console.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ofw/ofw_console.c,v
retrieving revision 1.20
diff -u -r1.20 ofw_console.c
--- dev/ofw/ofw_console.c 21 Feb 2004 21:10:45 -0000 1.20
+++ dev/ofw/ofw_console.c 16 Mar 2004 04:48:06 -0000
@@ -26,9 +26,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/dev/ofw/ofw_console.c,v 1.20 2004/02/21 21:10:45 phk Exp $");
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ofw/ofw_console.c,v 1.20 2004/02/21 21:10:45 phk Exp $");
-
#include "opt_ddb.h"
#include "opt_comconsole.h"
@@ -80,6 +77,9 @@
static cn_checkc_t ofw_cons_checkc;
static cn_putc_t ofw_cons_putc;
+int ofw_init_boot_console(void);
+void ofw_remove_boot_console(void);
+
CONS_DRIVER(ofw, ofw_cons_probe, ofw_cons_init, NULL, ofw_cons_getc,
ofw_cons_checkc, ofw_cons_putc, NULL);
@@ -103,6 +103,32 @@
}
SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL)
+
+/*
+ * Support for adding an OFW console very early in the boot process,
+ * before the machine is really ready for a full cninit().
+ */
+
+int
+ofw_init_boot_console(void)
+{
+ struct consdev *cn = &ofw_consdev;
+
+ cn->cn_probe(cn);
+ if (cn->cn_pri == CN_DEAD)
+ return(ENODEV);
+ cnadd(cn);
+ cn->cn_init(cn);
+ return(0);
+}
+
+void
+ofw_remove_boot_console(void)
+{
+ struct consdev *cn = &ofw_consdev;
+
+ cnremove(cn);
+}
static int stdin;
static int stdout;
Index: sparc64/sparc64/machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/sparc64/sparc64/machdep.c,v
retrieving revision 1.106
diff -u -r1.106 machdep.c
--- sparc64/sparc64/machdep.c 3 Jan 2004 02:02:26 -0000 1.106
+++ sparc64/sparc64/machdep.c 16 Mar 2004 04:48:58 -0000
@@ -162,6 +162,9 @@
CTASSERT(sizeof(struct pcpu) <= ((PCPU_PAGES * PAGE_SIZE) / 2));
+int ofw_init_boot_console(void);
+void ofw_remove_boot_console(void);
+
static void
cpu_startup(void *arg)
{
@@ -275,12 +278,15 @@
tick_init(clock);
/*
- * Initialize the console before printing anything.
+ * Initialize the Open Firmware console before printing anything.
+ * Call cninit() later when it's safe, need to be ready for
+ * mutexes to work before we can call cninit().
*/
- cninit();
+ if (ofw_init_boot_console())
+ panic("No Open Firmware console");
/*
- * Panic is there is no metadata. Most likely the kernel was booted
+ * Panic if there is no metadata. Most likely the kernel was booted
* directly, instead of through loader(8).
*/
if (mdp == NULL || kmdp == NULL) {
@@ -384,6 +390,12 @@
mutex_init();
intr_init2();
+
+ /*
+ * Now initialize the console for real.
+ */
+ ofw_remove_boot_console();
+ cninit();
OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1);
--
Ken Smith
- From there to here, from here to | kensmith at cse.buffalo.edu
there, funny things are everywhere. |
- Theodore Geisel |
More information about the freebsd-sparc64
mailing list