From owner-p4-projects@FreeBSD.ORG Sun Jun 12 22:09:16 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 92B6216A4C0; Sun, 12 Jun 2005 22:09:14 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3508716A44D for ; Sun, 12 Jun 2005 22:09:14 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 067FD43D48 for ; Sun, 12 Jun 2005 22:09:14 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j5CM9Dxs018946 for ; Sun, 12 Jun 2005 22:09:13 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j5CM9DR7018943 for perforce@freebsd.org; Sun, 12 Jun 2005 22:09:13 GMT (envelope-from marcel@freebsd.org) Date: Sun, 12 Jun 2005 22:09:13 GMT Message-Id: <200506122209.j5CM9DR7018943@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 78469 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2005 22:09:16 -0000 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 #include #include +#include #include #include #include @@ -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);