From owner-p4-projects@FreeBSD.ORG Thu May 12 04:38:41 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D2F2316A4D1; Thu, 12 May 2005 04:38:40 +0000 (GMT) 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 A757616A4CE for ; Thu, 12 May 2005 04:38:40 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 862B443D83 for ; Thu, 12 May 2005 04:38:40 +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 j4C4ceRu030813 for ; Thu, 12 May 2005 04:38:40 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j4C4cepI030810 for perforce@freebsd.org; Thu, 12 May 2005 04:38:40 GMT (envelope-from marcel@freebsd.org) Date: Thu, 12 May 2005 04:38:40 GMT Message-Id: <200505120438.j4C4cepI030810@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 Subject: PERFORCE change 76865 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2005 04:38:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=76865 Change 76865 by marcel@marcel_nfs on 2005/05/12 04:38:08 Flesh out what's needed for low-level console output. This basically boils down to finding the right definition of the BitBlt operation. Ideally you want the hardware driver to take advantage of any hardware acceleration if possible. In short: o Printing a character is a bitblt operation from host memory to the frame buffer, o Scrolling the screen is a bitblt operation from the frame buffer to the frame buffer, o Clearing a portion of the screen is a (pseudo) bitblt operation where the source is a pixel color and the destination is the frame buffer. Host originated bitmaps come in multiple variants of differing depths. Fonts typically are monochrome, so we need to have the ability to pass a background and foreground color to the bitblt function. Use stdarg to cover these variations. Affected files ... .. //depot/projects/tty/sys/dev/vga/vga.c#10 edit .. //depot/projects/tty/sys/dev/vga/vga.h#6 edit .. //depot/projects/tty/sys/dev/vga/vga_con.c#3 edit .. //depot/projects/tty/sys/dev/vtc/vtc_con.c#3 edit .. //depot/projects/tty/sys/dev/vtc/vtc_con.h#2 edit .. //depot/projects/tty/sys/sys/vtc.h#1 add Differences ... ==== //depot/projects/tty/sys/dev/vga/vga.c#10 (text+ko) ==== @@ -268,7 +268,8 @@ } int -vga_bitblt(struct vga_softc *sc, int x, int y) +vga_vbitblt(struct vga_softc *sc, int op, uintptr_t dst, uintptr_t src, + int width, int height, va_list ap) { return (0); ==== //depot/projects/tty/sys/dev/vga/vga.h#6 (text+ko) ==== @@ -29,6 +29,8 @@ #ifndef _DEV_VGA_VGA_H_ #define _DEV_VGA_VGA_H_ +#include + struct vga_spc { bus_space_tag_t bst; @@ -68,8 +70,9 @@ extern char vga_device_name[]; int vga_attach(device_t); -int vga_bitblt(struct vga_softc *, int, int); +int vga_vbitblt(struct vga_softc *, int, uintptr_t, uintptr_t, int, int, + va_list); int vga_init(struct vga_softc *); int vga_probe(struct vga_softc *); -#endif /* _DEV_VGA_VGA_H_ */ +#endif /* !_DEV_VGA_VGA_H_ */ ==== //depot/projects/tty/sys/dev/vga/vga_con.c#3 (text+ko) ==== @@ -46,7 +46,7 @@ VTC_CONOUT(vga, vga_con_probe, vga_con_init, vga_con_bitblt); static int -vga_con_probe() +vga_con_probe(struct vtc_conout *co) { struct vga_consdata cd; @@ -61,20 +61,30 @@ if (!vga_probe(&vga_console)) return (-1); + co->vtc_con_cookie = &vga_console; + co->vtc_con_width = 640; + co->vtc_con_height = 480; + co->vtc_con_depth = 16; return (0); } static void -vga_con_init() +vga_con_init(struct vtc_conout *co) { + struct vga_softc *sc = co->vtc_con_cookie; - if (vga_init(&vga_console) == 0) - vga_console.vga_console = 1; + if (vga_init(sc) == 0) + sc->vga_console = 1; } static void -vga_con_bitblt(int x, int y) +vga_con_bitblt(struct vtc_conout *co, int op, uintptr_t dst, uintptr_t src, + int width, int height, ...) { + struct vga_softc *sc = co->vtc_con_cookie; + va_list ap; - vga_bitblt(&vga_console, x, y); + va_start(ap, height); + vga_vbitblt(sc, op, dst, src, width, height, ap); + va_end(ap); } ==== //depot/projects/tty/sys/dev/vtc/vtc_con.c#3 (text+ko) ==== @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -62,7 +63,7 @@ cur_vc = NULL; SET_FOREACH(iter, vtc_conout_set) { vc = *iter; - pri = (vc->vtc_con_probe != NULL) ? vc->vtc_con_probe() : -1; + pri = (vc->vtc_con_probe != NULL) ? vc->vtc_con_probe(vc) : -1; if (pri > cur_pri) { cur_pri = pri; cur_vc = vc; @@ -78,7 +79,7 @@ { struct vtc_conout *vc = cp->cn_arg; - vc->vtc_con_init(); + vc->vtc_con_init(vc); } static void @@ -89,9 +90,34 @@ static void vtc_cnputc(struct consdev *cp, int c) { + static int col = 0, row = 0; + static uint8_t bitmap[] = { 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, + 0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0x82, + 0x00, 0x00, 0x00, 0x00, 0x00 }; struct vtc_conout *vc = cp->cn_arg; - vc->vtc_con_bitblt(0, 0); + switch (c) { + case 0x0a: + col = 0; + row++; + break; + default: + vc->vtc_con_bitblt(vc, BITBLT_H1TOFB, (uintptr_t)bitmap, + vc->vtc_con_width * row * 10 + col * 8, 8, 19, 0, 7); + col++; + break; + } + if (col >= 80) { + col = 0; + row++; + } + if (row >= 24) { + vc->vtc_con_bitblt(vc, BITBLT_FBTOFB, vc->vtc_con_width * 19, + 0, vc->vtc_con_width, 23 * 19); + vc->vtc_con_bitblt(vc, BITBLT_CLRTOFB, 0, 23 * 19, + vc->vtc_con_width, 19); + row = 0; + } } static int ==== //depot/projects/tty/sys/dev/vtc/vtc_con.h#2 (text+ko) ==== @@ -29,15 +29,22 @@ #ifndef _DEV_VTC_CON_H_ #define _DEV_VTC_CON_H_ -typedef void vtc_con_bitblt_f(int, int); -typedef void vtc_con_init_f(void); -typedef int vtc_con_probe_f(void); +struct vtc_conout; + +typedef void vtc_con_bitblt_f(struct vtc_conout *, int, uintptr_t, uintptr_t, + int, int, ...); +typedef void vtc_con_init_f(struct vtc_conout *); +typedef int vtc_con_probe_f(struct vtc_conout *); struct vtc_conout { const char *vtc_con_name; vtc_con_probe_f *vtc_con_probe; vtc_con_init_f *vtc_con_init; vtc_con_bitblt_f *vtc_con_bitblt; + void * vtc_con_cookie; + int vtc_con_width; + int vtc_con_height; + int vtc_con_depth; }; #define VTC_CONOUT(name, probe, init, bitblt) \ @@ -45,7 +52,11 @@ .vtc_con_name = #name, \ .vtc_con_probe = probe, \ .vtc_con_init = init, \ - .vtc_con_bitblt = bitblt \ + .vtc_con_bitblt = bitblt, \ + .vtc_con_cookie = NULL, \ + .vtc_con_width = -1, \ + .vtc_con_height = -1, \ + .vtc_con_depth = -1 \ }; \ DATA_SET(vtc_conout_set, name##_vtc_conout)