From c92d076f5ba7eb7b869da61aa25a8c81ef4d2463 Mon Sep 17 00:00:00 2001 From: pk Date: Sun, 17 Sep 1995 20:43:39 +0000 Subject: [PATCH] Change interface to th `fb' pseudo device to not need the major device number (a la sun3). Put in new glue for rcons. --- sys/arch/sparc/dev/bwtwo.c | 23 ++++++------ sys/arch/sparc/dev/cgsix.c | 19 +++++----- sys/arch/sparc/dev/cgthree.c | 19 +++++----- sys/arch/sparc/dev/fb.c | 68 +++++++++++++++++++++++++++++++++--- 4 files changed, 98 insertions(+), 31 deletions(-) diff --git a/sys/arch/sparc/dev/bwtwo.c b/sys/arch/sparc/dev/bwtwo.c index 4428fa5c338b..ca154e8d221f 100644 --- a/sys/arch/sparc/dev/bwtwo.c +++ b/sys/arch/sparc/dev/bwtwo.c @@ -1,4 +1,4 @@ -/* $NetBSD: bwtwo.c,v 1.10 1995/08/29 22:20:01 pk Exp $ */ +/* $NetBSD: bwtwo.c,v 1.11 1995/09/17 20:43:39 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -80,8 +80,14 @@ struct bwtwo_softc { }; /* autoconfiguration driver */ -static void bwtwoattach(struct device *, struct device *, void *); -static int bwtwomatch(struct device *, void *, void *); +static void bwtwoattach __P((struct device *, struct device *, void *)); +static int bwtwomatch __P((struct device *, void *, void *)); +int bwtwoopen __P((dev_t, int, int, struct proc *)); +int bwtwoclose __P((dev_t, int, int, struct proc *)); +int bwtwoioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); +int bwtwommap __P((dev_t, int, int)); +static void bwtwounblank __P((struct device *)); + struct cfdriver bwtwocd = { NULL, "bwtwo", bwtwomatch, bwtwoattach, DV_DULL, sizeof(struct bwtwo_softc) }; @@ -89,8 +95,9 @@ struct cfdriver bwtwocd = /* XXX we do not handle frame buffer interrupts (do not know how) */ /* frame buffer generic driver */ -static void bwtwounblank(struct device *); -static struct fbdriver bwtwofbdriver = { bwtwounblank }; +static struct fbdriver bwtwofbdriver = { + bwtwounblank, bwtwoopen, bwtwoclose, bwtwoioctl, bwtwommap +}; extern int fbnode; extern struct tty *fbconstty; @@ -99,8 +106,6 @@ extern int nullop(); static int bwtwo_cnputc(); static struct bwtwo_softc *bwcons; -#define BWTWO_MAJOR 27 /* XXX */ - /* * Match a bwtwo. */ @@ -143,8 +148,6 @@ bwtwoattach(parent, self, args) int sbus = 1; char *nam; - sc->sc_fb.fb_major = BWTWO_MAJOR; /* XXX to be removed */ - sc->sc_fb.fb_driver = &bwtwofbdriver; sc->sc_fb.fb_device = &sc->sc_dev; /* @@ -263,7 +266,7 @@ bwtwoattach(parent, self, args) #ifdef RCONSOLE /* XXX: doesn't work (??) on Sun 4 yet. */ if (cputyp != CPU_SUN4) - rcons_init(&sc->sc_fb); + fbrcons_init(&sc->sc_fb); #endif } else printf("\n"); diff --git a/sys/arch/sparc/dev/cgsix.c b/sys/arch/sparc/dev/cgsix.c index e6fc58cc0c79..b2455e344c86 100644 --- a/sys/arch/sparc/dev/cgsix.c +++ b/sys/arch/sparc/dev/cgsix.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgsix.c,v 1.14 1995/08/29 22:26:37 pk Exp $ */ +/* $NetBSD: cgsix.c,v 1.15 1995/09/17 20:43:43 pk Exp $ */ /* * Copyright (c) 1993 @@ -110,13 +110,20 @@ struct cgsix_softc { /* autoconfiguration driver */ static void cgsixattach __P((struct device *, struct device *, void *)); static int cgsixmatch __P((struct device *, void *, void *)); +int cgsixopen __P((dev_t, int, int, struct proc *)); +int cgsixclose __P((dev_t, int, int, struct proc *)); +int cgsixioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); +int cgsixmmap __P((dev_t, int, int)); +static void cg6_unblank __P((struct device *)); + struct cfdriver cgsixcd = { NULL, "cgsix", cgsixmatch, cgsixattach, DV_DULL, sizeof(struct cgsix_softc) }; /* frame buffer generic driver */ -static void cg6_unblank __P((struct device *)); -static struct fbdriver cg6_fbdriver = { cg6_unblank }; +static struct fbdriver cg6_fbdriver = { + cg6_unblank, cgsixopen, cgsixclose, cgsixioctl, cgsixmmap +}; /* * Unlike the bw2 and cg3 drivers, we do not need to provide an rconsole @@ -125,8 +132,6 @@ static struct fbdriver cg6_fbdriver = { cg6_unblank }; extern int fbnode; -#define CGSIX_MAJOR 67 /* XXX */ - static void cg6_reset __P((struct cgsix_softc *)); static void cg6_loadcmap __P((struct cgsix_softc *, int, int)); static void cg6_loadomap __P((struct cgsix_softc *)); @@ -174,9 +179,7 @@ cgsixattach(parent, self, args) register volatile struct cg6_layout *p; int sbus = 1; char *nam; -extern struct tty *fbconstty; - - sc->sc_fb.fb_major = CGSIX_MAJOR; /* XXX to be removed */ + extern struct tty *fbconstty; sc->sc_fb.fb_driver = &cg6_fbdriver; sc->sc_fb.fb_device = &sc->sc_dev; diff --git a/sys/arch/sparc/dev/cgthree.c b/sys/arch/sparc/dev/cgthree.c index 6c8847312b0b..d1b0e6650f15 100644 --- a/sys/arch/sparc/dev/cgthree.c +++ b/sys/arch/sparc/dev/cgthree.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgthree.c,v 1.13 1995/04/10 07:04:22 mycroft Exp $ */ +/* $NetBSD: cgthree.c,v 1.14 1995/09/17 20:43:49 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -86,14 +86,21 @@ struct cgthree_softc { /* autoconfiguration driver */ static void cgthreeattach(struct device *, struct device *, void *); static int cgthreematch(struct device *, void *, void *); +int cgthreeopen __P((dev_t, int, int, struct proc *)); +int cgthreeclose __P((dev_t, int, int, struct proc *)); +int cgthreeioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); +int cgthreemmap __P((dev_t, int, int)); +static void cgthreeunblank(struct device *); + struct cfdriver cgthreecd = { NULL, "cgthree", cgthreematch, cgthreeattach, DV_DULL, sizeof(struct cgthree_softc) }; /* frame buffer generic driver */ -static void cgthreeunblank(struct device *); -static struct fbdriver cgthreefbdriver = { cgthreeunblank }; +static struct fbdriver cgthreefbdriver = { + cgthreeunblank, cgthreeopen, cgthreeclose, cgthreeioctl, cgthreemmap +}; extern int fbnode; extern struct tty *fbconstty; @@ -103,8 +110,6 @@ static int cgthree_cnputc(); static void cgthreeloadcmap __P((struct cgthree_softc *, int, int)); -#define CGTHREE_MAJOR 55 /* XXX */ - /* * Match a cgthree. */ @@ -142,8 +147,6 @@ cgthreeattach(parent, self, args) int sbus = 1; char *nam; - sc->sc_fb.fb_major = CGTHREE_MAJOR; /* XXX to be removed */ - sc->sc_fb.fb_driver = &cgthreefbdriver; sc->sc_fb.fb_device = &sc->sc_dev; /* @@ -207,7 +210,7 @@ cgthreeattach(parent, self, args) if (isconsole) { printf(" (console)\n"); #ifdef RCONSOLE - rcons_init(&sc->sc_fb); + fbrcons_init(&sc->sc_fb); #endif } else printf("\n"); diff --git a/sys/arch/sparc/dev/fb.c b/sys/arch/sparc/dev/fb.c index 51d08440fc0f..a64f5721819b 100644 --- a/sys/arch/sparc/dev/fb.c +++ b/sys/arch/sparc/dev/fb.c @@ -1,4 +1,4 @@ -/* $NetBSD: fb.c,v 1.6 1995/04/10 07:04:18 mycroft Exp $ */ +/* $NetBSD: fb.c,v 1.7 1995/09/17 20:43:45 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -85,7 +85,7 @@ fbopen(dev, flags, mode, p) if (devfb == NULL) return (ENXIO); - return (cdevsw[devfb->fb_major].d_open(dev, flags, mode, p)); + return (devfb->fb_driver->fbd_open)(dev, flags, mode, p); } int @@ -95,7 +95,7 @@ fbclose(dev, flags, mode, p) struct proc *p; { - return (cdevsw[devfb->fb_major].d_close(dev, flags, mode, p)); + return (devfb->fb_driver->fbd_close)(dev, flags, mode, p); } int @@ -107,7 +107,7 @@ fbioctl(dev, cmd, data, flags, p) struct proc *p; { - return (cdevsw[devfb->fb_major].d_ioctl(dev, cmd, data, flags, p)); + return (devfb->fb_driver->fbd_ioctl)(dev, cmd, data, flags, p); } int @@ -115,9 +115,67 @@ fbmmap(dev, off, prot) dev_t dev; int off, prot; { - int (*map)() = cdevsw[devfb->fb_major].d_mmap; + int (*map)__P((dev_t, int, int)) = devfb->fb_driver->fbd_mmap; if (map == NULL) return (-1); return (map(dev, off, prot)); } + +#ifdef RCONSOLE +#include +#include + +extern int (*v_putc) __P((int)); + +static int +a2int(cp, deflt) + register char *cp; + register int deflt; +{ + register int i = 0; + + if (*cp == '\0') + return (deflt); + while (*cp != '\0') + i = i * 10 + *cp++ - '0'; + return (i); +} + +static void +fb_bell(on) + int on; +{ + (void)kbd_docmd(on?KBD_CMD_BELL:KBD_CMD_NOBELL, 0); +} + +void +fbrcons_init(fb) + struct fbdevice *fb; +{ + + /* + * Common glue for rconsole initialization + * XXX - mostly duplicates values with fbdevice. + */ + fb->fb_rcons.rc_linebytes = fb->fb_linebytes; + fb->fb_rcons.rc_pixels = fb->fb_pixels; + fb->fb_rcons.rc_width = fb->fb_type.fb_width; + fb->fb_rcons.rc_height = fb->fb_type.fb_height; + fb->fb_rcons.rc_depth = fb->fb_type.fb_depth; + + fb->fb_rcons.rc_maxcol = + a2int(getpropstring(optionsnode, "screen-#columns"), 80); + fb->fb_rcons.rc_maxrow = + a2int(getpropstring(optionsnode, "screen-#rows"), 34); + + /* Determine addresses of prom emulator row and column */ + if (romgetcursoraddr(&fb->fb_rcons.rc_row, &fb->fb_rcons.rc_col)) + fb->fb_rcons.rc_row = fb->fb_rcons.rc_col = NULL; + + fb->fb_rcons.rc_bell = fb_bell; + rcons_init(&fb->fb_rcons); + /* Hook up virtual console */ + v_putc = (int (*) __P((int)))rcons_cnputc; +} +#endif