Module Name: src Committed By: tsutsui Date: Sat Feb 12 05:08:41 UTC 2011
Modified Files: src/sys/arch/hp300/conf: GENERIC INSTALL files.hp300 src/sys/arch/hp300/dev: diofbreg.h diofbvar.h src/sys/arch/hp300/hp300: autoconf.c src/sys/arch/hp300/stand: Makefile.buildboot src/sys/arch/hp300/stand/common: grfreg.h ite.c ite_subr.c itevar.h Added Files: src/sys/arch/hp300/dev: gendiofb.c src/sys/arch/hp300/stand/common: ite_dumb.c Log Message: Add dumb framebuffer (no acceleration, no colormap) support for HP362 and HP382. Tested on A1473-69510 (HP362 VGA-res) and A1474-69511 (HP382 mid-res). To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/arch/hp300/conf/GENERIC cvs rdiff -u -r1.42 -r1.43 src/sys/arch/hp300/conf/INSTALL cvs rdiff -u -r1.79 -r1.80 src/sys/arch/hp300/conf/files.hp300 cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hp300/dev/diofbreg.h \ src/sys/arch/hp300/dev/diofbvar.h cvs rdiff -u -r0 -r1.1 src/sys/arch/hp300/dev/gendiofb.c cvs rdiff -u -r1.96 -r1.97 src/sys/arch/hp300/hp300/autoconf.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/hp300/stand/Makefile.buildboot cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hp300/stand/common/grfreg.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hp300/stand/common/ite.c cvs rdiff -u -r0 -r1.1 src/sys/arch/hp300/stand/common/ite_dumb.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp300/stand/common/ite_subr.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp300/stand/common/itevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/hp300/conf/GENERIC diff -u src/sys/arch/hp300/conf/GENERIC:1.161 src/sys/arch/hp300/conf/GENERIC:1.162 --- src/sys/arch/hp300/conf/GENERIC:1.161 Sun Feb 6 18:40:55 2011 +++ src/sys/arch/hp300/conf/GENERIC Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.161 2011/02/06 18:40:55 tsutsui Exp $ +# $NetBSD: GENERIC,v 1.162 2011/02/12 05:08:40 tsutsui Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.161 $" +#ident "GENERIC-$Revision: 1.162 $" maxusers 32 # estimated number of users @@ -236,6 +236,9 @@ tvrx* at dio? scode ? # TurboVRX framebuffer wsdisplay* at tvrx? +gendiofb* at dio? scode ? # dumb framebuffer support for 362/382 +wsdisplay* at gendiofb? + com0 at dio0 scode 9 # DCA serial interfaces com* at dio? scode ? Index: src/sys/arch/hp300/conf/INSTALL diff -u src/sys/arch/hp300/conf/INSTALL:1.42 src/sys/arch/hp300/conf/INSTALL:1.43 --- src/sys/arch/hp300/conf/INSTALL:1.42 Sun Feb 6 18:26:53 2011 +++ src/sys/arch/hp300/conf/INSTALL Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -# $NetBSD: INSTALL,v 1.42 2011/02/06 18:26:53 tsutsui Exp $ +# $NetBSD: INSTALL,v 1.43 2011/02/12 05:08:40 tsutsui Exp $ # # INSTALL machine description file # @@ -183,6 +183,9 @@ tvrx* at dio? scode ? wsdisplay* at tvrx? +gendiofb* at dio? scode ? +wsdisplay* at gendiofb? + com* at dio0 scode 9 # DCA serial interfaces com* at dio? scode ? Index: src/sys/arch/hp300/conf/files.hp300 diff -u src/sys/arch/hp300/conf/files.hp300:1.79 src/sys/arch/hp300/conf/files.hp300:1.80 --- src/sys/arch/hp300/conf/files.hp300:1.79 Sun Feb 6 18:26:53 2011 +++ src/sys/arch/hp300/conf/files.hp300 Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -# $NetBSD: files.hp300,v 1.79 2011/02/06 18:26:53 tsutsui Exp $ +# $NetBSD: files.hp300,v 1.80 2011/02/12 05:08:40 tsutsui Exp $ # # hp300-specific configuration info @@ -113,6 +113,10 @@ attach tvrx at dio file arch/hp300/dev/tvrx.c tvrx needs-flag +device gendiofb: wsemuldisplaydev, diofb, rasops8 +attach gendiofb at dio +file arch/hp300/dev/gendiofb.c gendiofb needs-flag + # # Devices on the DIO bus # Index: src/sys/arch/hp300/dev/diofbreg.h diff -u src/sys/arch/hp300/dev/diofbreg.h:1.1 src/sys/arch/hp300/dev/diofbreg.h:1.2 --- src/sys/arch/hp300/dev/diofbreg.h:1.1 Sun Feb 6 18:26:51 2011 +++ src/sys/arch/hp300/dev/diofbreg.h Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: diofbreg.h,v 1.1 2011/02/06 18:26:51 tsutsui Exp $ */ +/* $NetBSD: diofbreg.h,v 1.2 2011/02/12 05:08:40 tsutsui Exp $ */ /* $OpenBSD: diofbreg.h,v 1.3 2007/01/07 15:13:52 miod Exp $ */ /* @@ -58,6 +58,8 @@ #define GID_TIGER 12 #define GID_YGENESIS 13 #define GID_HYPERION 14 +#define GID_A1474MID 16 +#define GID_A147xVGA 17 #ifndef _LOCORE struct diofbreg { Index: src/sys/arch/hp300/dev/diofbvar.h diff -u src/sys/arch/hp300/dev/diofbvar.h:1.1 src/sys/arch/hp300/dev/diofbvar.h:1.2 --- src/sys/arch/hp300/dev/diofbvar.h:1.1 Sun Feb 6 18:26:51 2011 +++ src/sys/arch/hp300/dev/diofbvar.h Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: diofbvar.h,v 1.1 2011/02/06 18:26:51 tsutsui Exp $ */ +/* $NetBSD: diofbvar.h,v 1.2 2011/02/12 05:08:40 tsutsui Exp $ */ /* $OpenBSD: diofbvar.h,v 1.10 2006/08/11 18:33:13 miod Exp $ */ /* @@ -140,6 +140,7 @@ int rboxcnattach(bus_space_tag_t, bus_addr_t, int); int topcatcnattach(bus_space_tag_t, bus_addr_t, int); int tvrxcnattach(bus_space_tag_t, bus_addr_t, int); +int gendiofbcnattach(bus_space_tag_t, bus_addr_t, int); extern struct diofb diofb_cn; /* struct diofb for console device */ #endif Index: src/sys/arch/hp300/hp300/autoconf.c diff -u src/sys/arch/hp300/hp300/autoconf.c:1.96 src/sys/arch/hp300/hp300/autoconf.c:1.97 --- src/sys/arch/hp300/hp300/autoconf.c:1.96 Wed Feb 9 09:32:49 2011 +++ src/sys/arch/hp300/hp300/autoconf.c Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.96 2011/02/09 09:32:49 tsutsui Exp $ */ +/* $NetBSD: autoconf.c,v 1.97 2011/02/12 05:08:40 tsutsui Exp $ */ /*- * Copyright (c) 1996, 1997, 2002 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.96 2011/02/09 09:32:49 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.97 2011/02/12 05:08:40 tsutsui Exp $"); #include "dvbox.h" #include "gbox.h" @@ -96,6 +96,7 @@ #include "rbox.h" #include "topcat.h" #include "tvrx.h" +#include "gendiofb.h" #include "com_dio.h" #include "com_frodo.h" #include "dcm.h" @@ -820,6 +821,10 @@ if (!dio_scan(tvrxcnattach)) goto find_kbd; #endif +#if NGENDIOFB > 0 + if (!dio_scan(gendiofbcnattach)) + goto find_kbd; +#endif find_kbd: Index: src/sys/arch/hp300/stand/Makefile.buildboot diff -u src/sys/arch/hp300/stand/Makefile.buildboot:1.31 src/sys/arch/hp300/stand/Makefile.buildboot:1.32 --- src/sys/arch/hp300/stand/Makefile.buildboot:1.31 Thu Feb 10 13:04:31 2011 +++ src/sys/arch/hp300/stand/Makefile.buildboot Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.buildboot,v 1.31 2011/02/10 13:04:31 tsutsui Exp $ +# $NetBSD: Makefile.buildboot,v 1.32 2011/02/12 05:08:40 tsutsui Exp $ # RELOC=FFF00000 allows for boot prog up to FF000 (1044480) bytes long RELOC= FFF00000 @@ -56,8 +56,8 @@ COMMONSOURCE= srt0.S autoconf.c clock.c conf.c cons.c devopen.c \ exec.c machdep.c prf.c rawfs.c netio.c DRIVERSOURCE= apci.c ct.c dca.c dcm.c dnkbd.c fhpib.c hil.c \ - hpib.c if_le.c ite.c ite_dv.c ite_gb.c ite_hy.c \ - ite_rb.c ite_subr.c ite_tc.c ite_tvrx.c \ + hpib.c if_le.c ite.c ite_dumb.c ite_dv.c ite_gb.c \ + ite_hy.c ite_rb.c ite_subr.c ite_tc.c ite_tvrx.c \ kbd.c kbdconf.c nhpib.c rd.c scsi.c sd.c .include <bsd.own.mk> Index: src/sys/arch/hp300/stand/common/grfreg.h diff -u src/sys/arch/hp300/stand/common/grfreg.h:1.2 src/sys/arch/hp300/stand/common/grfreg.h:1.3 --- src/sys/arch/hp300/stand/common/grfreg.h:1.2 Tue Feb 8 20:20:14 2011 +++ src/sys/arch/hp300/stand/common/grfreg.h Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: grfreg.h,v 1.2 2011/02/08 20:20:14 rmind Exp $ */ +/* $NetBSD: grfreg.h,v 1.3 2011/02/12 05:08:40 tsutsui Exp $ */ /* * Copyright (c) 1991 University of Utah. @@ -54,6 +54,8 @@ #define GID_TIGER 12 #define GID_YGENESIS 13 #define GID_HYPERION 14 +#define GID_A1474MID 16 +#define GID_A147xVGA 17 typedef unsigned char grftype; Index: src/sys/arch/hp300/stand/common/ite.c diff -u src/sys/arch/hp300/stand/common/ite.c:1.15 src/sys/arch/hp300/stand/common/ite.c:1.16 --- src/sys/arch/hp300/stand/common/ite.c:1.15 Thu Feb 10 13:04:32 2011 +++ src/sys/arch/hp300/stand/common/ite.c Sat Feb 12 05:08:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.15 2011/02/10 13:04:32 tsutsui Exp $ */ +/* $NetBSD: ite.c,v 1.16 2011/02/12 05:08:40 tsutsui Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -96,6 +96,14 @@ { GID_TIGER, tvrx_init, ite_dio_clear, ite_dio_putc1bpp, ite_dio_cursor, ite_dio_scroll }, + + { GID_A1474MID, + dumb_init, dumb_clear, dumb_putc, + dumb_cursor, dumb_scroll }, + + { GID_A147xVGA, + dumb_init, dumb_clear, dumb_putc, + dumb_cursor, dumb_scroll }, }; int nitesw = sizeof(itesw) / sizeof(itesw[0]); Index: src/sys/arch/hp300/stand/common/ite_subr.c diff -u src/sys/arch/hp300/stand/common/ite_subr.c:1.10 src/sys/arch/hp300/stand/common/ite_subr.c:1.11 --- src/sys/arch/hp300/stand/common/ite_subr.c:1.10 Thu Feb 10 12:46:22 2011 +++ src/sys/arch/hp300/stand/common/ite_subr.c Sat Feb 12 05:08:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ite_subr.c,v 1.10 2011/02/10 12:46:22 tsutsui Exp $ */ +/* $NetBSD: ite_subr.c,v 1.11 2011/02/12 05:08:41 tsutsui Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,12 +47,6 @@ #include <hp300/stand/common/samachdep.h> #include <hp300/stand/common/itevar.h> -#define getbyte(ip, offset) \ - *(((u_char *)(ip)->regbase) + (offset)) - -#define getword(ip, offset) \ - ((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2)) - static void ite_writeglyph(struct ite_data *, u_char *, u_char *); void Index: src/sys/arch/hp300/stand/common/itevar.h diff -u src/sys/arch/hp300/stand/common/itevar.h:1.14 src/sys/arch/hp300/stand/common/itevar.h:1.15 --- src/sys/arch/hp300/stand/common/itevar.h:1.14 Thu Feb 10 13:04:32 2011 +++ src/sys/arch/hp300/stand/common/itevar.h Sat Feb 12 05:08:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: itevar.h,v 1.14 2011/02/10 13:04:32 tsutsui Exp $ */ +/* $NetBSD: itevar.h,v 1.15 2011/02/12 05:08:41 tsutsui Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +42,12 @@ * Standalone version of hp300 ITE. */ +#define getbyte(ip, offset) \ + *(((u_char *)(ip)->regbase) + (offset)) + +#define getword(ip, offset) \ + ((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2)) + struct ite_data; typedef void (*ite_windowmover)(struct ite_data *, int, int, int, int, int, @@ -133,3 +139,8 @@ void dvbox_init(struct ite_data *); void hyper_init(struct ite_data *); void tvrx_init(struct ite_data *); +void dumb_init(struct ite_data *); +void dumb_cursor(struct ite_data *, int); +void dumb_putc(struct ite_data *, int, int, int); +void dumb_clear(struct ite_data *, int, int, int, int); +void dumb_scroll(struct ite_data *); Added files: Index: src/sys/arch/hp300/dev/gendiofb.c diff -u /dev/null src/sys/arch/hp300/dev/gendiofb.c:1.1 --- /dev/null Sat Feb 12 05:08:41 2011 +++ src/sys/arch/hp300/dev/gendiofb.c Sat Feb 12 05:08:40 2011 @@ -0,0 +1,277 @@ +/* $NetBSD: gendiofb.c,v 1.1 2011/02/12 05:08:40 tsutsui Exp $ */ +/* $OpenBSD: tvrx.c,v 1.1 2006/04/14 21:05:43 miod Exp $ */ + +/* + * Copyright (c) 2006, Miodrag Vallat. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * dumb graphics routines for frame buffer on HP362 and HP382 based on tvrx.c + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/proc.h> +#include <sys/ioctl.h> +#include <sys/bus.h> +#include <sys/cpu.h> + +#include <machine/autoconf.h> + +#include <hp300/dev/dioreg.h> +#include <hp300/dev/diovar.h> +#include <hp300/dev/diodevs.h> + +#include <dev/cons.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wsdisplayvar.h> +#include <dev/rasops/rasops.h> + +#include <hp300/dev/diofbreg.h> +#include <hp300/dev/diofbvar.h> + +struct gendiofb_softc { + device_t sc_dev; + struct diofb *sc_fb; + struct diofb sc_fb_store; + int sc_scode; +}; + +static int gendiofb_match(device_t, cfdata_t, void *); +static void gendiofb_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(gendiofb, sizeof(struct gendiofb_softc), + gendiofb_match, gendiofb_attach, NULL, NULL); + +static int gendiofb_reset(struct diofb *, int, struct diofbreg *); + +static int gendiofb_ioctl(void *, void *, u_long, void *, int, struct lwp *); + +static struct wsdisplay_accessops gendiofb_accessops = { + gendiofb_ioctl, + diofb_mmap, + diofb_alloc_screen, + diofb_free_screen, + diofb_show_screen, + NULL, /* load_font */ +}; + +/* + * Attachment glue + */ + +static int +gendiofb_match(device_t parent, cfdata_t cf, void *aux) +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER) { + switch (da->da_secid) { + case DIO_DEVICE_SECID_A147xVGA: + case DIO_DEVICE_SECID_A1474MID: + return 1; + } + } + + return 0; +} + +static void +gendiofb_attach(device_t parent, device_t self, void *aux) +{ + struct gendiofb_softc *sc = device_private(self); + struct dio_attach_args *da = aux; + bus_space_handle_t bsh; + struct diofbreg *fbr; + bus_size_t size; + + sc->sc_dev = self; + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) { + fbr = (struct diofbreg *)conaddr; /* already mapped */ + sc->sc_fb = &diofb_cn; + } else { + sc->sc_fb = &sc->sc_fb_store; + size = da->da_size; + if (size > DIOII_DEVSIZE) /* XXX */ + size = DIOII_DEVSIZE; + if (bus_space_map(da->da_bst, da->da_addr, size, 0, + &bsh)) { + aprint_error(": can't map framebuffer\n"); + return; + } + fbr = bus_space_vaddr(da->da_bst, bsh); + if (gendiofb_reset(sc->sc_fb, sc->sc_scode, fbr) != 0) { + aprint_error(": failed to reset\n"); + return; + } + } + + diofb_end_attach(self, &gendiofb_accessops, sc->sc_fb, + sc->sc_scode == conscode, NULL); +} + +/* + * Initialize hardware and display routines. + */ +static int +gendiofb_reset(struct diofb *fb, int scode, struct diofbreg *fbr) +{ + int rc; + struct rasops_info *ri = &fb->ri; + + if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0) + return (rc); + + /* + * We rely on the PROM to initialize the frame buffer in the mode + * we expect it: cleared, overlay plane enabled and accessible + * at the beginning of the video memory. + * + * This is NOT the mode we would end up by simply resetting the + * board. + */ + + ri->ri_depth = 8; + ri->ri_stride = (fb->fbwidth * ri->ri_depth) / 8; + + ri->ri_flg = RI_CENTER | RI_FULLCLEAR; + if (fb == &diofb_cn) + ri->ri_flg |= RI_NO_AUTO; /* XXX */ + ri->ri_bits = fb->fbkva; + ri->ri_width = fb->dwidth; + ri->ri_height = fb->dheight; + ri->ri_hw = fb; + + /* + * Ask for an unholy big display, rasops will trim this to more + * reasonable values. + */ + rasops_init(ri, 160, 160); + ri->ri_flg |= RI_FORCEMONO; /* no colormap */ + + diofb_resetcmap(fb); + + fb->wsd.name = fb->wsdname; + fb->wsd.ncols = ri->ri_cols; + fb->wsd.nrows = ri->ri_rows; + fb->wsd.textops = &ri->ri_ops; + fb->wsd.fontwidth = ri->ri_font->fontwidth; + fb->wsd.fontheight = ri->ri_font->fontheight; + fb->wsd.capabilities = ri->ri_caps; + strlcpy(fb->wsdname, "std", sizeof(fb->wsdname)); + + return 0; +} + +static int +gendiofb_ioctl(void *v, void *vs, u_long cmd, void *data, int flags, + struct lwp *l) +{ + struct diofb *fb = v; + struct wsdisplay_fbinfo *wdf; + + switch (cmd) { + case WSDISPLAYIO_GTYPE: + *(u_int *)data = WSDISPLAY_TYPE_UNKNOWN; + return 0; + case WSDISPLAYIO_SMODE: + fb->mapmode = *(u_int *)data; + return 0; + case WSDISPLAYIO_GINFO: + wdf = (void *)data; + wdf->width = fb->ri.ri_width; + wdf->height = fb->ri.ri_height; + wdf->depth = fb->ri.ri_depth; + wdf->cmsize = 0; + return 0; + case WSDISPLAYIO_LINEBYTES: + *(u_int *)data = fb->ri.ri_stride; + return 0; + case WSDISPLAYIO_GETCMAP: + case WSDISPLAYIO_PUTCMAP: + /* until color support is implemented */ + return EPASSTHROUGH; + case WSDISPLAYIO_GVIDEO: + case WSDISPLAYIO_SVIDEO: + /* unsupported */ + return EPASSTHROUGH; + } + + return EPASSTHROUGH; +} + + +/* + * Console attachment + */ + +int +gendiofbcnattach(bus_space_tag_t bst, bus_addr_t addr, int scode) +{ + bus_space_handle_t bsh; + void *va; + struct diofbreg *fbr; + struct diofb *fb = &diofb_cn; + bus_size_t size; + + if (bus_space_map(bst, addr, PAGE_SIZE, 0, &bsh)) + return 1; + va = bus_space_vaddr(bst, bsh); + fbr = va; + if (badaddr(va) || + fbr->id != GRFHWID || + (fbr->fbid != DIO_DEVICE_SECID_A1474MID && + fbr->fbid != DIO_DEVICE_SECID_A147xVGA)) { + bus_space_unmap(bst, bsh, PAGE_SIZE); + return 1; + } + + size = DIO_SIZE(scode, va); + if (size > DIOII_DEVSIZE) /* XXX */ + size = DIOII_DEVSIZE; + + bus_space_unmap(bst, bsh, PAGE_SIZE); + if (bus_space_map(bst, addr, size, 0, &bsh)) + return 1; + va = bus_space_vaddr(bst, bsh); + + /* + * Initialize the framebuffer hardware. + */ + conscode = scode; + conaddr = va; + gendiofb_reset(fb, conscode, (struct diofbreg *)conaddr); + + /* + * Initialize the terminal emulator. + */ + diofb_cnattach(fb); + return 0; +} Index: src/sys/arch/hp300/stand/common/ite_dumb.c diff -u /dev/null src/sys/arch/hp300/stand/common/ite_dumb.c:1.1 --- /dev/null Sat Feb 12 05:08:41 2011 +++ src/sys/arch/hp300/stand/common/ite_dumb.c Sat Feb 12 05:08:41 2011 @@ -0,0 +1,251 @@ +/* $NetBSD: ite_dumb.c,v 1.1 2011/02/12 05:08:41 tsutsui Exp $ */ + +/*- + * Copyright (c) 2011 Izumi Tsutsui. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Mark Davies of the Department of Computer + * Science, Victoria University of Wellington, New Zealand. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: Utah $Hdr: ite_subr.c 1.2 92/01/20$ + * + * @(#)ite_subr.c 8.1 (Berkeley) 6/10/93 + */ + +#ifdef ITECONSOLE + +#include <sys/param.h> + +#include <hp300/stand/common/samachdep.h> +#include <hp300/stand/common/itereg.h> +#include <hp300/stand/common/itevar.h> + +static void dumb_fontinit(struct ite_data *ip); +static void dumb_writeglyph(struct ite_data *, uint8_t *fbmem, uint8_t *); +static void dumb_flip_cursor(struct ite_data *ip); +static void dumb_windowmove(struct ite_data *, int, int, int, int, int, int, + int); + +static uint8_t *font; + +void +dumb_init(struct ite_data *ip) +{ + + ip->bmv = dumb_windowmove; /* unused */ + ite_fontinfo(ip); + dumb_clear(ip, 0, 0, ip->rows, ip->cols); + dumb_fontinit(ip); +} + +static void +dumb_fontinit(struct ite_data *ip) +{ + int bytewidth = (((ip->ftwidth - 1) / 8) + 1); + int glyphsize = bytewidth * ip->ftheight; + uint8_t fontbuf[500]; + uint8_t *dp, *fontp; + int c, i, romp; + + /* + * We don't bother to copy font glyph into fbmem + * since there is no hardware windowmove ops. + * Prepare font data into contiguous memory instead. + */ + font = alloc((ip->ftwidth * ip->ftheight) * 128); + romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA; + + for (c = 0; c < 128; c++) { + /* get font glyph from FONTROM */ + dp = fontbuf; + for (i = 0; i < glyphsize; i++) { + *dp++ = getbyte(ip, romp); + romp += 2; + } + + /* setup font data for 8bpp fbmem */ + fontp = &font[(ip->ftwidth * ip->ftheight) * c]; + dumb_writeglyph(ip, fontp, fontbuf); + } +} + +static void +dumb_writeglyph(struct ite_data *ip, uint8_t *fontmem, uint8_t *glyphp) +{ + int bn; + int b, l; + + for (l = 0; l < ip->ftheight; l++) { + bn = 7; + for (b = 0; b < ip->ftwidth; b++) { + if ((1 << bn) & *glyphp) + *fontmem++ = 0x01; + else + *fontmem++ = 0x00; + if (--bn < 0) { + bn = 7; + glyphp++; + } + } + if (bn < 7) + glyphp++; + } +} + +static void +dumb_flip_cursor(struct ite_data *ip) +{ + int l, w; + uint8_t *pc; + uint32_t *pc32; + + pc = (uint8_t *)ip->fbbase + + ((ip->ftheight * ip->cursory) * ip->fbwidth) + + ip->ftwidth * ip->cursorx; + + for (l = 0; l < ip->ftheight; l++) { + /* assume (ip->ftwidth % sizeof(uint32_t) == 0) */ + pc32 = (uint32_t *)pc; + for (w = 0; w < ip->ftwidth / sizeof(uint32_t); w++) + pc32[w] ^= 0x01010101; + pc += ip->fbwidth; + } +} + +void +dumb_cursor(struct ite_data *ip, int flag) +{ + + switch (flag) { + case MOVE_CURSOR: + dumb_flip_cursor(ip); + /* FALLTHROUGH */ + case DRAW_CURSOR: + ip->cursorx = ip->curx; + ip->cursory = ip->cury; + /* FALLTHROUGH */ + default: + dumb_flip_cursor(ip); + break; + } +} + +void +dumb_putc(struct ite_data *ip, int c, int dy, int dx) +{ + int l, w; + uint8_t *pc; + uint32_t *pc32; + uint32_t *fontp; + + pc = (uint8_t *)ip->fbbase + + ((ip->ftheight * ip->cursory) * ip->fbwidth) + + ip->ftwidth * ip->cursorx; + fontp = (uint32_t *)&font[(ip->ftwidth * ip->ftheight) * c]; + + for (l = 0; l < ip->ftheight; l++) { + /* assume (ip->ftwidth % sizeof(uint32_t) == 0) */ + pc32 = (uint32_t *)pc; + for (w = 0; w < ip->ftwidth / sizeof(uint32_t); w++) + pc32[w] = *fontp++; + pc += ip->fbwidth; + } +} + +void +dumb_clear(struct ite_data *ip, int sy, int sx, int h, int w) +{ + int l; + uint8_t *pdst; + + pdst = (uint8_t *)ip->fbbase + + ((ip->ftheight * sy) * ip->fbwidth) + ip->ftwidth * sx; + + for (l = 0; l < ip->ftheight * h; l++) { + /* slow, but just works */ + memset(pdst, 0, ip->ftwidth * w); + pdst += ip->fbwidth; + } +} + +void +dumb_scroll(struct ite_data *ip) +{ + int l, h, w; + uint8_t *psrc, *pdst; + + dumb_flip_cursor(ip); + + psrc = (uint8_t *)ip->fbbase + (ip->ftheight * ip->fbwidth); + pdst = (uint8_t *)ip->fbbase; + + h = (ip->rows - 1) * ip->ftheight; + w = ip->cols * ip->ftwidth; + + for (l = 0; l < h; l++) { + /* slow, but just works and no scroll if no retry */ + memmove(pdst, psrc, w); + psrc += ip->fbwidth; + pdst += ip->fbwidth; + } +} + +static void +dumb_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx, + int w, int h, int func) +{ + + /* for sanity check */ + printf("%s: called\n", __func__); +} +#endif