From owner-freebsd-sparc64@FreeBSD.ORG Mon Mar 15 21:56:52 2004 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4737E16A4CE for ; Mon, 15 Mar 2004 21:56:52 -0800 (PST) Received: from electra.cse.Buffalo.EDU (electra.cse.Buffalo.EDU [128.205.32.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id DA3EC43D60 for ; Mon, 15 Mar 2004 21:56:51 -0800 (PST) (envelope-from kensmith@cse.Buffalo.EDU) Received: from electra.cse.Buffalo.EDU (kensmith@localhost [127.0.0.1]) i2G5up2Z015407 for ; Tue, 16 Mar 2004 00:56:51 -0500 (EST) Received: (from kensmith@localhost) by electra.cse.Buffalo.EDU (8.12.10/8.12.9/Submit) id i2G5up6I015406 for freebsd-sparc64@freebsd.org; Tue, 16 Mar 2004 00:56:51 -0500 (EST) Date: Tue, 16 Mar 2004 00:56:50 -0500 From: Ken Smith To: freebsd-sparc64@freebsd.org Message-ID: <20040316055650.GA15182@electra.cse.Buffalo.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: Console patch part II... X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2004 05:56:52 -0000 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 __FBSDID("$FreeBSD: src/sys/dev/ofw/ofw_console.c,v 1.20 2004/02/21 21:10:45 phk Exp $"); -#include -__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@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel |