Date: Mon, 15 Mar 2004 23:28:31 -0500 From: Ken Smith <kensmith@cse.Buffalo.EDU> To: freebsd-sparc64@freebsd.org Subject: Console patch Message-ID: <20040316042831.GB13457@electra.cse.Buffalo.EDU>
next in thread | raw e-mail | index | archive | help
Kris tested this for me and said it works on his system. I've got it installed on two different architecture machines (Sunblade 100 and Ultra-60) and it doesn't seem to break anything on them but they hadn't been horribly broken before. Does anyone see any problems with this? It takes the same approach to the "cninit() must come after mutexes work" problem as the Alpha machines use. I wasn't able to untangle the dependencies that happen during the early phases of booting for me to be able to be comfortable where cninit() needs to go so I have an initial function called early in the boot procedure that makes the OpenFirmware console functional. At that point printf()'s start working but there is still quite a bit of stuff that needs to happen before the normal cninit() can be called. Most of that stuff is ... fragile. There didn't seem to be much I could do that would move the stuff that is critical to cninit() working sooner in the initialization. Minimally it seems to need the bulk of proc0 existing and mutex_init() done. Comments? It seems like this issue should be fixed before I bother posting the 64-bTT ISO so I'll wait a day or so for feedback and then go ahead with the commit if it seems like nobody sees a problem with this. 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 01:51:34 -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,8 @@ static cn_checkc_t ofw_cons_checkc; static cn_putc_t ofw_cons_putc; +int ofw_init_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 +102,24 @@ } 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); +} 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 02:09:21 -0000 @@ -162,6 +162,8 @@ CTASSERT(sizeof(struct pcpu) <= ((PCPU_PAGES * PAGE_SIZE) / 2)); +int ofw_init_boot_console(void); + static void cpu_startup(void *arg) { @@ -275,12 +277,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 +389,11 @@ mutex_init(); intr_init2(); + + /* + * Now initialize the console for real. + */ + cninit(); OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1); -- Ken Smith - From there to here, from here to | kensmith@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel |
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040316042831.GB13457>