Date: Sun, 12 Jun 2005 22:09:13 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 78469 for review Message-ID: <200506122209.j5CM9DR7018943@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=78469 Change 78469 by marcel@marcel_nfs on 2005/06/12 22:08:13 Rework the VT initialization. After bus enumeration we have a list of hardware devices (currently only output devices). During SI_SUB_INT_CONFIG_HOOKS we create the initial VT with a corresponding TE and TTY structure. During SI_SUB_VTC we wire up the hardware devices to the initial VT and allow a re-initialization. This allows accelerated graphics drivers to take over from the generic low-level console code and switch to higher resolution graphics modes. Initially all output devices (and input devices when I have a chance to work on that) will be hooked up to a single VT. Affected files ... .. //depot/projects/tty/sys/dev/vtc/hw/vga/vga.c#6 edit .. //depot/projects/tty/sys/dev/vtc/vtc_core.c#8 edit .. //depot/projects/tty/sys/dev/vtc/vtc_te.c#3 edit .. //depot/projects/tty/sys/dev/vtc/vtc_vtout.h#1 add .. //depot/projects/tty/sys/dev/vtc/vtc_vtout_if.m#1 add Differences ... ==== //depot/projects/tty/sys/dev/vtc/hw/vga/vga.c#6 (text+ko) ==== @@ -447,13 +447,25 @@ } static int -vga_bitblt(void *cookie, int op, uintptr_t src, uintptr_t dst, int width, +vga_clear(device_t dev) +{ + struct vga_softc *sc; + + sc = device_get_softc(dev); + + return (vga_bitblt_ctofb(sc, 0, 0, 640, 480)); +} + +static int +vga_bitblt(device_t dev, int op, uintptr_t src, uintptr_t dst, int width, int height, ...) { - struct vga_softc *sc = (struct vga_softc *)cookie; + struct vga_softc *sc; va_list ap; int error; + sc = device_get_softc(dev); + va_start(ap, height); error = vga_vbitblt(sc, op, src, dst, width, height, ap); va_end(ap); @@ -480,5 +492,5 @@ vtc_logo4_height); } - return (vtc_vtout_attach(sc, vga_bitblt, 640, 480)); + return (vtc_vtout_attach(dev, vga_clear, vga_bitblt, 640, 480)); } ==== //depot/projects/tty/sys/dev/vtc/vtc_core.c#8 (text+ko) ==== @@ -31,6 +31,7 @@ #include <sys/systm.h> #include <sys/bus.h> #include <sys/conf.h> +#include <sys/cons.h> #include <sys/kernel.h> #include <sys/kobj.h> #include <sys/malloc.h> @@ -171,24 +172,53 @@ } int -vtc_vtout_attach(void *cookie, vtout_bitblt_f bitblt, int width, int height) +vtc_vtout_attach(device_t dev, vtout_init_f init, vtout_bitblt_f bitblt, + int width, int height) { - struct vtc_te_softc *te; - struct tty *tp; struct vtc_vtout_softc *vo; vo = malloc(sizeof(*vo), M_VTC, M_WAITOK|M_ZERO); TAILQ_INSERT_TAIL(&vtc_vtout_devs, vo, vo_alldevs); - vo->vo_cookie = cookie; + vo->vo_dev = dev; + vo->vo_init = init; vo->vo_bitblt = bitblt; vo->vo_width = width; vo->vo_height = height; + return (0); +} + +int +vtc_vtout_console(device_t dev) +{ + struct vtc_conout *vc, **iter; + + SET_FOREACH(iter, vtc_conout_set) { + vc = *iter; + if (vc->vtc_busdev == dev) + return (1); + } + return (0); +} + +/* + * Create the initial VT. + */ +static void +vtc_initial(void *data __unused) +{ + struct tty *tp; + struct vtc_conout *vc, **iter; + struct vtc_te_softc *te; + + printf("%s: create initial VT\n", vtc_device_name); + if (TAILQ_EMPTY(&vtc_vtout_devs)) + return; + te = malloc(vt102_class.size, M_VTC, M_WAITOK|M_ZERO); kobj_init((kobj_t)te, (kobj_class_t)&vt102_class); TAILQ_INSERT_TAIL(&vtc_te_devs, te, te_alldevs); TAILQ_INIT(&te->te_vodevs); - TAILQ_INSERT_TAIL(&te->te_vodevs, vo, vo_tedevs); VTC_TE_RESET(te); @@ -203,29 +233,38 @@ tp->t_break = vtc_tty_break; tp->t_open = vtc_tty_open; tp->t_close = vtc_tty_close; - -/* - sprintf(((struct consdev *)sc->sc_sysdev->cookie)->cn_name, "ttyv%r", - unit); -*/ ttyconsolemode(tp, 0); + ttycreate(tp, NULL, 0, MINOR_CALLOUT, "V%r", 0); - ttycreate(tp, NULL, 0, MINOR_CALLOUT, "V%r", 0); - return (0); + SET_FOREACH(iter, vtc_conout_set) { + vc = *iter; + if (vc->vtc_consdev != NULL) + strcpy(vc->vtc_consdev->cn_name, "ttyV0"); + } } +SYSINIT(initial, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_ANY, vtc_initial, NULL) -int -vtc_vtout_console(device_t dev) +/* + * Preempt the low-level console driver with the accelerated driver. + */ +static void +vtc_finalize(void *data __unused) { - struct vtc_conout *vc, **iter; + struct vtc_te_softc *te; + struct vtc_vtout_softc *vo; + + printf("%s: finalize initial VT\n", vtc_device_name); + + te = TAILQ_FIRST(&vtc_te_devs); + if (te == NULL) + return; - SET_FOREACH(iter, vtc_conout_set) { - vc = *iter; - if (vc->vtc_busdev == dev) - return (1); + TAILQ_FOREACH(vo, &vtc_vtout_devs, vo_alldevs) { + if (vo->vo_init == NULL || (*vo->vo_init)(vo->vo_dev) == 0) + TAILQ_INSERT_TAIL(&te->te_vodevs, vo, vo_tedevs); } - return (0); } +SYSINIT(finalize, SI_SUB_VTC, SI_ORDER_ANY, vtc_finalize, NULL) static int vtc_modevent(module_t mod, int type, void *data) @@ -245,5 +284,4 @@ return (EOPNOTSUPP); } - DEV_MODULE(vtc, vtc_modevent, NULL); ==== //depot/projects/tty/sys/dev/vtc/vtc_te.c#3 (text+ko) ==== @@ -63,7 +63,7 @@ } glyph = vo->vo_font + (wc - 0x20) * 16; - vo->vo_bitblt(vo->vo_cookie, BITBLT_H1TOFB, (uintptr_t)glyph, + vo->vo_bitblt(vo->vo_dev, BITBLT_H1TOFB, (uintptr_t)glyph, vo->vo_width * row * vo->vo_ch + col * vo->vo_cw, 8, 16, 0, 7); } @@ -88,12 +88,12 @@ ch = vo->vo_height / te->te_maxrow; cw = vo->vo_width / te->te_maxcol; - vo->vo_bitblt(vo->vo_cookie, BITBLT_FBTOFB, + vo->vo_bitblt(vo->vo_dev, BITBLT_FBTOFB, vo->vo_width * (ulr + hs) * ch + ulc * cw, vo->vo_width * ulr * ch + ulc * cw, (lrc - ulc) * cw, (lrr - ulr - hs) * ch); - vo->vo_bitblt(vo->vo_cookie, BITBLT_CTOFB, 0, + vo->vo_bitblt(vo->vo_dev, BITBLT_CTOFB, 0, (lrr - hs) * ch, (lrc - ulc) * cw, hs * ch); } return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506122209.j5CM9DR7018943>