From ca0ac2c78c506ae4c59137035bfce7eb91c11981 Mon Sep 17 00:00:00 2001 From: ad Date: Fri, 13 Sep 2002 14:03:52 +0000 Subject: [PATCH] Driver for the Sun ZX/Leo framebuffer. This would be called leo, but the amiga port already has a driver by that name. --- sys/arch/sparc/conf/GENERIC | 7 +- sys/dev/DEVNAMES | 4 +- sys/dev/sbus/files.sbus | 6 +- sys/dev/sbus/zx.c | 933 ++++++++++++++++++++++++++++++++++++ sys/dev/sbus/zxreg.h | 269 +++++++++++ sys/dev/sbus/zxvar.h | 118 +++++ 6 files changed, 1333 insertions(+), 4 deletions(-) create mode 100644 sys/dev/sbus/zx.c create mode 100644 sys/dev/sbus/zxreg.h create mode 100644 sys/dev/sbus/zxvar.h diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index 8e8159f7f7c0..3d9efe0df545 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.135 2002/06/17 05:14:25 lukem Exp $ +# $NetBSD: GENERIC,v 1.136 2002/09/13 14:03:52 ad Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc/conf/std.sparc" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.135 $" +#ident "GENERIC-$Revision: 1.136 $" maxusers 32 @@ -603,6 +603,9 @@ cgfourteen0 at obio0 # sun4m # P9100-based display on Tadpole SPARCbook 3. pnozz0 at sbus? slot ? offset ? +# Sun ZX/Leo 24-bit framebuffer +zx* at sbus? slot ? offset ? + #### Other device configuration # Tadpole microcontroller diff --git a/sys/dev/DEVNAMES b/sys/dev/DEVNAMES index e06bb3a39cad..944c2c01e4d8 100644 --- a/sys/dev/DEVNAMES +++ b/sys/dev/DEVNAMES @@ -1,4 +1,4 @@ -# $NetBSD: DEVNAMES,v 1.119 2002/08/11 13:17:53 isaki Exp $ +# $NetBSD: DEVNAMES,v 1.120 2002/09/13 14:03:53 ad Exp $ # # This file contains all used device names and defined attributes in # alphabetical order. New devices added to the system somewhere should first @@ -1282,3 +1282,5 @@ zstty sparc64 zstty sun2 zstty sun3 zstty x68k +zx MI + diff --git a/sys/dev/sbus/files.sbus b/sys/dev/sbus/files.sbus index 2396536cf77a..bce1db77587c 100644 --- a/sys/dev/sbus/files.sbus +++ b/sys/dev/sbus/files.sbus @@ -1,4 +1,4 @@ -# $NetBSD: files.sbus,v 1.17 2001/10/03 04:28:41 mrg Exp $ +# $NetBSD: files.sbus,v 1.18 2002/09/13 14:03:53 ad Exp $ # # Config file and device description for machine-independent SBUS code. # Included by ports that need it. @@ -107,6 +107,10 @@ device tcx: bt_dac, fb, rasops8, rasops24 attach tcx at sbus file dev/sbus/tcx.c tcx needs-flag +device zx: fb, rasops32 +attach zx at sbus +file dev/sbus/zx.c zx + # Tadpole 3GX/3GS (P9100 -- P Nine One Zero Zero -> pnozz) device pnozz: fb, bt_dac, rasops8, rasops16, rasops32 attach pnozz at sbus diff --git a/sys/dev/sbus/zx.c b/sys/dev/sbus/zx.c new file mode 100644 index 000000000000..ffb922299578 --- /dev/null +++ b/sys/dev/sbus/zx.c @@ -0,0 +1,933 @@ +/* $NetBSD: zx.c,v 1.1 2002/09/13 14:03:53 ad Exp $ */ + +/* + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * Driver for the Sun ZX display adapter. This would be called 'leo', but + * NetBSD/amiga already has a driver by that name. The XFree86 and Linux + * drivers were used as "living documentation" when writing this; thanks + * to the authors. + * + * Issues (which can be solved with wscons, happily enough): + * + * o There is lots of unnecessary mucking about rasops in here, primarily + * to appease the sparc fb code. + * + * o RASTERCONSOLE is required. X needs the board set up correctly, and + * that's difficult to reconcile with using the PROM for output. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.1 2002/09/13 14:03:53 ad Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +#ifndef RASTERCONSOLE +#error Sorry, this driver needs the RASTERCONSOLE option +#endif + +/* Force 32-bit writes. */ +#define SETREG(r, v) (*((volatile u_int32_t *)&r) = (v)) + +#define ZX_STD_ROP (ZX_ROP_NEW | ZX_ATTR_WE_ENABLE | \ + ZX_ATTR_OE_ENABLE | ZX_ATTR_FORCE_WID) + +void zx_attach(struct device *, struct device *, void *); +int zx_match(struct device *, struct cfdata *, void *); + +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; + off_t mo_pa; + off_t mo_size; +} static const zx_mmo[] = { + { ZX_FB0_VOFF, ZX_OFF_SS0, 0x00800000 }, + { ZX_LC0_VOFF, ZX_OFF_LC_SS0_USR, 0x00001000 }, + { ZX_LD0_VOFF, ZX_OFF_LD_SS0, 0x00001000 }, + { ZX_LX0_CURSOR_VOFF, ZX_OFF_LX_CURSOR, 0x00001000 }, + { ZX_FB1_VOFF, ZX_OFF_SS1, 0x00800000 }, + { ZX_LC1_VOFF, ZX_OFF_LC_SS1_USR, 0x00001000 }, + { ZX_LD1_VOFF, ZX_OFF_LD_SS1, 0x00001000 }, + { ZX_LX_KRN_VOFF, ZX_OFF_LX_CROSS, 0x00001000 }, + { ZX_LC0_KRN_VOFF, ZX_OFF_LC_SS0_KRN, 0x00001000 }, + { ZX_LC1_KRN_VOFF, ZX_OFF_LC_SS1_KRN, 0x00001000 }, + { ZX_LD_GBL_VOFF, ZX_OFF_LD_GBL, 0x00001000 }, +}; + +struct cfattach zx_ca = { + sizeof(struct zx_softc), zx_match, zx_attach +}; + +extern struct cfdriver zx_cd; + +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 +}; + +int +zx_match(struct device *parent, struct cfdata *cf, void *aux) +{ + struct sbus_attach_args *sa; + + sa = (struct sbus_attach_args *)aux; + + return (strcmp(sa->sa_name, "SUNW,leo") == 0); +} + +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; + struct rasops_info *ri; + volatile struct zx_command *zc; + int isconsole; + + sc = (struct zx_softc *)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 (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0, + 0x800000, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map bits\n", self->dv_xname); + return; + } + fb->fb_pixels = (caddr_t)bus_space_vaddr(bt, bh); + sc->sc_pixels = (u_int32_t *)fb->fb_pixels; + + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LC_SS0_USR, + PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map zc\n", self->dv_xname); + return; + } + sc->sc_zc = (struct zx_command *)bus_space_vaddr(bt, bh); + + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0, + PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map ld/ss0\n", self->dv_xname); + return; + } + sc->sc_zd_ss0 = (struct zx_draw *)bus_space_vaddr(bt, bh); + + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS1, + PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map ld/ss1\n", self->dv_xname); + return; + } + sc->sc_zd_ss1 = + (struct zx_draw_ss1 *)bus_space_vaddr(bt, bh); + + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CROSS, + PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map zx\n", self->dv_xname); + return; + } + sc->sc_zx = (struct zx_cross *)bus_space_vaddr(bt, bh); + + if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CURSOR, + PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) { + printf("%s: can't map zcu\n", self->dv_xname); + return; + } + sc->sc_zcu = (struct zx_cursor *)bus_space_vaddr(bt, bh); + + fb->fb_driver = &zx_fbdriver; + fb->fb_device = &sc->sc_dv; + fb->fb_flags = sc->sc_dv.dv_cfdata->cf_flags & FB_USERMASK; + fb->fb_pfour = NULL; + fb->fb_linebytes = 8192; + + fb_setsize_obp(fb, 32, 1280, 1024, sa->sa_node); + + fb->fb_type.fb_cmsize = 256; + fb->fb_type.fb_depth = 32; + fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes; + fb->fb_type.fb_type = FBTYPE_SUNLEO; + + printf(": %d x %d", fb->fb_type.fb_width, fb->fb_type.fb_height); + isconsole = fb_is_console(sa->sa_node); + if (isconsole) + printf(" (console)"); + printf("\n"); + + sbus_establish(&sc->sc_sd, &sc->sc_dv); + if (sa->sa_nintr != 0) + bus_intr_establish(bt, sa->sa_pri, IPL_NONE, 0, zx_intr, sc); + + sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT); + fb_attach(&sc->sc_fb, isconsole); + zx_reset(sc); + + /* + * 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. + */ + zc = sc->sc_zc; + SETREG(zc->zc_fontt, 1); + SETREG(zc->zc_fontmsk, 0); + + fbrcons_init(&sc->sc_fb); + + SETREG(zc->zc_fontt, 0); + SETREG(zc->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; +} + +int +zxopen(dev_t dev, int flags, int mode, struct proc *p) +{ + + if (device_lookup(&zx_cd, minor(dev)) == NULL) + return (ENXIO); + return (0); +} + +int +zxclose(dev_t dev, int flags, int mode, struct proc *p) +{ + struct zx_softc *sc; + + sc = (struct zx_softc *)device_lookup(&zx_cd, minor(dev)); + + zx_reset(sc); + zx_cursor_blank(sc); + return (0); +} + +int +zxioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +{ + struct zx_softc *sc; + struct fbcmap *cm; + struct fbcursor *cu; + int rv, v, count, i; + + sc = zx_cd.cd_devs[minor(dev)]; + + switch (cmd) { + case FBIOGTYPE: + *(struct fbtype *)data = sc->sc_fb.fb_type; + break; + + case FBIOGATTR: +#define fba ((struct fbgattr *)data) + fba->real_type = sc->sc_fb.fb_type.fb_type; + fba->owner = 0; /* XXX ??? */ + fba->fbtype = sc->sc_fb.fb_type; + fba->sattr.flags = 0; + fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type; + fba->sattr.dev_specific[0] = -1; + fba->emu_types[0] = sc->sc_fb.fb_type.fb_type; + fba->emu_types[1] = -1; + fba->emu_types[2] = -1; +#undef fba + break; + + case FBIOGVIDEO: + *(int *)data = ((sc->sc_flags & ZX_BLANKED) != 0); + break; + + case FBIOSVIDEO: + if (*(int *)data) + zx_unblank(&sc->sc_dv); + else + zx_blank(&sc->sc_dv); + break; + + case FBIOGETCMAP: + cm = (struct fbcmap *)data; + if (cm->index > 256 || cm->count > 256 - cm->index) + return (EINVAL); + rv = copyout(sc->sc_cmap + cm->index, cm->red, cm->count); + if (rv != 0) + rv = copyout(sc->sc_cmap + 256 + cm->index, cm->green, + cm->count); + if (rv != 0) + rv = copyout(sc->sc_cmap + 512 + cm->index, cm->blue, + cm->count); + return (rv); + + case FBIOPUTCMAP: + cm = (struct fbcmap *)data; + if (cm->index > 256 || cm->count > 256 - cm->index) + return (EINVAL); + rv = copyin(cm->red, sc->sc_cmap + cm->index, cm->count); + if (rv != 0) + rv = copyin(cm->green, sc->sc_cmap + 256 + cm->index, + cm->count); + if (rv != 0) + rv = copyin(cm->blue, sc->sc_cmap + 512 + cm->index, + cm->count); + + zx_cmap_put(sc); + return (rv); + + case FBIOGCURPOS: + *(struct fbcurpos *)data = sc->sc_curpos; + break; + + case FBIOSCURPOS: + sc->sc_curpos = *(struct fbcurpos *)data; + zx_cursor_move(sc); + break; + + case FBIOGCURMAX: + ((struct fbcurpos *)data)->x = 32; + ((struct fbcurpos *)data)->y = 32; + break; + + case FBIOSCURSOR: + cu = (struct fbcursor *)data; + v = cu->set; + + if ((v & FB_CUR_SETSHAPE) != 0) { + if ((u_int)cu->size.x > 32 || (u_int)cu->size.y > 32) + return (EINVAL); + count = cu->size.y * 4; + if (!uvm_useracc(cu->image, count, B_READ) || + !uvm_useracc(cu->mask, count, B_READ)) + return (EFAULT); + } + if ((v & FB_CUR_SETCUR) != 0) { + if (cu->enable) + zx_cursor_unblank(sc); + else + zx_cursor_blank(sc); + } + if ((v & (FB_CUR_SETPOS | FB_CUR_SETHOT)) != 0) { + if ((v & FB_CUR_SETPOS) != 0) + sc->sc_curpos = cu->pos; + if ((v & FB_CUR_SETHOT) != 0) + sc->sc_curhot = cu->hot; + zx_cursor_move(sc); + } + if ((v & FB_CUR_SETCMAP) != 0) { + if (cu->cmap.index > 2 || + cu->cmap.count > 2 - cu->cmap.index) + return (EINVAL); + for (i = 0; i < cu->cmap.count; i++) { + if ((v = fubyte(&cu->cmap.red[i])) < 0) + return (EFAULT); + sc->sc_curcmap[i + cu->cmap.index + 0] = v; + if ((v = fubyte(&cu->cmap.green[i])) < 0) + return (EFAULT); + sc->sc_curcmap[i + cu->cmap.index + 2] = v; + if ((v = fubyte(&cu->cmap.blue[i])) < 0) + return (EFAULT); + sc->sc_curcmap[i + cu->cmap.index + 4] = v; + } + zx_cursor_color(sc); + } + if ((v & FB_CUR_SETSHAPE) != 0) { + sc->sc_cursize = cu->size; + count = cu->size.y * 4; + memset(sc->sc_curbits, 0, sizeof(sc->sc_curbits)); + copyin(cu->mask, (caddr_t)sc->sc_curbits[0], count); + copyin(cu->image, (caddr_t)sc->sc_curbits[1], count); + zx_cursor_set(sc); + } + break; + + case FBIOGCURSOR: + cu = (struct fbcursor *)data; + + cu->set = FB_CUR_SETALL; + cu->enable = ((sc->sc_flags & ZX_CURSOR) != 0); + cu->pos = sc->sc_curpos; + cu->hot = sc->sc_curhot; + cu->size = sc->sc_cursize; + + if (cu->image != NULL) { + count = sc->sc_cursize.y * 4; + rv = copyout((caddr_t)sc->sc_curbits[1], + (caddr_t)cu->image, count); + if (rv) + return (rv); + rv = copyout((caddr_t)sc->sc_curbits[0], + (caddr_t)cu->mask, count); + if (rv) + return (rv); + } + if (cu->cmap.red != NULL) { + if (cu->cmap.index > 2 || + cu->cmap.count > 2 - cu->cmap.index) + return (EINVAL); + for (i = 0; i < cu->cmap.count; i++) { + v = sc->sc_curcmap[i + cu->cmap.index + 0]; + if (subyte(&cu->cmap.red[i], v)) + return (EFAULT); + v = sc->sc_curcmap[i + cu->cmap.index + 2]; + if (subyte(&cu->cmap.green[i], v)) + return (EFAULT); + v = sc->sc_curcmap[i + cu->cmap.index + 4]; + if (subyte(&cu->cmap.blue[i], v)) + return (EFAULT); + } + } else { + cu->cmap.index = 0; + cu->cmap.count = 2; + } + break; + + default: +#ifdef DEBUG + log(LOG_NOTICE, "zxioctl(0x%lx) (%s[%d])\n", cmd, + p->p_comm, p->p_pid); +#endif + return (ENOTTY); + } + + return (0); +} + +int +zx_intr(void *cookie) +{ + + return (1); +} + +void +zx_reset(struct zx_softc *sc) +{ + volatile struct zx_draw *zd; + volatile struct zx_command *zc; + struct fbtype *fbt; + u_int i; + + zd = sc->sc_zd_ss0; + zc = sc->sc_zc; + fbt = &sc->sc_fb.fb_type; + + zx_cross_loadwid(sc, ZX_WID_DBL_8, 0, 0x2c0); + zx_cross_loadwid(sc, ZX_WID_DBL_8, 1, 0x30); + zx_cross_loadwid(sc, ZX_WID_DBL_8, 2, 0x20); + zx_cross_loadwid(sc, ZX_WID_DBL_24, 1, 0x30); + + i = sc->sc_zd_ss1->zd_misc; + i |= ZX_SS1_MISC_ENABLE; + SETREG(sc->sc_zd_ss1->zd_misc, i); + + SETREG(zd->zd_wmask, 0xffff); + SETREG(zd->zd_vclipmin, 0); + SETREG(zd->zd_vclipmax, + (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 16)); + SETREG(zd->zd_fg, 0); + SETREG(zd->zd_planemask, 0xff000000); + SETREG(zd->zd_rop, ZX_STD_ROP); + SETREG(zd->zd_widclip, 0); + + SETREG(zc->zc_extent, + (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 11)); + SETREG(zc->zc_addrspace, ZX_ADDRSPC_FONT_OBGR); + SETREG(zc->zc_fontt, 0); + + for (i = 0; i < 256; i++) { + sc->sc_cmap[i] = rasops_cmap[i * 3]; + sc->sc_cmap[i + 256] = rasops_cmap[i * 3 + 1]; + sc->sc_cmap[i + 512] = rasops_cmap[i * 3 + 2]; + } + + zx_cmap_put(sc); +} + +int +zx_cross_wait(struct zx_softc *sc) +{ + volatile struct zx_cross *zx; + int i; + + zx = sc->sc_zx; + + for (i = 300000; i != 0; i--) { + if ((zx->zx_csr & ZX_CROSS_CSR_PROGRESS) == 0) + break; + DELAY(1); + } + + if (i == 0) + printf("zx_cross_wait: timed out\n"); + + return (i); +} + +int +zx_cross_loadwid(struct zx_softc *sc, u_int type, u_int index, u_int value) +{ + volatile struct zx_cross *zx; + u_int tmp; + + zx = sc->sc_zx; + SETREG(zx->zx_type, ZX_CROSS_TYPE_WID); + + if (zx_cross_wait(sc)) + return (1); + + if (type == ZX_WID_DBL_8) + tmp = (index & 0x0f) + 0x40; + else if (type == ZX_WID_DBL_24) + tmp = index & 0x3f; + + SETREG(zx->zx_type, 0x5800 + tmp); + SETREG(zx->zx_value, value); + SETREG(zx->zx_type, ZX_CROSS_TYPE_WID); + SETREG(zx->zx_csr, ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2); + + return (0); +} + +int +zx_cmap_put(struct zx_softc *sc) +{ + volatile struct zx_cross *zx; + const u_char *b; + u_int i, t; + + zx = sc->sc_zx; + + SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUT0); + if (zx_cross_wait(sc)) + return (1); + + SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUTDATA); + + for (i = 0, b = sc->sc_cmap; i < 256; i++) { + t = b[i]; + t |= b[i + 256] << 8; + t |= b[i + 512] << 16; + SETREG(zx->zx_value, t); + } + + SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUT0); + i = zx->zx_csr; + i = i | ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2; + SETREG(zx->zx_csr, i); + return (0); +} + +void +zx_cursor_move(struct zx_softc *sc) +{ + volatile struct zx_cursor *zcu; + int sx, sy, x, y; + + x = sc->sc_curpos.x - sc->sc_curhot.x; + y = sc->sc_curpos.y - sc->sc_curhot.y; + zcu = sc->sc_zcu; + + if (x < 0) { + sx = min(-x, 32); + x = 0; + } else + sx = 0; + + if (y < 0) { + sy = min(-y, 32); + y = 0; + } else + sy = 0; + + if (sx != sc->sc_shiftx || sy != sc->sc_shifty) { + sc->sc_shiftx = sx; + sc->sc_shifty = sy; + zx_cursor_set(sc); + } + + SETREG(zcu->zcu_sxy, ((y & 0x7ff) << 11) | (x & 0x7ff)); + SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x30); + + /* XXX Necessary? */ + SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x80); +} + +void +zx_cursor_set(struct zx_softc *sc) +{ + volatile struct zx_cursor *zcu; + int i, j, data; + + zcu = sc->sc_zcu; + SETREG(zcu->zcu_type, 0); + + for (j = 0; j < 2; j++) { + for (i = sc->sc_shifty; i < 32; i++) { + data = sc->sc_curbits[j][i]; + SETREG(zcu->zcu_data, data >> sc->sc_shiftx); + } + for (i = sc->sc_shifty; i != 0; i--) + SETREG(zcu->zcu_data, 0); + } +} + +void +zx_cursor_blank(struct zx_softc *sc) +{ + volatile struct zx_cursor *zcu; + + sc->sc_flags &= ~ZX_CURSOR; + zcu = sc->sc_zcu; + SETREG(zcu->zcu_misc, zcu->zcu_misc & ~0x80); +} + +void +zx_cursor_unblank(struct zx_softc *sc) +{ + volatile struct zx_cursor *zcu; + + sc->sc_flags |= ZX_CURSOR; + zcu = sc->sc_zcu; + SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x80); +} + +void +zx_cursor_color(struct zx_softc *sc) +{ + volatile struct zx_cursor *zcu; + u_int8_t tmp; + + zcu = sc->sc_zcu; + + SETREG(zcu->zcu_type, 0x50); + + tmp = sc->sc_curcmap[0] | (sc->sc_curcmap[2] << 8) | + (sc->sc_curcmap[4] << 16); + SETREG(zcu->zcu_data, tmp); + + tmp = sc->sc_curcmap[1] | (sc->sc_curcmap[3] << 8) | + (sc->sc_curcmap[5] << 16); + SETREG(zcu->zcu_data, sc->sc_curcmap[1]); + + SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x03); +} + +void +zx_blank(struct device *dv) +{ + struct zx_softc *sc; + volatile struct zx_cross *zx; + + sc = (struct zx_softc *)dv; + + if ((sc->sc_flags & ZX_BLANKED) != 0) + return; + sc->sc_flags |= ZX_BLANKED; + + zx = sc->sc_zx; + SETREG(zx->zx_type, ZX_CROSS_TYPE_VIDEO); + SETREG(zx->zx_csr, zx->zx_csr & ~ZX_CROSS_CSR_ENABLE); +} + +void +zx_unblank(struct device *dv) +{ + struct zx_softc *sc; + volatile struct zx_cross *zx; + + sc = (struct zx_softc *)dv; + + if ((sc->sc_flags & ZX_BLANKED) == 0) + return; + sc->sc_flags &= ~ZX_BLANKED; + + zx = sc->sc_zx; + SETREG(zx->zx_type, ZX_CROSS_TYPE_VIDEO); + SETREG(zx->zx_csr, zx->zx_csr | ZX_CROSS_CSR_ENABLE); +} + +paddr_t +zxmmap(dev_t dev, off_t off, int prot) +{ + struct zx_softc *sc; + const struct zx_mmo *mm, *max; + + sc = device_lookup(&zx_cd, minor(dev)); + off = round_page(off); + mm = zx_mmo; + max = mm + sizeof(zx_mmo) / sizeof(zx_mmo[0]); + + for (; mm < max; mm++) + if (off >= mm->mo_va && off < mm->mo_va + mm->mo_size) { + off = off - mm->mo_va + mm->mo_pa; + return (bus_space_mmap(sc->sc_bt, sc->sc_paddr, + off, prot, BUS_SPACE_MAP_LINEAR)); + } + + return (-1); +} + +void +zx_fillrect(struct rasops_info *ri, int x, int y, int w, int h, long attr, + int rop) +{ + struct zx_softc *sc; + volatile struct zx_command *zc; + volatile struct zx_draw *zd; + int fg, bg; + + sc = ri->ri_hw; + zc = sc->sc_zc; + zd = sc->sc_zd_ss0; + + 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 ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0) + ; + + SETREG(zd->zd_rop, rop); + SETREG(zd->zd_fg, (bg & 7) ? 0x00000000 : 0xff000000); + SETREG(zc->zc_extent, w | (h << 11)); + SETREG(zc->zc_fill, x | (y << 11) | 0x80000000); +} + +void +zx_copyrect(struct rasops_info *ri, int sx, int sy, int dx, int dy, int w, + int h) +{ + struct zx_softc *sc; + volatile struct zx_command *zc; + volatile struct zx_draw *zd; + int dir; + + sc = ri->ri_hw; + zc = sc->sc_zc; + zd = sc->sc_zd_ss0; + + 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; + sx += w; + sy += h; + dx += w; + dy += h; + } else + dir = 0; + + while ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0) + ; + + SETREG(zd->zd_rop, ZX_STD_ROP); + SETREG(zc->zc_extent, w | (h << 11) | dir); + SETREG(zc->zc_src, sx | (sy << 11)); + SETREG(zc->zc_copy, dx | (dy << 11)); +} + +void +zx_do_cursor(struct rasops_info *ri) +{ + + 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); +} + +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); +} + +void +zx_eraserows(void *cookie, int row, int num, long attr) +{ + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + zx_fillrect(ri, 0, row, ri->ri_cols, num, attr, ZX_STD_ROP); +} + +void +zx_copyrows(void *cookie, int src, int dst, int num) +{ + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + zx_copyrect(ri, 0, src, 0, dst, ri->ri_cols, num); +} + +void +zx_copycols(void *cookie, int row, int src, int dst, int num) +{ + struct rasops_info *ri; + + ri = (struct rasops_info *)cookie; + + zx_copyrect(ri, src, row, dst, row, num, 1); +} + +void +zx_putchar(void *cookie, int row, int col, u_int uc, long attr) +{ + struct rasops_info *ri; + struct zx_softc *sc; + struct wsdisplay_font *font; + volatile struct zx_command *zc; + volatile struct zx_draw *zd; + volatile u_int32_t *dp; + u_int8_t *fb; + int fs, i, fg, bg, ul; + + 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; + zc = sc->sc_zc; + zd = sc->sc_zd_ss0; + + dp = (volatile u_int32_t *)sc->sc_pixels + + ((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 ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0) + ; + + SETREG(zd->zd_rop, ZX_STD_ROP); + SETREG(zd->zd_fg, (fg & 7) ? 0x00000000 : 0xff000000); + SETREG(zd->zd_bg, (bg & 7) ? 0x00000000 : 0xff000000); + SETREG(zc->zc_fontmsk, 0xffffffff << (32 - sc->sc_fontw)); + + if (sc->sc_fontw <= 8) { + for (i = sc->sc_fonth; i != 0; i--, dp += 2048) { + *dp = *fb << 24; + fb += fs; + } + } else { + for (i = sc->sc_fonth; i != 0; i--, dp += 2048) { + *dp = *((u_int16_t *)fb) << 16; + fb += fs; + } + } + + if (ul) { + dp -= 4096; + *dp = 0xffffffff; + } +} diff --git a/sys/dev/sbus/zxreg.h b/sys/dev/sbus/zxreg.h new file mode 100644 index 000000000000..2b8dcad24121 --- /dev/null +++ b/sys/dev/sbus/zxreg.h @@ -0,0 +1,269 @@ +/* $NetBSD: zxreg.h,v 1.1 2002/09/13 14:03:53 ad Exp $ */ + +/* + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _DEV_SBUS_ZXREG_H_ +#define _DEV_SBUS_ZXREG_H_ + +/* Hardware offsets. */ +#define ZX_OFF_UNK2 0x00000000 +#define ZX_OFF_LC_SS0_KRN 0x00200000 +#define ZX_OFF_LC_SS0_USR 0x00201000 +#define ZX_OFF_LD_SS0 0x00400000 +#define ZX_OFF_LD_GBL 0x00401000 +#define ZX_OFF_LX_CROSS 0x00600000 +#define ZX_OFF_LX_CURSOR 0x00601000 +#define ZX_OFF_UNK 0x00602000 +#define ZX_OFF_SS0 0x00800000 +#define ZX_OFF_LC_SS1_KRN 0x01200000 +#define ZX_OFF_LC_SS1_USR 0x01201000 +#define ZX_OFF_LD_SS1 0x01400000 +#define ZX_OFF_SS1 0x01800000 + +/* ROP register */ +#define ZX_ATTR_PICK_DISABLE 0x00000000 +#define ZX_ATTR_PICK_2D 0x80000000 +#define ZX_ATTR_PICK_3D 0xa0000000 +#define ZX_ATTR_PICK_2D_REND 0xc0000000 +#define ZX_ATTR_PICK_3D_REND 0xe0000000 + +#define ZX_ATTR_DCE_DISABLE 0x00000000 +#define ZX_ATTR_DCE_ENABLE 0x10000000 + +#define ZX_ATTR_APE_DISABLE 0x00000000 +#define ZX_ATTR_APE_ENABLE 0x08000000 + +#define ZX_ATTR_COLOR_VAR 0x00000000 +#define ZX_ATTR_COLOR_CONST 0x04000000 + +#define ZX_ATTR_AA_DISABLE 0x02000000 +#define ZX_ATTR_AA_ENABLE 0x01000000 + +#define ZX_ATTR_ABE_BG 0x00000000 /* dst + alpha * (src - bg) */ +#define ZX_ATTR_ABE_FB 0x00800000 /* dst + alpha * (src - dst) */ + +#define ZX_ATTR_ABE_DISABLE 0x00000000 +#define ZX_ATTR_ABE_ENABLE 0x00400000 + +#define ZX_ATTR_BLTSRC_A 0x00000000 +#define ZX_ATTR_BLTSRC_B 0x00200000 + +#define ZX_ROP_ZERO (0x0 << 18) +#define ZX_ROP_NEW_AND_OLD (0x8 << 18) +#define ZX_ROP_NEW_AND_NOLD (0x4 << 18) +#define ZX_ROP_NEW (0xc << 18) +#define ZX_ROP_NNEW_AND_OLD (0x2 << 18) +#define ZX_ROP_OLD (0xa << 18) +#define ZX_ROP_NEW_XOR_OLD (0x6 << 18) +#define ZX_ROP_NEW_OR_OLD (0xe << 18) +#define ZX_ROP_NNEW_AND_NOLD (0x1 << 18) +#define ZX_ROP_NNEW_XOR_NOLD (0x9 << 18) +#define ZX_ROP_NOLD (0x5 << 18) +#define ZX_ROP_NEW_OR_NOLD (0xd << 18) +#define ZX_ROP_NNEW (0x3 << 18) +#define ZX_ROP_NNEW_OR_OLD (0xb << 18) +#define ZX_ROP_NNEW_OR_NOLD (0x7 << 18) +#define ZX_ROP_ONES (0xf << 18) + +#define ZX_ATTR_HSR_DISABLE 0x00000000 +#define ZX_ATTR_HSR_ENABLE 0x00020000 + +#define ZX_ATTR_WRITEZ_DISABLE 0x00000000 +#define ZX_ATTR_WRITEZ_ENABLE 0x00010000 + +#define ZX_ATTR_Z_VAR 0x00000000 +#define ZX_ATTR_Z_CONST 0x00008000 + +#define ZX_ATTR_WCLIP_DISABLE 0x00000000 +#define ZX_ATTR_WCLIP_ENABLE 0x00004000 + +#define ZX_ATTR_MONO 0x00000000 +#define ZX_ATTR_STEREO_LEFT 0x00001000 +#define ZX_ATTR_STEREO_RIGHT 0x00003000 + +#define ZX_ATTR_WE_DISABLE 0x00000000 +#define ZX_ATTR_WE_ENABLE 0x00000800 + +#define ZX_ATTR_FCE_DISABLE 0x00000000 +#define ZX_ATTR_FCE_ENABLE 0x00000400 + +#define ZX_ATTR_RE_DISABLE 0x00000000 +#define ZX_ATTR_RE_ENABLE 0x00000200 + +#define ZX_ATTR_GE_DISABLE 0x00000000 +#define ZX_ATTR_GE_ENABLE 0x00000100 + +#define ZX_ATTR_BE_DISABLE 0x00000000 +#define ZX_ATTR_BE_ENABLE 0x00000080 + +#define ZX_ATTR_RGBE_DISABLE 0x00000000 +#define ZX_ATTR_RGBE_ENABLE 0x00000380 + +#define ZX_ATTR_OE_DISABLE 0x00000000 +#define ZX_ATTR_OE_ENABLE 0x00000040 + +#define ZX_ATTR_ZE_DISABLE 0x00000000 +#define ZX_ATTR_ZE_ENABLE 0x00000020 + +#define ZX_ATTR_FORCE_WID 0x00000010 + +#define ZX_ATTR_FC_PLANE_MASK 0x0000000e + +#define ZX_ATTR_BUFFER_A 0x00000000 +#define ZX_ATTR_BUFFER_B 0x00000001 + +/* CSR */ +#define ZX_CSR_BLT_BUSY 0x20000000 + +struct zx_draw { + u_int32_t zd_pad0[896]; + u_int32_t zd_csr; + u_int32_t zd_wid; + u_int32_t zd_wmask; + u_int32_t zd_widclip; + u_int32_t zd_vclipmin; + u_int32_t zd_vclipmax; + u_int32_t zd_pickmin; /* SS1 only */ + u_int32_t zd_pickmax; /* SS1 only */ + u_int32_t zd_fg; + u_int32_t zd_bg; + u_int32_t zd_src; /* Copy/Scroll (SS0 only) */ + u_int32_t zd_dst; /* Copy/Scroll/Fill (SS0 only) */ + u_int32_t zd_extent; /* Copy/Scroll/Fill size (SS0 only) */ + u_int32_t zd_pad1[3]; + u_int32_t zd_setsem; /* SS1 only */ + u_int32_t zd_clrsem; /* SS1 only */ + u_int32_t zd_clrpick; /* SS1 only */ + u_int32_t zd_clrdat; /* SS1 only */ + u_int32_t zd_alpha; /* SS1 only */ + u_int32_t zd_pad2[11]; + u_int32_t zd_winbg; + u_int32_t zd_planemask; + u_int32_t zd_rop; + u_int32_t zd_z; + u_int32_t zd_dczf; /* SS1 only */ + u_int32_t zd_dczb; /* SS1 only */ + u_int32_t zd_dcs; /* SS1 only */ + u_int32_t zd_dczs; /* SS1 only */ + u_int32_t zd_pickfb; /* SS1 only */ + u_int32_t zd_pickbb; /* SS1 only */ + u_int32_t zd_dcfc; /* SS1 only */ + u_int32_t zd_forcecol; /* SS1 only */ + u_int32_t zd_door[8]; /* SS1 only */ + u_int32_t zd_pick[5]; /* SS1 only */ +} __attribute__ ((__packed__)); + +struct zx_draw_ss1 { + u_int32_t zd_pad0[957]; + u_int32_t zd_misc; +} __attribute__ ((__packed__)); +#define ZX_SS1_MISC_ENABLE 0x00000001 +#define ZX_SS1_MISC_STEREO 0x00000002 + +#define ZX_ADDRSPC_OBGR 0x00 +#define ZX_ADDRSPC_Z 0x01 +#define ZX_ADDRSPC_W 0x02 +#define ZX_ADDRSPC_FONT_OBGR 0x04 +#define ZX_ADDRSPC_FONT_Z 0x05 +#define ZX_ADDRSPC_FONT_W 0x06 +#define ZX_ADDRSPC_O 0x08 +#define ZX_ADDRSPC_B 0x09 +#define ZX_ADDRSPC_G 0x0a +#define ZX_ADDRSPC_R 0x0b + +struct zx_command { + u_int32_t zc_csr; + u_int32_t zc_addrspace; + u_int32_t zc_fontmsk; + u_int32_t zc_fontt; + u_int32_t zc_extent; + u_int32_t zc_src; + u_int32_t zc_dst; + u_int32_t zc_copy; + u_int32_t zc_fill; +} __attribute__ ((__packed__)); + +#define ZX_CROSS_TYPE_CLUT0 0x00001000 +#define ZX_CROSS_TYPE_CLUT1 0x00001001 +#define ZX_CROSS_TYPE_CLUT2 0x00001002 +#define ZX_CROSS_TYPE_WID 0x00001003 +#define ZX_CROSS_TYPE_UNK 0x00001006 +#define ZX_CROSS_TYPE_VIDEO 0x00002003 +#define ZX_CROSS_TYPE_CLUTDATA 0x00004000 + +#define ZX_CROSS_CSR_ENABLE 0x00000008 +#define ZX_CROSS_CSR_PROGRESS 0x00000004 +#define ZX_CROSS_CSR_UNK 0x00000002 +#define ZX_CROSS_CSR_UNK2 0x00000001 + +struct zx_cross { + u_int32_t zx_type; + u_int32_t zx_csr; + u_int32_t zx_value; +} __attribute__ ((__packed__)); + +struct zx_cursor { + u_int32_t zcu_pad0[4]; + u_int32_t zcu_type; + u_int32_t zcu_misc; + u_int32_t zcu_sxy; + u_int32_t zcu_data; +} __attribute__ ((__packed__)); + +#endif /* !_DEV_SBUS_ZXREG_H_ */ diff --git a/sys/dev/sbus/zxvar.h b/sys/dev/sbus/zxvar.h new file mode 100644 index 000000000000..ef3cf8ddd89a --- /dev/null +++ b/sys/dev/sbus/zxvar.h @@ -0,0 +1,118 @@ +/* $NetBSD: zxvar.h,v 1.1 2002/09/13 14:03:53 ad Exp $ */ + +/* + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _DEV_SBUS_ZXVAR_H_ +#define _DEV_SBUS_ZXVAR_H_ + +/* + * Sun (and Linux) compatible offsets for mmap(). + */ +#define ZX_FB0_VOFF 0x00000000 +#define ZX_LC0_VOFF 0x00800000 +#define ZX_LD0_VOFF 0x00801000 +#define ZX_LX0_CURSOR_VOFF 0x00802000 +#define ZX_FB1_VOFF 0x00803000 +#define ZX_LC1_VOFF 0x01003000 +#define ZX_LD1_VOFF 0x01004000 +#define ZX_LX0_VERT_VOFF 0x01005000 +#define ZX_LX_KRN_VOFF 0x01006000 +#define ZX_LC0_KRN_VOFF 0x01007000 +#define ZX_LC1_KRN_VOFF 0x01008000 +#define ZX_LD_GBL_VOFF 0x01009000 + +#define ZX_WID_SHARED_8 0 +#define ZX_WID_SHARED_24 1 +#define ZX_WID_DBL_8 2 +#define ZX_WID_DBL_24 3 + +/* + * Per-instance data. + */ +struct zx_softc { + struct device sc_dv; + struct sbusdev sc_sd; + struct fbdevice sc_fb; + bus_space_tag_t sc_bt; + + int sc_flags; + int sc_fontw; + int sc_fonth; + u_int8_t *sc_cmap; + u_int32_t *sc_pixels; + bus_addr_t sc_paddr; + int sc_shiftx; + int sc_shifty; + + struct fbcurpos sc_curpos; + struct fbcurpos sc_curhot; + struct fbcurpos sc_cursize; + u_int8_t sc_curcmap[8]; + u_int32_t sc_curbits[2][32]; + + volatile struct zx_command *sc_zc; + volatile struct zx_cross *sc_zx; + volatile struct zx_draw *sc_zd_ss0; + volatile struct zx_draw_ss1 *sc_zd_ss1; + volatile struct zx_cursor *sc_zcu; +}; +#define ZX_BLANKED 0x01 +#define ZX_CURSOR 0x02 + +#endif /* !_DEV_SBUS_ZXVAR_H_ */