Module Name: src Committed By: bouyer Date: Sun Oct 18 14:32:29 UTC 2009
Modified Files: src/sys/dev/sbus [netbsd-5]: files.sbus zx.c zxreg.h zxvar.h Log Message: Back out ticket 960 To generate a diff of this commit: cvs rdiff -u -r1.31.36.1 -r1.31.36.2 src/sys/dev/sbus/files.sbus cvs rdiff -u -r1.24.6.2 -r1.24.6.3 src/sys/dev/sbus/zx.c cvs rdiff -u -r1.5.4.2 -r1.5.4.3 src/sys/dev/sbus/zxreg.h cvs rdiff -u -r1.2.10.2 -r1.2.10.3 src/sys/dev/sbus/zxvar.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/dev/sbus/files.sbus diff -u src/sys/dev/sbus/files.sbus:1.31.36.1 src/sys/dev/sbus/files.sbus:1.31.36.2 --- src/sys/dev/sbus/files.sbus:1.31.36.1 Sun Oct 18 13:23:31 2009 +++ src/sys/dev/sbus/files.sbus Sun Oct 18 14:32:29 2009 @@ -1,4 +1,4 @@ -# $NetBSD: files.sbus,v 1.31.36.1 2009/10/18 13:23:31 bouyer Exp $ +# $NetBSD: files.sbus,v 1.31.36.2 2009/10/18 14:32:29 bouyer Exp $ # # Config file and device description for machine-independent SBUS code. # Included by ports that need it. @@ -119,7 +119,7 @@ attach tcx at sbus file dev/sbus/tcx.c tcx needs-flag -device zx: fb, rasops32, wsemuldisplaydev, vcons +device zx: fb, rasops32 attach zx at sbus file dev/sbus/zx.c zx Index: src/sys/dev/sbus/zx.c diff -u src/sys/dev/sbus/zx.c:1.24.6.2 src/sys/dev/sbus/zx.c:1.24.6.3 --- src/sys/dev/sbus/zx.c:1.24.6.2 Sun Oct 18 13:23:31 2009 +++ src/sys/dev/sbus/zx.c Sun Oct 18 14:32:29 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: zx.c,v 1.24.6.2 2009/10/18 13:23:31 bouyer Exp $ */ +/* $NetBSD: zx.c,v 1.24.6.3 2009/10/18 14:32:29 bouyer Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.24.6.2 2009/10/18 13:23:31 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.24.6.3 2009/10/18 14:32:29 bouyer Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -66,58 +66,45 @@ #include <dev/sun/fbio.h> #include <dev/sun/fbvar.h> -#include "wsdisplay.h" -#if NWSDISPLAY > 0 -#include <dev/wscons/wsconsio.h> -#include <dev/wsfont/wsfont.h> -#include <dev/rasops/rasops.h> -#include <dev/wscons/wsdisplay_vconsvar.h> - -#include "opt_wsemul.h" -#endif - #include <dev/sbus/zxreg.h> #include <dev/sbus/zxvar.h> #include <dev/sbus/sbusvar.h> #include <dev/wscons/wsconsio.h> -#if (NWSDISPLAY == 0) && !defined(RASTERCONSOLE) -#error Sorry, this driver needs WSCONS or RASTERCONSOLE -#endif - -#if (NWSDISPLAY > 0) && defined(RASTERCONSOLE) -#error Sorry, RASTERCONSOLE and WSCONS are mutually exclusive +#ifndef RASTERCONSOLE +#error Sorry, this driver needs the RASTERCONSOLE option #endif #define ZX_STD_ROP (ZX_ROP_NEW | ZX_ATTR_WE_ENABLE | \ ZX_ATTR_OE_ENABLE | ZX_ATTR_FORCE_WID) -static void zx_attach(device_t, device_t, void *); -static int zx_match(device_t, struct cfdata *, void *); +void zx_attach(struct device *, struct device *, void *); +int zx_match(struct device *, struct cfdata *, void *); -static void zx_blank(device_t); -static int zx_cmap_put(struct zx_softc *); -static void zx_copyrect(struct zx_softc *, int, int, int, int, int, int); -static int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int); -static int zx_cross_wait(struct zx_softc *); -static void zx_fillrect(struct zx_softc *, int, int, int, int, uint32_t, int); -static int zx_intr(void *); -static void zx_reset(struct zx_softc *); -static void zx_unblank(device_t); - -static void zx_cursor_blank(struct zx_softc *); -static void zx_cursor_color(struct zx_softc *); -static void zx_cursor_move(struct zx_softc *); -static void zx_cursor_set(struct zx_softc *); -static void zx_cursor_unblank(struct zx_softc *); - -static void zx_copycols(void *, int, int, int, int); -static void zx_copyrows(void *, int, int, int); -static void zx_do_cursor(void *, int, int, int); -static void zx_erasecols(void *, int, int, int, long); -static void zx_eraserows(void *, int, int, long); -static void zx_putchar(void *, int, int, u_int, long); +void zx_blank(struct device *); +int zx_cmap_put(struct zx_softc *); +void zx_copyrect(struct rasops_info *, int, int, int, int, int, int); +int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int); +int zx_cross_wait(struct zx_softc *); +void zx_fillrect(struct rasops_info *, int, int, int, int, long, int); +int zx_intr(void *); +void zx_reset(struct zx_softc *); +void zx_unblank(struct device *); + +void zx_cursor_blank(struct zx_softc *); +void zx_cursor_color(struct zx_softc *); +void zx_cursor_move(struct zx_softc *); +void zx_cursor_set(struct zx_softc *); +void zx_cursor_unblank(struct zx_softc *); + +void zx_copycols(void *, int, int, int, int); +void zx_copyrows(void *, int, int, int); +void zx_cursor(void *, int, int, int); +void zx_do_cursor(struct rasops_info *); +void zx_erasecols(void *, int, int, int, long); +void zx_eraserows(void *, int, int, long); +void zx_putchar(void *, int, int, u_int, long); struct zx_mmo { off_t mo_va; @@ -137,66 +124,22 @@ { ZX_LD_GBL_VOFF, ZX_OFF_LD_GBL, 0x00001000 }, }; -CFATTACH_DECL_NEW(zx, sizeof(struct zx_softc), +CFATTACH_DECL(zx, sizeof(struct zx_softc), zx_match, zx_attach, NULL, NULL); extern struct cfdriver zx_cd; -static dev_type_open(zxopen); -static dev_type_close(zxclose); -static dev_type_ioctl(zxioctl); -static dev_type_mmap(zxmmap); +dev_type_open(zxopen); +dev_type_close(zxclose); +dev_type_ioctl(zxioctl); +dev_type_mmap(zxmmap); static struct fbdriver zx_fbdriver = { zx_unblank, zxopen, zxclose, zxioctl, nopoll, zxmmap }; -#if NWSDISPLAY > 0 -struct wsscreen_descr zx_defaultscreen = { - "std", - 0, 0, /* will be filled in -- XXX shouldn't, it's global */ - /* doesn't matter - you can't really have more than one leo */ - NULL, /* textops */ - 8, 16, /* font width/height */ - WSSCREEN_WSCOLORS, /* capabilities */ - NULL /* modecookie */ -}; - -static int zx_ioctl(void *, void *, u_long, void *, int, struct lwp *); -static paddr_t zx_mmap(void *, void *, off_t, int); -static void zx_init_screen(void *, struct vcons_screen *, int, long *); - -static int zx_putcmap(struct zx_softc *, struct wsdisplay_cmap *); -static int zx_getcmap(struct zx_softc *, struct wsdisplay_cmap *); - -struct wsdisplay_accessops zx_accessops = { - zx_ioctl, - zx_mmap, - NULL, /* alloc_screen */ - NULL, /* free_screen */ - NULL, /* show_screen */ - NULL, /* load_font */ - NULL, /* pollc */ - NULL /* scroll */ -}; - -const struct wsscreen_descr *_zx_scrlist[] = { - &zx_defaultscreen -}; - -struct wsscreen_list zx_screenlist = { - sizeof(_zx_scrlist) / sizeof(struct wsscreen_descr *), - _zx_scrlist -}; - - -extern const u_char rasops_cmap[768]; - -static struct vcons_screen zx_console_screen; -#endif /* NWSDISPLAY > 0 */ - -static int -zx_match(device_t parent, struct cfdata *cf, void *aux) +int +zx_match(struct device *parent, struct cfdata *cf, void *aux) { struct sbus_attach_args *sa; @@ -205,31 +148,27 @@ return (strcmp(sa->sa_name, "SUNW,leo") == 0); } -static void -zx_attach(device_t parent, device_t self, void *args) +void +zx_attach(struct device *parent, struct device *self, void *args) { struct zx_softc *sc; struct sbus_attach_args *sa; bus_space_handle_t bh; bus_space_tag_t bt; struct fbdevice *fb; -#if NWSDISPLAY > 0 - struct wsemuldisplaydev_attach_args aa; - struct rasops_info *ri = &zx_console_screen.scr_ri; - unsigned long defattr; -#endif + struct rasops_info *ri; int isconsole; sc = device_private(self); - sc->sc_dv = self; - sa = args; fb = &sc->sc_fb; + ri = &fb->fb_rinfo; bt = sa->sa_bustag; sc->sc_bt = bt; + sc->sc_paddr = sbus_bus_addr(bt, sa->sa_slot, sa->sa_offset); - if (sparc_bus_map_large(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0, + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0, 0x800000, BUS_SPACE_MAP_LINEAR, &bh) != 0) { aprint_error_dev(self, "can't map bits\n"); return; @@ -242,7 +181,6 @@ aprint_error_dev(self, "can't map zc\n"); return; } - sc->sc_bhzc = bh; if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0, @@ -274,8 +212,8 @@ sc->sc_bhzcu = bh; fb->fb_driver = &zx_fbdriver; - fb->fb_device = sc->sc_dv; - fb->fb_flags = device_cfdata(sc->sc_dv)->cf_flags & FB_USERMASK; + fb->fb_device = &sc->sc_dv; + fb->fb_flags = device_cfdata(&sc->sc_dv)->cf_flags & FB_USERMASK; fb->fb_pfour = NULL; fb->fb_linebytes = 8192; @@ -292,68 +230,40 @@ printf(" (console)"); printf("\n"); - sbus_establish(&sc->sc_sd, sc->sc_dv); + sbus_establish(&sc->sc_sd, &sc->sc_dv); if (sa->sa_nintr != 0) bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc); sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT); + fb_attach(&sc->sc_fb, isconsole); zx_reset(sc); -#if NWSDISPLAY > 0 - sc->sc_width = fb->fb_type.fb_width; - sc->sc_stride = 8192; /* 32 bit */ - sc->sc_height = fb->fb_type.fb_height; - - /* setup rasops and so on for wsdisplay */ - wsfont_init(); - sc->sc_mode = WSDISPLAYIO_MODE_EMUL; - sc->sc_bg = WS_DEFAULT_BG; - - vcons_init(&sc->vd, sc, &zx_defaultscreen, &zx_accessops); - sc->vd.init_screen = zx_init_screen; - - if (isconsole) { - /* we mess with zx_console_screen only once */ - vcons_init_screen(&sc->vd, &zx_console_screen, 1, - &defattr); - zx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; - - zx_defaultscreen.textops = &ri->ri_ops; - zx_defaultscreen.capabilities = WSSCREEN_WSCOLORS; - zx_defaultscreen.nrows = ri->ri_rows; - zx_defaultscreen.ncols = ri->ri_cols; - wsdisplay_cnattach(&zx_defaultscreen, ri, 0, 0, defattr); - } else { - /* - * we're not the console so we just clear the screen and don't - * set up any sort of text display - */ - if (zx_defaultscreen.textops == NULL) { - /* - * ugly, but... - * we want the console settings to win, so we only - * touch anything when we find an untouched screen - * definition. In this case we fill it from fb to - * avoid problems in case no zx is the console - */ - ri = &sc->sc_fb.fb_rinfo; - zx_defaultscreen.textops = &ri->ri_ops; - zx_defaultscreen.capabilities = ri->ri_caps; - zx_defaultscreen.nrows = ri->ri_rows; - zx_defaultscreen.ncols = ri->ri_cols; - } - } + /* + * Attach to rcons. XXX At this point, rasops_do_cursor() will be + * called before we get our hooks in place. So, we mask off access + * to the framebuffer until it's done. + */ + bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontt, 1); + bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk, 0); - aa.scrdata = &zx_screenlist; - aa.console = isconsole; - aa.accessops = &zx_accessops; - aa.accesscookie = &sc->vd; - config_found(sc->sc_dv, &aa, wsemuldisplaydevprint); -#endif - fb_attach(&sc->sc_fb, isconsole); + fbrcons_init(&sc->sc_fb); + + bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontt, 0); + bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk, 0xffffffff); + + ri->ri_hw = sc; + ri->ri_do_cursor = zx_do_cursor; + ri->ri_ops.copycols = zx_copycols; + ri->ri_ops.copyrows = zx_copyrows; + ri->ri_ops.erasecols = zx_erasecols; + ri->ri_ops.eraserows = zx_eraserows; + ri->ri_ops.putchar = zx_putchar; + + sc->sc_fontw = ri->ri_font->fontwidth; + sc->sc_fonth = ri->ri_font->fontheight; } -static int +int zxopen(dev_t dev, int flags, int mode, struct lwp *l) { @@ -362,7 +272,7 @@ return (0); } -static int +int zxclose(dev_t dev, int flags, int mode, struct lwp *l) { struct zx_softc *sc; @@ -374,7 +284,7 @@ return (0); } -static int +int zxioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l) { struct zx_softc *sc; @@ -410,9 +320,9 @@ case FBIOSVIDEO: if (*(int *)data) - zx_unblank(sc->sc_dv); + zx_unblank(&sc->sc_dv); else - zx_blank(sc->sc_dv); + zx_blank(&sc->sc_dv); break; case FBIOGETCMAP: @@ -561,14 +471,14 @@ return (0); } -static int +int zx_intr(void *cookie) { return (1); } -static void +void zx_reset(struct zx_softc *sc) { struct fbtype *fbt; @@ -585,14 +495,14 @@ i |= ZX_SS1_MISC_ENABLE; bus_space_write_4(sc->sc_bt, sc->sc_bhzdss1, zd_misc, i); - bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wid, 1); + bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wid, 0xffffffff); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_widclip, 0); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_wmask, 0xffff); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmin, 0); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_vclipmax, (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 16)); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, 0); - bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_planemask, 0xffffffff); + bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_planemask, 0xff000000); bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP); bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent, @@ -610,7 +520,7 @@ zx_cmap_put(sc); } -static int +int zx_cross_wait(struct zx_softc *sc) { int i; @@ -628,7 +538,7 @@ return (i); } -static int +int zx_cross_loadwid(struct zx_softc *sc, u_int type, u_int index, u_int value) { u_int tmp = 0; @@ -652,15 +562,15 @@ return (0); } -static int +int zx_cmap_put(struct zx_softc *sc) { const u_char *b; u_int i, t; bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUT0); - - zx_cross_wait(sc); + if (zx_cross_wait(sc)) + return (1); bus_space_write_4(sc->sc_bt, sc->sc_bhzx, zx_type, ZX_CROSS_TYPE_CLUTDATA); @@ -679,7 +589,7 @@ return (0); } -static void +void zx_cursor_move(struct zx_softc *sc) { int sx, sy, x, y; @@ -715,7 +625,7 @@ bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80); } -static void +void zx_cursor_set(struct zx_softc *sc) { int i, j, data; @@ -742,7 +652,7 @@ bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80); } -static void +void zx_cursor_blank(struct zx_softc *sc) { @@ -751,7 +661,7 @@ bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) & ~0x80); } -static void +void zx_cursor_unblank(struct zx_softc *sc) { @@ -760,7 +670,7 @@ bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x80); } -static void +void zx_cursor_color(struct zx_softc *sc) { u_int8_t tmp; @@ -779,8 +689,8 @@ bus_space_read_4(sc->sc_bt, sc->sc_bhzcu, zcu_misc) | 0x03); } -static void -zx_blank(device_t dv) +void +zx_blank(struct device *dv) { struct zx_softc *sc; @@ -796,8 +706,8 @@ ~ZX_CROSS_CSR_ENABLE); } -static void -zx_unblank(device_t dv) +void +zx_unblank(struct device *dv) { struct zx_softc *sc; @@ -813,7 +723,7 @@ ZX_CROSS_CSR_ENABLE); } -static paddr_t +paddr_t zxmmap(dev_t dev, off_t off, int prot) { struct zx_softc *sc; @@ -834,28 +744,48 @@ return (-1); } -static void -zx_fillrect(struct zx_softc *sc, int x, int y, int w, int h, uint32_t bg, +void +zx_fillrect(struct rasops_info *ri, int x, int y, int w, int h, long attr, int rop) { + struct zx_softc *sc; + int fg, bg; + + sc = ri->ri_hw; + rasops_unpack_attr(attr, &fg, &bg, NULL); + x = x * sc->sc_fontw + ri->ri_xorigin; + y = y * sc->sc_fonth + ri->ri_yorigin; + w = sc->sc_fontw * w - 1; + h = sc->sc_fonth * h - 1; while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) & ZX_CSR_BLT_BUSY) != 0) ; bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, rop); - bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, bg); + bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, + (bg & 7) ? 0x00000000 : 0xff000000); bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_extent, w | (h << 11)); bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fill, x | (y << 11) | 0x80000000); } -static void -zx_copyrect(struct zx_softc *sc, int sx, int sy, int dx, int dy, int w, +void +zx_copyrect(struct rasops_info *ri, int sx, int sy, int dx, int dy, int w, int h) { - uint32_t dir; + struct zx_softc *sc; + int dir; + + sc = ri->ri_hw; + + sx = sx * sc->sc_fontw + ri->ri_xorigin; + sy = sy * sc->sc_fonth + ri->ri_yorigin; + dx = dx * sc->sc_fontw + ri->ri_xorigin; + dy = dy * sc->sc_fonth + ri->ri_yorigin; + w = w * sc->sc_fontw - 1; + h = h * sc->sc_fonth - 1; if (sy < dy || sx < dx) { dir = 0x80000000; @@ -877,161 +807,102 @@ bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_copy, dx | (dy << 11)); } -static void -zx_do_cursor(void *cookie, int on, int row, int col) +void +zx_do_cursor(struct rasops_info *ri) { - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; - int x, y, wi, he; - - wi = ri->ri_font->fontwidth; - he = ri->ri_font->fontheight; - - if (ri->ri_flg & RI_CURSOR) { - x = ri->ri_ccol * wi + ri->ri_xorigin; - y = ri->ri_crow * he + ri->ri_yorigin; - zx_fillrect(sc, x, y, wi, he, 0xff000000, - ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE | - ZX_ATTR_FORCE_WID); - ri->ri_flg &= ~RI_CURSOR; - } - ri->ri_crow = row; - ri->ri_ccol = col; + zx_fillrect(ri, ri->ri_ccol, ri->ri_crow, 1, 1, 0, + ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE | + ZX_ATTR_FORCE_WID); +} - if (on) - { - x = ri->ri_ccol * wi + ri->ri_xorigin; - y = ri->ri_crow * he + ri->ri_yorigin; - zx_fillrect(sc, x, y, wi, he, 0xff000000, - ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE | - ZX_ATTR_FORCE_WID); - ri->ri_flg |= RI_CURSOR; - } +void +zx_erasecols(void *cookie, int row, int col, int num, long attr) +{ + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + zx_fillrect(ri, col, row, num, 1, attr, ZX_STD_ROP); } -static void -zx_erasecols(void *cookie, int row, int startcol, int ncols, long attr) +void +zx_eraserows(void *cookie, int row, int num, long attr) { - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; - int32_t x, y, width, height, bg; - - x = ri->ri_xorigin + ri->ri_font->fontwidth * startcol; - y = ri->ri_yorigin + ri->ri_font->fontheight * row; - width = ri->ri_font->fontwidth * ncols; - height = ri->ri_font->fontheight; - bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24; - zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP); -} - -static void -zx_eraserows(void *cookie, int row, int nrows, long attr) -{ - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; - int32_t x, y, width, height, bg; - - if ((row == 0) && (nrows == ri->ri_rows)) { - x = y = 0; - width = ri->ri_width; - height = ri->ri_height; - } else { - x = ri->ri_xorigin; - y = ri->ri_yorigin + ri->ri_font->fontheight * row; - width = ri->ri_emuwidth; - height = ri->ri_font->fontheight * nrows; - } - bg = ((uint32_t)ri->ri_devcmap[(attr >> 16) & 0xff]) << 24; - zx_fillrect(sc, x, y, width, height, bg, ZX_STD_ROP); + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + zx_fillrect(ri, 0, row, ri->ri_cols, num, attr, ZX_STD_ROP); } -static void -zx_copyrows(void *cookie, int srcrow, int dstrow, int nrows) +void +zx_copyrows(void *cookie, int src, int dst, int num) { - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; - int32_t x, ys, yd, width, height; + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; - x = ri->ri_xorigin; - ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow; - yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow; - width = ri->ri_emuwidth; - height = ri->ri_font->fontheight * nrows; - zx_copyrect(sc, x, ys, x, yd, width, height); + zx_copyrect(ri, 0, src, 0, dst, ri->ri_cols, num); } -static void -zx_copycols(void *cookie, int row, int srccol, int dstcol, int ncols) +void +zx_copycols(void *cookie, int row, int src, int dst, int num) { - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; - int32_t xs, xd, y, width, height; + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; - xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol; - xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol; - y = ri->ri_yorigin + ri->ri_font->fontheight * row; - width = ri->ri_font->fontwidth * ncols; - height = ri->ri_font->fontheight; - zx_copyrect(sc, xs, y, xd, y, width, height); + zx_copyrect(ri, src, row, dst, row, num, 1); } -static void +void zx_putchar(void *cookie, int row, int col, u_int uc, long attr) { - struct rasops_info *ri = cookie; - struct vcons_screen *scr = ri->ri_hw; - struct zx_softc *sc = scr->scr_cookie; + struct rasops_info *ri; + struct zx_softc *sc; struct wsdisplay_font *font; volatile u_int32_t *dp; u_int8_t *fb; - int fs, i, ul; - uint32_t fg, bg; - - rasops_unpack_attr(attr, &fg, &bg, &ul); - bg = ((uint32_t)ri->ri_devcmap[bg]) << 24; - fg = ((uint32_t)ri->ri_devcmap[fg]) << 24; - if (uc == ' ') { - int x, y; + int fs, i, fg, bg, ul; - x = ri->ri_xorigin + ri->ri_font->fontwidth * col; - y = ri->ri_yorigin + ri->ri_font->fontheight * row; - zx_fillrect(sc, x, y, ri->ri_font->fontwidth, - ri->ri_font->fontheight, bg, ZX_STD_ROP); + ri = (struct rasops_info *)cookie; + + if (uc == ' ') { + zx_fillrect(ri, col, row, 1, 1, attr, ZX_STD_ROP); return; } + sc = (struct zx_softc *)ri->ri_hw; font = ri->ri_font; dp = (volatile u_int32_t *)sc->sc_pixels + - ((row * font->fontheight + ri->ri_yorigin) << 11) + - (col * font->fontwidth + ri->ri_xorigin); + ((row * sc->sc_fonth + ri->ri_yorigin) << 11) + + (col * sc->sc_fontw + ri->ri_xorigin); fb = (u_int8_t *)font->data + (uc - font->firstchar) * ri->ri_fontscale; fs = font->stride; + rasops_unpack_attr(attr, &fg, &bg, &ul); while ((bus_space_read_4(sc->sc_bt, sc->sc_bhzc, zc_csr) & ZX_CSR_BLT_BUSY) != 0) ; bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_rop, ZX_STD_ROP); - bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, fg); - bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_bg, bg); + bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_fg, + (fg & 7) ? 0x00000000 : 0xff000000); + bus_space_write_4(sc->sc_bt, sc->sc_bhzdss0, zd_bg, + (bg & 7) ? 0x00000000 : 0xff000000); bus_space_write_4(sc->sc_bt, sc->sc_bhzc, zc_fontmsk, - 0xffffffff << (32 - font->fontwidth)); + 0xffffffff << (32 - sc->sc_fontw)); - if (font->fontwidth <= 8) { - for (i = font->fontheight; i != 0; i--, dp += 2048) { + if (sc->sc_fontw <= 8) { + for (i = sc->sc_fonth; i != 0; i--, dp += 2048) { *dp = *fb << 24; fb += fs; } } else { - for (i = font->fontheight; i != 0; i--, dp += 2048) { + for (i = sc->sc_fonth; i != 0; i--, dp += 2048) { *dp = *((u_int16_t *)fb) << 16; fb += fs; } @@ -1042,146 +913,3 @@ *dp = 0xffffffff; } } - -#if NWSDISPLAY > 0 -static int -zx_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, - struct lwp *l) -{ - /* we'll probably need to add more stuff here */ - struct vcons_data *vd = v; - struct zx_softc *sc = vd->cookie; - struct wsdisplay_fbinfo *wdf; - struct rasops_info *ri = &sc->sc_fb.fb_rinfo; - struct vcons_screen *ms = sc->vd.active; - switch (cmd) { - case WSDISPLAYIO_GTYPE: - *(u_int *)data = WSDISPLAY_TYPE_SUNTCX; - return 0; - case WSDISPLAYIO_GINFO: - wdf = (void *)data; - wdf->height = ri->ri_height; - wdf->width = ri->ri_width; - wdf->depth = ri->ri_depth; - wdf->cmsize = 256; - return 0; - - case WSDISPLAYIO_GETCMAP: - return zx_getcmap(sc, - (struct wsdisplay_cmap *)data); - case WSDISPLAYIO_PUTCMAP: - return zx_putcmap(sc, - (struct wsdisplay_cmap *)data); - - case WSDISPLAYIO_SMODE: - { - int new_mode = *(int*)data; - if (new_mode != sc->sc_mode) - { - sc->sc_mode = new_mode; - if(new_mode == WSDISPLAYIO_MODE_EMUL) - { - vcons_redraw_screen(ms); - } - } - } - } - return EPASSTHROUGH; -} - -static paddr_t -zx_mmap(void *v, void *vs, off_t offset, int prot) -{ - /* I'm not at all sure this is the right thing to do */ - return zxmmap(0, offset, prot); /* assume minor dev 0 for now */ -} - -static int -zx_putcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm) -{ - u_int index = cm->index; - u_int count = cm->count; - int error,i; - if (index >= 256 || count > 256 || index + count > 256) - return EINVAL; - - for (i = 0; i < count; i++) - { - error = copyin(&cm->red[i], - &sc->sc_cmap[index + i], 1); - if (error) - return error; - error = copyin(&cm->green[i], - &sc->sc_cmap[index + i + 256], 1); - if (error) - return error; - error = copyin(&cm->blue[i], - &sc->sc_cmap[index + i + 512], 1); - if (error) - return error; - } - zx_cmap_put(sc); - - return 0; -} - -static int -zx_getcmap(struct zx_softc *sc, struct wsdisplay_cmap *cm) -{ - u_int index = cm->index; - u_int count = cm->count; - int error,i; - - if (index >= 256 || count > 256 || index + count > 256) - return EINVAL; - - for (i = 0; i < count; i++) - { - error = copyout(&sc->sc_cmap[index + i], - &cm->red[i], 1); - if (error) - return error; - error = copyout(&sc->sc_cmap[index + i + 256], - &cm->green[i], 1); - if (error) - return error; - error = copyout(&sc->sc_cmap[index + i + 256], - &cm->blue[i], 1); - if (error) - return error; - } - - return 0; -} - -static void -zx_init_screen(void *cookie, struct vcons_screen *scr, - int existing, long *defattr) -{ - struct zx_softc *sc = cookie; - struct rasops_info *ri = &scr->scr_ri; - - ri->ri_depth = 8; /*sc->sc_fb.fb_type.fb_depth = 32;*/ - ri->ri_width = sc->sc_width; - ri->ri_height = sc->sc_height; - ri->ri_stride = sc->sc_stride; - ri->ri_flg = RI_CENTER; - - ri->ri_bits = (void *)sc->sc_pixels; - - rasops_init(ri, sc->sc_height/8, sc->sc_width/8); - ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_REVERSE; - rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight, - sc->sc_width / ri->ri_font->fontwidth); - - ri->ri_hw = scr; - - ri->ri_ops.cursor = zx_do_cursor; - ri->ri_ops.copycols = zx_copycols; - ri->ri_ops.copyrows = zx_copyrows; - ri->ri_ops.erasecols = zx_erasecols; - ri->ri_ops.eraserows = zx_eraserows; - ri->ri_ops.putchar = zx_putchar; -} - -#endif /* NWSDISPLAY > 0 */ Index: src/sys/dev/sbus/zxreg.h diff -u src/sys/dev/sbus/zxreg.h:1.5.4.2 src/sys/dev/sbus/zxreg.h:1.5.4.3 --- src/sys/dev/sbus/zxreg.h:1.5.4.2 Sun Oct 18 13:23:31 2009 +++ src/sys/dev/sbus/zxreg.h Sun Oct 18 14:32:29 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: zxreg.h,v 1.5.4.2 2009/10/18 13:23:31 bouyer Exp $ */ +/* $NetBSD: zxreg.h,v 1.5.4.3 2009/10/18 14:32:29 bouyer Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -69,39 +69,6 @@ #define ZX_OFF_LD_SS1 0x01400000 #define ZX_OFF_SS1 0x01800000 -/* offsets relative to ZX_OFF_LC_SS0_KRN */ -/* Leo clock domain */ -#define ZX_LC_SS0_LEO_INT_ENABLE 0x00000000 -#define ZX_LC_SS0_CLR_BLIT_DONE 0x00000004 -#define ZX_LC_SS0_CLR_DEODRAW_SEM 0x00000008 - -/* SBus clock domain */ -#define ZX_LC_SS0_CHIP_CODE 0x00000800 -#define ZX_LC_SS0_SBUS_STATUS 0x00000804 -#define ZX_LC_SS0_SBUS_INT_ENABLE 0x00000808 -#define ZX_LC_SS0_FIRST_TIMEOUT_CNTR 0x0000080c -#define ZX_LC_SS0_RERUN_CNTR 0x00000810 -#define ZX_LC_SS0_CLR_READ_DMA_DONE 0x00000820 -#define ZX_LC_SS0_CLR_WRITE_DMA_DONE 0x00000824 -#define ZX_LC_SS0_CLR_INVALID_PTE 0x00000828 -#define ZX_LC_SS0_CLR_DMA_ERROR_ACK 0x0000082c -#define ZX_LC_SS0_CLR_SLAVE_ILL_ADDR 0x00000830 -#define ZX_LC_SS0_CLR_SLAVE_RERUN_TOUT 0x00000834 -#define ZX_LC_SS0_LEO_RESET 0x00000840 -#define ZX_LC_SS0_CLR_LEO_RESET 0x00000844 -#define ZX_LC_SS0_DMA_READ_PAUSE 0x00000848 - -/* Leo clock domain */ -#define ZX_LC_SS0_LEO_SYSTEM_STATUS 0x00001000 -#define ZX_LC_SS0_FB_ADDRESS_SPACE 0x00001004 -#define ZX_LC_SS0_STENCIL_MASK 0x00001008 -#define ZX_LC_SS0_STENCIL_TRANSPARENT 0x0000100c -#define ZX_LC_SS0_DIRECTION_SIZE 0x00001010 -#define ZX_LC_SS0_SOURCE_ADDR 0x00001014 -#define ZX_LC_SS0_DEST_COPY_NOSTART 0x00001018 -#define ZX_LC_SS0_DEST_COPY_START 0x0000101c -#define ZX_LC_SS0_DEST_FILL_START 0x00001020 - /* ROP register */ #define ZX_ATTR_PICK_DISABLE 0x00000000 #define ZX_ATTR_PICK_2D 0x80000000 Index: src/sys/dev/sbus/zxvar.h diff -u src/sys/dev/sbus/zxvar.h:1.2.10.2 src/sys/dev/sbus/zxvar.h:1.2.10.3 --- src/sys/dev/sbus/zxvar.h:1.2.10.2 Sun Oct 18 13:23:31 2009 +++ src/sys/dev/sbus/zxvar.h Sun Oct 18 14:32:29 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: zxvar.h,v 1.2.10.2 2009/10/18 13:23:31 bouyer Exp $ */ +/* $NetBSD: zxvar.h,v 1.2.10.3 2009/10/18 14:32:29 bouyer Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ * Per-instance data. */ struct zx_softc { - device_t sc_dv; + struct device sc_dv; struct sbusdev sc_sd; struct fbdevice sc_fb; bus_space_tag_t sc_bt; @@ -91,6 +91,8 @@ bus_space_handle_t sc_bhzcu; int sc_flags; + int sc_fontw; + int sc_fonth; u_int8_t *sc_cmap; u_int32_t *sc_pixels; bus_addr_t sc_paddr; @@ -102,15 +104,6 @@ struct fbcurpos sc_cursize; u_int8_t sc_curcmap[8]; u_int32_t sc_curbits[2][32]; - -#if NWSDISPLAY > 0 - uint32_t sc_width; - uint32_t sc_height; /* display width / height */ - uint32_t sc_stride; - int sc_mode; - uint32_t sc_bg; - struct vcons_data vd; -#endif }; #define ZX_BLANKED 0x01 #define ZX_CURSOR 0x02