From owner-freebsd-sparc64@FreeBSD.ORG Wed Mar 31 09:19:43 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 2F75F16A4CE for ; Wed, 31 Mar 2004 09:19:43 -0800 (PST) Received: from electra.cse.Buffalo.EDU (electra.cse.Buffalo.EDU [128.205.32.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id A6E4F43D45 for ; Wed, 31 Mar 2004 09:19:41 -0800 (PST) (envelope-from kensmith@cse.Buffalo.EDU) Received: from electra.cse.Buffalo.EDU (kensmith@localhost [127.0.0.1]) i2VHJf8o022230 for ; Wed, 31 Mar 2004 12:19:41 -0500 (EST) Received: (from kensmith@localhost) by electra.cse.Buffalo.EDU (8.12.10/8.12.9/Submit) id i2VHJfmb022229 for sparc64@freebsd.org; Wed, 31 Mar 2004 12:19:41 -0500 (EST) Date: Wed, 31 Mar 2004 12:19:41 -0500 From: Ken Smith To: sparc64@freebsd.org Message-ID: <20040331171941.GC21402@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: Fix for syscons... 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: Wed, 31 Mar 2004 17:19:43 -0000 One person has taken a look at this so far and didn't see anything horrible with it so lets see if anyone else notices anything... This patch to sys/dev/syscons/syscons.c seems to work OK on my Ultra-60 with Creator-3D, which is the only machine I'm able to use syscons on. I'm building an i386 kernel with this same patch applied now to see if it causes any problems there. Does anyone see anything wrong with this? Kris, would you mind giving it a try on your Ultra-30? If you do test it don't forget to back out that temp patch I sent you for sys/sparc64/sparc64/machdep.c. It should still work with that patch in place but the point of this patch is to not need that patch. :-) Thanks... Index: syscons.c =================================================================== RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v retrieving revision 1.417 diff -u -r1.417 syscons.c --- syscons.c 18 Mar 2004 21:07:54 -0000 1.417 +++ syscons.c 31 Mar 2004 08:02:48 -0000 @@ -99,6 +99,8 @@ static struct tty *sc_console_tty; static struct consdev *sc_consptr; static void *kernel_console_ts; +static scr_stat main_console; +static dev_t main_devs[MAXCONS]; static char init_done = COLD; static char shutdown_in_progress = FALSE; @@ -151,6 +153,7 @@ static int scparam(struct tty *tp, struct termios *t); static void scstart(struct tty *tp); static void scinit(int unit, int flags); +static scr_stat *sc_get_stat(dev_t devptr); #if !__alpha__ static void scterm(int unit, int flags); #endif @@ -331,7 +334,7 @@ sc = sc_get_softc(unit, flags & SC_KERNEL_CONSOLE); sc->config = flags; - scp = SC_STAT(sc->dev[0]); + scp = sc_get_stat(sc->dev[0]); if (sc_console == NULL) /* sc_console_unit < 0 */ sc_console = scp; @@ -388,6 +391,9 @@ dev = make_dev(&sc_cdevsw, vc + unit * MAXCONS, UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS); sc->dev[vc] = dev; + sc->dev[vc]->si_tty = ttymalloc(sc->dev[vc]->si_tty); + if (vc == 0 && sc->dev == main_devs) + SC_STAT(sc->dev[0]) = &main_console; } /* * The first vty already has struct tty and scr_stat initialized @@ -497,7 +503,7 @@ error = (*linesw[tp->t_line].l_open)(dev, tp); - scp = SC_STAT(dev); + scp = sc_get_stat(dev); if (scp == NULL) { scp = SC_STAT(dev) = alloc_scp(sc, SC_VTY(dev)); if (ISGRAPHSC(scp)) @@ -519,7 +525,7 @@ int s; if (SC_VTY(dev) != SC_CONSOLECTL) { - scp = SC_STAT(tp->t_dev); + scp = sc_get_stat(tp->t_dev); /* were we in the middle of the VT switching process? */ DPRINTF(5, ("sc%d: scclose(), ", scp->sc->unit)); s = spltty(); @@ -682,7 +688,7 @@ return error; #endif - scp = SC_STAT(tp->t_dev); + scp = sc_get_stat(tp->t_dev); /* assert(scp != NULL) */ /* scp is sc_console, if SC_VTY(dev) == SC_CONSOLECTL. */ sc = scp->sc; @@ -1015,7 +1021,7 @@ splx(s); if (error) return error; - scp = SC_STAT(SC_DEV(sc, i)); + scp = sc_get_stat(SC_DEV(sc, i)); if (scp == scp->sc->cur_scp) return 0; while ((error=tsleep(&scp->smode, PZERO|PCATCH, @@ -1353,7 +1359,7 @@ struct clist *rbp; int s, len; u_char buf[PCBURST]; - scr_stat *scp = SC_STAT(tp->t_dev); + scr_stat *scp = sc_get_stat(tp->t_dev); if (scp->status & SLKED || (scp == scp->sc->cur_scp && scp->sc->blink_in_progress)) @@ -1417,7 +1423,7 @@ sc_get_cons_priority(&unit, &flags); scinit(unit, flags | SC_KERNEL_CONSOLE); sc_console_unit = unit; - sc_console = SC_STAT(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]); + sc_console = sc_get_stat(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]); sc_consptr = cp; #endif /* !__alpha__ */ @@ -1475,7 +1481,7 @@ scinit(unit, flags | SC_KERNEL_CONSOLE); sc_console_unit = unit; sc_consptr = &consdev; - sc_console = SC_STAT(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]); + sc_console = sc_get_stat(sc_get_softc(unit, SC_KERNEL_CONSOLE)->dev[0]); sprintf(consdev.cn_name, "ttyv%r", 0); cnadd(&consdev); } @@ -2312,7 +2318,7 @@ ++sc->switch_in_progress; sc->delayed_next_scr = 0; sc->old_scp = cur_scp; - sc->new_scp = SC_STAT(SC_DEV(sc, next_scr)); + sc->new_scp = sc_get_stat(SC_DEV(sc, next_scr)); if (sc->new_scp == sc->old_scp) { sc->switch_in_progress = 0; /* @@ -2624,7 +2630,7 @@ for (i = sc->first_vty; i < sc->first_vty + sc->vtys; ++i) { if ((dev = SC_DEV(sc, i)) == NODEV) continue; - if ((scp = SC_STAT(dev)) == NULL) + if ((scp = sc_get_stat(dev)) == NULL) continue; scp->dflt_curs_attr = sc->curs_attr; change_cursor_shape(scp, CONS_RESET_CURSOR, -1, -1); @@ -2642,9 +2648,6 @@ * static buffers for the console. This is less than ideal, * but is necessry evil for the time being. XXX */ - static scr_stat main_console; - static dev_t main_devs[MAXCONS]; - static struct tty main_tty; #ifdef PC98 static u_short sc_buffer[ROW*COL*2];/* XXX */ #else @@ -2727,11 +2730,12 @@ sc->first_vty = unit*MAXCONS; sc->vtys = MAXCONS; /* XXX: should be configurable */ if (flags & SC_KERNEL_CONSOLE) { + /* + * Set up devs structure but don't use it yet, calling make_dev() + * might panic kernel. Wait for sc_attach_unit() to actually + * create the devices. + */ sc->dev = main_devs; - sc->dev[0] = make_dev(&sc_cdevsw, unit * MAXCONS, - UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS); - sc->dev[0]->si_tty = &main_tty; - ttyregister(&main_tty); scp = &main_console; init_scp(sc, sc->first_vty, scp); sc_vtb_init(&scp->vtb, VTB_MEMORY, scp->xsize, scp->ysize, @@ -2748,8 +2752,8 @@ UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS); sc->dev[0]->si_tty = ttymalloc(sc->dev[0]->si_tty); scp = alloc_scp(sc, sc->first_vty); + SC_STAT(sc->dev[0]) = scp; } - SC_STAT(sc->dev[0]) = scp; sc->cur_scp = scp; #ifndef __sparc64__ @@ -2879,7 +2883,7 @@ vid_release(sc->adp, &sc->adapter); /* stop the terminal emulator, if any */ - scp = SC_STAT(sc->dev[0]); + scp = sc_get_stat(sc->dev[0]); if (scp->tsw) (*scp->tsw->te_term)(scp, &scp->ts); if (scp->ts != NULL) @@ -3412,7 +3416,7 @@ { scr_stat *scp; - scp = SC_STAT(dev); + scp = sc_get_stat(dev); if (scp != scp->sc->cur_scp) return -1; return (*vidsw[scp->sc->adapter]->mmap)(scp->sc->adp, offset, paddr, nprot); @@ -3620,4 +3624,12 @@ scp->sc->blink_in_progress--; timeout(blink_screen, scp, hz / 10); } +} + +static scr_stat * +sc_get_stat(dev_t devptr) +{ + if (devptr == NULL) + return (&main_console); + return (SC_STAT(devptr)); } -- Ken Smith - From there to here, from here to | kensmith@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel |