diff options
-rw-r--r-- | sys/arch/hppa/dev/sti.c | 601 | ||||
-rw-r--r-- | sys/arch/hppa/dev/sti_sgc.c | 192 | ||||
-rw-r--r-- | sys/arch/hppa/dev/stireg.h | 430 |
3 files changed, 192 insertions, 1031 deletions
diff --git a/sys/arch/hppa/dev/sti.c b/sys/arch/hppa/dev/sti.c deleted file mode 100644 index b90c7fec196..00000000000 --- a/sys/arch/hppa/dev/sti.c +++ /dev/null @@ -1,601 +0,0 @@ -/* $OpenBSD: sti.c,v 1.2 1999/07/13 21:13:55 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - */ - -#undef STIDEBUG - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> - -#include <vm/vm.h> -#include <vm/vm_kern.h> -#include <vm/pmap.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/iomod.h> -#include <machine/autoconf.h> - -#include <dev/wscons/wsconsvar.h> -#include <dev/wscons/wscons_emul.h> - -#include <hppa/dev/stireg.h> - -#include <hppa/dev/cpudevs.h> - -#define STI_SIZE 0x1000000 - -struct sti_softc { - struct device sc_dev; - - u_int sc_flags; - u_int sc_devtype; - u_int sc_regs; - u_int sc_rom; - - int sc_attr; - struct sti_config sti_config; - struct sti_fontcfg sti_fontcfg; - vaddr_t sc_code; /* code region allocated */ - void (*sti_init) __P((struct sti_initflags *, - struct sti_initin *, - struct sti_initout *, - struct sti_config *)); - void (*sti_state) __P((void)); - void (*sti_font) __P((struct sti_fontflags *, - struct sti_fontin *, - struct sti_fontout *, - struct sti_config *)); - void (*sti_bmove) __P((struct sti_moveflags *, - struct sti_movein *, - struct sti_moveout *, - struct sti_config *)); - void (*sti_test) __P((void)); - void (*sti_fault) __P((void)); - void (*sti_inqcfg) __P((struct sti_inquireflags *, - struct sti_inquirein *, - struct sti_inquireout *, - struct sti_config *)); -}; - -/* sti_init() flags */ -#define STI_TEXTMODE 0x01 -#define STI_CLEARSCR 0x02 - -enum sti_bmove_funcs { - bmf_clear, bmf_copy, bmf_invert -}; - -int stiprobe __P((struct device *, void *, void *)); -void stiattach __P((struct device *, struct device *, void *)); - -struct cfattach sti_ca = { - sizeof(struct sti_softc), stiprobe, stiattach -}; - -struct cfdriver sti_cd = { - NULL, "sti", DV_DULL -}; - -void sti_cursor __P((void *, int, int, int)); -void sti_putstr __P((void *, int, int, char *, int)); -void sti_copycols __P((void *, int, int, int, int)); -void sti_erasecols __P((void *, int, int, int)); -void sti_copyrows __P((void *, int, int, int)); -void sti_eraserows __P((void *, int, int)); -void sti_set_attr __P((void *, int)); - -struct wscons_emulfuncs sti_emulfuncs = { - sti_cursor, - sti_putstr, - sti_copycols, - sti_erasecols, - sti_copyrows, - sti_eraserows, - sti_set_attr -}; - -u_int stiload __P((vaddr_t dst, vaddr_t scode, vaddr_t ecode, int t)); -int sti_init __P((struct sti_softc *sc, int mode)); -int sti_inqcfg __P((struct sti_softc *sc, struct sti_inquireout *out)); -void sti_bmove __P((struct sti_softc *sc, int, int, int, int, int, int, - enum sti_bmove_funcs)); -int sti_print __P((void *aux, const char *pnp)); -int stiioctl __P((void *v, u_long cmd, caddr_t data, int flag, struct proc *)); -int stimmap __P((void *v, off_t offset, int prot)); - -int -stiprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - register struct confargs *ca = aux; - bus_space_handle_t ioh, rioh; - u_int rom; - u_char devtype; - int rv = 0; - - if (ca->ca_type.iodc_type != HPPA_TYPE_FIO || - (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC && - ca->ca_type.iodc_sv_model != HPPA_FIO_SGC)) - return 0; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, STI_SIZE, 0, &ioh)) - return 0; - - /* - * Locate STI ROM. - * On some machines it may not be part of the HPA space. - */ - if (!PAGE0->pd_resv2[1]) { - rom = ca->ca_hpa; - rioh = ioh; - } else - rom = PAGE0->pd_resv2[1]; - - if (rom != ca->ca_hpa && - bus_space_map(ca->ca_iot, rom, IOMOD_HPASIZE, 0, &rioh)) { - bus_space_unmap(ca->ca_iot, ioh, STI_SIZE); - return 0; - } - - devtype = STI_DEVTYP(STI_TYPE_BWGRF, rom); - if ((ca->ca_type.iodc_sv_model == HPPA_FIO_SGC && - STI_ID_HI(STI_TYPE_BWGRF, ca->ca_hpa) == STI_ID_FDDI) || - (devtype != STI_TYPE_BWGRF && devtype != STI_TYPE_WWGRF)) { -#ifdef DEBUG - printf("sti: not a graphics device (:%x)\n", devtype); -#endif - } else - rv = 1; - - bus_space_unmap(ca->ca_iot, ioh, STI_SIZE); - if (ioh != rioh) - bus_space_unmap(ca->ca_iot, rioh, IOMOD_HPASIZE); - return rv; -} - -int -sti_init(sc, mode) - struct sti_softc *sc; - int mode; -{ - struct sti_initflags flags; - struct sti_initin input; - struct sti_initout output; - - bzero(&flags, sizeof(flags)); - bzero(&input, sizeof(input)); - bzero(&output, sizeof(output)); - - flags.wait = 1; - flags.hardreset = 0; - flags.clear = 0; - flags.cmap_black = 1; - flags.bus_error_timer = 1; - if (mode & STI_TEXTMODE) { - flags.texton = 1; - flags.no_change_bet = 1; - flags.no_change_bei = 1; - flags.init_text_cmap = 1; - } - input.text_planes = 1; - sc->sti_init(&flags, &input, &output, &sc->sti_config); - return (output.text_planes != input.text_planes || output.errno); -} - -int -sti_inqcfg(sc, out) - struct sti_softc *sc; - struct sti_inquireout *out; -{ - struct sti_inquireflags flags; - struct sti_inquirein input; - - bzero(&flags, sizeof(flags)); - bzero(&input, sizeof(input)); - bzero(out, sizeof(*out)); - - flags.wait = 1; - sc->sti_inqcfg(&flags, &input, out, &sc->sti_config); - - return out->errno; -} - -void -sti_bmove(sc, x1, y1, x2, y2, h, w, f) - struct sti_softc *sc; - int x1, y1, x2, y2, h, w; - enum sti_bmove_funcs f; -{ - struct sti_moveflags flags; - struct sti_movein input; - struct sti_moveout output; - - bzero(&flags, sizeof(flags)); - bzero(&input, sizeof(input)); - bzero(&output, sizeof(output)); - - flags.wait = 1; - switch (f) { - case bmf_clear: - flags.clear = 1; - input.bg_color = 0; - break; - case bmf_copy: - input.fg_color = 1; - input.bg_color = 0; - break; - case bmf_invert: - input.fg_color = 0; - input.bg_color = 1; - break; - } - input.src_x = x1; - input.src_y = y1; - input.dest_x = x2; - input.dest_y = y2; - input.wheight = h; - input.wwidth = w; - - sc->sti_bmove(&flags, &input, &output, &sc->sti_config); -#ifdef STIDEBUG - if (output.errno) - printf ("%s: sti_bmove returned %d\n", - sc->sc_dev.dv_xname, output.errno); -#endif -} - -void -stiattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - bus_space_handle_t ioh; - struct wscons_attach_args waa; - struct sti_inquireout cfg; - register struct sti_softc *sc = (void *)self; - register struct confargs *ca = aux; - register struct wscons_odev_spec *wo; - register u_int dt, addr; - int error; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, STI_SIZE, 0, &ioh)) - return; - - sc->sc_regs = ca->ca_hpa; - if (!PAGE0->pd_resv2[1]) - sc->sc_rom = ca->ca_hpa; - else - sc->sc_rom = PAGE0->pd_resv2[1]; - - dt = sc->sc_devtype = STI_DEVTYP(STI_TYPE_BWGRF, sc->sc_rom); -#if 0 - sc->sti_init = (void *)STI_IGADDR(dt, sc->sc_rom); - sc->sti_state = (void *)STI_SMADDR(dt, sc->sc_rom); - sc->sti_font = (void *)STI_FUADDR(dt, sc->sc_rom); - sc->sti_bmove = (void *)STI_BMADDR(dt, sc->sc_rom); - sc->sti_test = (void *)STI_STADDR(dt, sc->sc_rom); - sc->sti_fault = (void *)STI_EHADDR(dt, sc->sc_rom); - sc->sti_inqcfg = (void *)STI_ICADDR(dt, sc->sc_rom); -#else - { - u_int t; - t = STI_EADDR(dt, sc->sc_rom) - STI_IGADDR(dt, sc->sc_rom); - t = hppa_round_page(t); - if (!(sc->sc_code = uvm_km_kmemalloc(kmem_map, - uvmexp.kmem_object, t, 0))) { - printf(": cannot allocate %d bytes for code\n", t); - return; - } else - pmap_protect(kmem_map->pmap, sc->sc_code, - sc->sc_code + t, VM_PROT_ALL); - - t = 0; - sc->sti_init = (void *)sc->sc_code; - t += stiload(sc->sc_code + t, STI_IGADDR(dt, sc->sc_rom), - STI_SMADDR(dt, sc->sc_rom), dt); - sc->sti_state = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_SMADDR(dt, sc->sc_rom), - STI_FUADDR(dt, sc->sc_rom), dt); - sc->sti_font = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_FUADDR(dt, sc->sc_rom), - STI_BMADDR(dt, sc->sc_rom), dt); - sc->sti_bmove = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_BMADDR(dt, sc->sc_rom), - STI_STADDR(dt, sc->sc_rom), dt); - sc->sti_test = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_STADDR(dt, sc->sc_rom), - STI_EHADDR(dt, sc->sc_rom), dt); - sc->sti_fault = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_EHADDR(dt, sc->sc_rom), - STI_ICADDR(dt, sc->sc_rom), dt); - sc->sti_inqcfg = (void *)(sc->sc_code + t); - t += stiload(sc->sc_code + t, STI_ICADDR(dt, sc->sc_rom), - STI_EADDR(dt, sc->sc_rom), dt); - fcacheall(); - } -#endif - - /* fill out sti_config */ - bzero(&sc->sti_config, sizeof(sc->sti_config)); - { - register u_int *p; - register u_int *q = (u_int *)STI_MMAP(dt, sc->sc_rom); - -#ifdef STIDEBUG - printf ("stregions @%p:\n", q); -#endif - for (p = sc->sti_config.regions; - p < &sc->sti_config.regions[STI_REGIONS]; p++) { - struct sti_region r; - if (dt == STI_TYPE_BWGRF) { - /* we know that sti_region is 4 bytes */ - *((u_char *)&r + 0) = *q++; - *((u_char *)&r + 1) = *q++; - *((u_char *)&r + 2) = *q++; - *((u_char *)&r + 3) = *q++; - } else - *(u_int *)&r = *q++; - - *p = ((p == sc->sti_config.regions)? sc->sc_rom : - sc->sc_regs) + (r.offset << PGSHIFT); - - if (r.last) - break; -#ifdef STIDEBUG - printf("@0x%05x, sys %d, cache %d, btlb %d, len %d\n", - r.offset, r.sysonly, r.cache, r.btlb, r.length); -#endif - } - } - - - if ((error = sti_init(sc, 0))) { - printf (": can not initialize (%d)\n", error); - return; - } - - if ((error = sti_inqcfg(sc, &cfg))) { - printf (": error %d inquiring config\n", error); - return; - } - - if ((error = sti_init(sc, STI_TEXTMODE))) { - printf (": can not initialize (%d)\n", error); - return; - } - - /* fill out sti_fontcfg */ - addr = STI_FONTAD(dt, sc->sc_rom) & ~3; - sc->sti_fontcfg.firstc = STIF_FIRSTC (dt, addr); - sc->sti_fontcfg.lastc = STIF_LASTC (dt, addr); - sc->sti_fontcfg.ftheight = STIF_FHEIGHT(dt, addr); - sc->sti_fontcfg.ftwidth = STIF_FWIDTH (dt, addr); - sc->sti_fontcfg.ftype = STIF_FTYPE (dt, addr); - sc->sti_fontcfg.bpc = STIF_BPC (dt, addr); - sc->sti_fontcfg.uheight = STIF_UHEIGHT(dt, addr); - sc->sti_fontcfg.uoffset - STIF_UOFFSET(dt, addr); - - printf (": %s rev %d.%d\n" - "%s: %dx%d frame buffer, %dx%dx%d display, offset %dx%d\n" - "%s: %dx%d font type %d, %d bpc, charset %d-%d\n", - cfg.devname, STI_GLOREV(dt, sc->sc_rom) >> 4, - STI_GLOREV(dt, sc->sc_rom) & 0xf, - sc->sc_dev.dv_xname, cfg.fbwidth, cfg.fbheight, - cfg.dwidth, cfg.dheight, cfg.bpp, cfg.owidth, cfg.oheight, - sc->sc_dev.dv_xname, - sc->sti_fontcfg.ftwidth, sc->sti_fontcfg.ftheight, - sc->sti_fontcfg.ftype, sc->sti_fontcfg.bpc, - sc->sti_fontcfg.firstc, sc->sti_fontcfg.lastc); - - /* attach WSCONS */ - wo = &waa.waa_odev_spec; - - wo->wo_emulfuncs = &sti_emulfuncs; - wo->wo_emulfuncs_cookie = sc; - - wo->wo_ioctl = stiioctl; - wo->wo_mmap = stimmap; - wo->wo_miscfuncs_cookie = sc; - - wo->wo_nrows = 64; - wo->wo_ncols = 80; - wo->wo_crow = 64; - wo->wo_ccol = 0; - - config_found(parent, &waa, sti_print); - - return; -} - -u_int -stiload(dst, scode, ecode, t) - vaddr_t dst, scode, ecode; - int t; -{ - vaddr_t sdst = dst; - -#ifdef STIDEBUG - printf("stiload(%x, %x, %x, %d)\n", dst, scode, ecode, t); -#endif - while (scode < ecode) { - if (t == STI_TYPE_BWGRF) - *((u_char *)dst)++ = *(u_char *)scode; - else - *((u_int *)dst)++ = *(u_int *)scode; - scode += sizeof(u_int); - } - - return dst - sdst; -} - -int -sti_print(aux, pnp) - void *aux; - const char *pnp; -{ - if (pnp) - printf("wscons at %s", pnp); - return UNCONF; -} - -int -stiioctl(v, cmd, data, flag, p) - void *v; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - /* register struct sti_softc *sc; */ - - return -1; -} - -int -stimmap(v, offset, prot) - void *v; - off_t offset; - int prot; -{ - /* XXX not finished */ - return offset; -} - -void -sti_cursor(v, on, row, col) - void *v; - int on, row, col; -{ - register struct sti_softc *sc = v; - - sti_bmove(sc, row * sc->sti_fontcfg.ftheight, col * sc->sti_fontcfg.ftwidth, - row * sc->sti_fontcfg.ftheight, col * sc->sti_fontcfg.ftwidth, - sc->sti_fontcfg.ftwidth, sc->sti_fontcfg.ftheight, bmf_invert); -} - -void -sti_putstr(v, row, col, cp, len) - void *v; - int row, col; - char *cp; - int len; -{ - register struct sti_softc *sc = v; - struct sti_fontflags flags; - struct sti_fontin input; - struct sti_fontout output; - - bzero(&flags, sizeof(flags)); - bzero(&input, sizeof(input)); - bzero(&output, sizeof(output)); - - flags.wait = 1; - /* XXX does not handle text attributes */ - input.fg_color = 1; - input.bg_color = 0; - input.dest_x = col * sc->sti_fontcfg.ftwidth; - input.dest_y = row * sc->sti_fontcfg.ftheight; - input.startaddr = STI_FONTAD(sc->sc_devtype, sc->sc_rom); - for (; *cp; cp++, input.dest_x += sc->sti_fontcfg.ftwidth) { - input.index = *cp; - sc->sti_font(&flags, &input, &output, &sc->sti_config); - } -} - -void -sti_copycols(v, row, srccol, dstcol, ncols) - void *v; - int row, srccol, dstcol, ncols; -{ - register struct sti_softc *sc = v; - - sti_bmove(sc, - row * sc->sti_fontcfg.ftheight, srccol * sc->sti_fontcfg.ftwidth, - row * sc->sti_fontcfg.ftheight, dstcol * sc->sti_fontcfg.ftwidth, - ncols * sc->sti_fontcfg.ftwidth, sc->sti_fontcfg.ftheight, - bmf_copy); -} - -void -sti_erasecols(v, row, startcol, ncols) - void *v; - int row, startcol, ncols; -{ - register struct sti_softc *sc = v; - - sti_bmove(sc, - row * sc->sti_fontcfg.ftheight, startcol * sc->sti_fontcfg.ftwidth, - row * sc->sti_fontcfg.ftheight, startcol * sc->sti_fontcfg.ftwidth, - ncols * sc->sti_fontcfg.ftwidth, sc->sti_fontcfg.ftheight, - bmf_clear); -} - -void -sti_copyrows(v, srcrow, dstrow, nrows) - void *v; - int srcrow, dstrow, nrows; -{ - register struct sti_softc *sc = v; - - sti_bmove(sc, - srcrow * sc->sti_fontcfg.ftheight, 0, - dstrow * sc->sti_fontcfg.ftheight, 0, - sc->sti_config.fbwidth, nrows + sc->sti_fontcfg.ftheight, - bmf_copy); -} - -void -sti_eraserows(v, srcrow, nrows) - void *v; - int srcrow, nrows; -{ - register struct sti_softc *sc = v; - - sti_bmove(sc, - srcrow * sc->sti_fontcfg.ftheight, 0, - srcrow * sc->sti_fontcfg.ftheight, 0, - sc->sti_config.fbwidth, nrows + sc->sti_fontcfg.ftheight, - bmf_clear); -} - -void -sti_set_attr(v, val) - void *v; - int val; -{ - register struct sti_softc *sc = v; - - sc->sc_attr = val; -} - diff --git a/sys/arch/hppa/dev/sti_sgc.c b/sys/arch/hppa/dev/sti_sgc.c new file mode 100644 index 00000000000..72c4d1cf5ee --- /dev/null +++ b/sys/arch/hppa/dev/sti_sgc.c @@ -0,0 +1,192 @@ +/* $OpenBSD: sti_sgc.c,v 1.1 2000/05/30 19:42:02 mickey Exp $ */ + +/* + * Copyright (c) 2000 Michael Shalayeff + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael Shalayeff. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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 MIND, + * 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. + */ +/* + * These cards has to be known to work so far: + * - HPA1991AC19 rev 0.0 (715/33) w/ weird hack to align sti rom ptrs + * - HPA208LC1280 rev 8.04 (712/80) just works + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> + +#include <vm/vm.h> +#include <vm/vm_kern.h> +#include <uvm/uvm.h> + +#include <machine/bus.h> +#include <machine/cpu.h> +#include <machine/iomod.h> +#include <machine/autoconf.h> + +#include <dev/wscons/wsdisplayvar.h> +#include <dev/wscons/wsconsio.h> + +#include <dev/ic/stireg.h> +#include <dev/ic/stivar.h> + +#include <hppa/dev/cpudevs.h> + +#define STI_MEMSIZE 0x1000000 + +int sti_sgc_probe __P((struct device *, void *, void *)); +void sti_sgc_attach __P((struct device *, struct device *, void *)); + +struct cfattach sti_sgc_ca = { + sizeof(struct sti_softc), sti_sgc_probe, sti_sgc_attach +}; + +int +sti_sgc_probe(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + register struct confargs *ca = aux; + bus_space_handle_t ioh, romh; + u_int rom; + u_char devtype; + int rv = 0, romunmapped = 0; + + if (ca->ca_type.iodc_type != HPPA_TYPE_FIO || + (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC && + ca->ca_type.iodc_sv_model != HPPA_FIO_SGC)) + return 0; + + if ((rv = bus_space_map(ca->ca_iot, ca->ca_hpa, STI_MEMSIZE, 0, &ioh))) { +#ifdef STIDEBUG + printf("st: cannot map io space (%d)\n", rv); +#endif + return 0; + } + + /* + * Locate STI ROM. + * On some machines it may not be part of the HPA space. + */ + if (!PAGE0->pd_resv2[1]) { + rom = ca->ca_hpa; + romh = ioh; + romunmapped++; + } else + rom = PAGE0->pd_resv2[1]; + + printf ("sti: hpa=%x, rom=%x\n", ca->ca_hpa, rom); + + /* if it does not map, probably part of the lasi space */ + if (rom != ca->ca_hpa && + (rv = bus_space_map(ca->ca_iot, rom, IOMOD_HPASIZE, 0, &romh))) { +#ifdef STIDEBUG + printf ("sti: cannot map rom space (%d)\n", rv); +#endif + if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) { + romh = rom; + romunmapped++; + } else { + /* in this case i have no freaking idea */ + bus_space_unmap(ca->ca_iot, ioh, STI_MEMSIZE); + return 0; + } + } + + printf("sti: ioh=%x, romh=%x\n", ioh, romh); + + devtype = bus_space_read_1(ca->ca_iot, ioh, 3); + +#ifdef STIDEBUG + printf("sti: devtype=%d\n", devtype); +#endif +#if 0 /* ignore this for now */ + if ((ca->ca_type.iodc_sv_model == HPPA_FIO_SGC && + STI_ID_HI(STI_TYPE_BWGRF, rioh) == STI_ID_FDDI) || + (devtype != STI_TYPE_BWGRF && devtype != STI_TYPE_WWGRF)) { +#ifdef STIDEBUG + printf("sti: not a graphics device (%x)\n", devtype); +#endif + } else +#endif + rv = 1; + + bus_space_unmap(ca->ca_iot, ioh, STI_MEMSIZE); + if (!romunmapped) + bus_space_unmap(ca->ca_iot, romh, IOMOD_HPASIZE); + return rv; +} + +void +sti_sgc_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct sti_softc *sc = (void *)self; + struct confargs *ca = aux; + bus_addr_t addr; + int rv; + + if (!PAGE0->pd_resv2[1]) + addr = ca->ca_hpa; + else + addr = PAGE0->pd_resv2[1]; + + sc->memt = sc->iot = ca->ca_iot; + + if ((rv = bus_space_map(ca->ca_iot, ca->ca_hpa, STI_MEMSIZE, 0, + &sc->ioh))) { +#ifdef STIDEBUG + printf("st: cannot map io space (%d)\n", rv); +#endif + return; + } + + sc->sc_devtype = bus_space_read_1(sc->iot, sc->ioh, 3); + printf ("sti: hpa=%x, rom=%x\n", ca->ca_hpa, addr); + + /* if it does not map, probably part of the lasi space */ + if (addr == ca->ca_hpa) + sc->romh = sc->ioh; + else if ((rv = bus_space_map(ca->ca_iot, addr, IOMOD_HPASIZE, 0, &sc->romh))) { +#ifdef STIDEBUG + printf ("sti: cannot map rom space (%d)\n", rv); +#endif + if ((addr & HPPA_IOBEGIN) == HPPA_IOBEGIN) + sc->romh = addr; + else { + /* in this case i have no freaking idea */ + bus_space_unmap(ca->ca_iot, sc->ioh, STI_MEMSIZE); + return; + } + } + + printf("sti: ioh=%x, romh=%x\n", sc->ioh, sc->romh); + + sti_attach_common(sc); +} + diff --git a/sys/arch/hppa/dev/stireg.h b/sys/arch/hppa/dev/stireg.h deleted file mode 100644 index b0c353a3c12..00000000000 --- a/sys/arch/hppa/dev/stireg.h +++ /dev/null @@ -1,430 +0,0 @@ -/* $OpenBSD: stireg.h,v 1.1 1998/12/31 03:20:44 mickey Exp $ */ - -/* - * Copyright 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/* - * Copyright (c) 1991,1992,1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: grf_stireg.h 1.7 94/12/14$ - */ - -#ifndef _STIREG_H_ -#define _STIREG_H_ - -/* - * Standard Text Interface. - */ - -#define STI_CODECNT 7 -#define STI_REGIONS 8 -#define STI_NAMELEN 32 - -/* - * Structure templates for old byte-wide interface - */ -typedef struct { - char p[3]; - u_char b0; -} stibyte; - -typedef struct { - char p0[3]; - u_char b0; - char p1[3]; - u_char b1; -} stihalf; - -typedef struct { - char p0[3]; - u_char b0; - char p1[3]; - u_char b1; - char p2[3]; - u_char b2; - char p3[3]; - u_char b3; -} stiword; - -/* - * STI ROM layout, byte-wide and word-wide interfaces. - * Word-wide fields are aligned to word boundaries for access even - * though some are technically smaller (e.g. devtype is 8 bits). - */ -struct sti_bytewide { - stibyte sti_devtype; /* 0x03: device type (see below) */ - stihalf sti_revno; /* 0x07: global/local ROM revision */ - char sti_p0[0x4]; - stiword sti_gid_hi; /* 0x13: graphics ID (high word) */ - stiword sti_gid_lo; /* 0x23: graphics ID (low byte) */ - stiword sti_fontaddr; /* 0x33: font start address */ - stiword sti_mss; /* 0x43: max state storage */ - stiword sti_erom; /* 0x53: last address of ROM */ - stiword sti_mmap; /* 0x63: memory map information */ - stihalf sti_mstore; /* 0x73: max re-entrant storage */ - stihalf sti_mtimo; /* 0x7b: max 1/10 secs for routines */ -#ifdef hp300 - char sti_p1[0x180]; -#else - char sti_p1[0x80]; -#endif - stiword sti_routine[STI_CODECNT+1]; /* 0x103: routines */ -}; - -struct sti_wordwide { - u_int sti_devtype; /* 0x00: device type (see below) */ - u_int sti_revno; /* 0x04: global ROM revision */ - u_int sti_gid_hi; /* 0x08: graphics ID (high word) */ - u_int sti_gid_lo; /* 0x0c: graphics ID (low byte) */ - u_int sti_fontaddr; /* 0x10: font start address */ - u_int sti_mss; /* 0x14: max state storage */ - u_int sti_erom; /* 0x18: last address of ROM */ - u_int sti_mmap; /* 0x1c: memory map information */ - u_int sti_mstore; /* 0x20: max re-entrant storage */ - u_int sti_mtimo; /* 0x24: max 1/10 secs for routines */ -#ifdef hp300 - char sti_p0[0x58]; -#else - char sti_p0[0x18]; -#endif - u_int sti_routine[STI_CODECNT+1]; /* 0x40: routines */ -}; - -#define STI_GETBYTE(t,a,f) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct sti_bytewide *)(a))->f.b0 : \ - (((struct sti_wordwide *)(a))->f & 0xff)) - -#define STI_GETHALF(t,a,f) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((((struct sti_bytewide *)(a))->f.b0 << 8) | \ - (((struct sti_bytewide *)(a))->f.b1)) : \ - (((struct sti_wordwide *)(a))->f & 0xffff)) - -#define STI_GETWORD(t,a,f) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((((struct sti_bytewide *)(a))->f.b0 << 24) | \ - (((struct sti_bytewide *)(a))->f.b1 << 16) | \ - (((struct sti_bytewide *)(a))->f.b2 << 8) | \ - (((struct sti_bytewide *)(a))->f.b3)) : \ - ((struct sti_wordwide *)(a))->f) - - -#define STI_DEVTYP(t,a) STI_GETBYTE(t,a,sti_devtype) -#define STI_GLOREV(t,a) (STI_GETHALF(t,a,sti_revno) >> 8) -#define STI_LOCREV(t,a) (STI_GETHALF(t,a,sti_revno) & 0xff) -#define STI_ID_HI(t,a) STI_GETWORD(t,a,sti_gid_hi) -#define STI_ID_LO(t,a) STI_GETWORD(t,a,sti_gid_lo) -#define STI_FONTAD(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_fontaddr)) -#define STI_MSS(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_mss)) -#define STI_EROM(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_erom)) -#define STI_MMAP(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_mmap)) -#define STI_MSTOR(t,a) STI_GETHALF(t,a,sti_mstore) -#define STI_MTOUT(t,a) STI_GETHALF(t,a,sti_mtimo) - - /* INIT_GRAPH address */ -#define STI_IGADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[0])) - /* STATE_MGMT address */ -#define STI_SMADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[1])) - /* FONT_UNP/MV address*/ -#define STI_FUADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[2])) - /* BLOCK_MOVE address */ -#define STI_BMADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[3])) - /* SELF_TEST address */ -#define STI_STADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[4])) - /* EXCEP_HDLR address */ -#define STI_EHADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[5])) - /* INQ_CONF address */ -#define STI_ICADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[6])) - /* End address */ -#define STI_EADDR(t,a) ((u_int)(a) + STI_GETWORD(t,a,sti_routine[7])) - -/* STI_ID_HI */ -#define STI_ID_FDDI 0x280B31AF /* Medusa STI ROM graphics ID */ - -/* STI_DEVTYP */ -#define STI_TYPE_BWGRF 1 /* graphics device (byte-wide if) */ -#define STI_TYPE_WWGRF 3 /* graphics device (word-wide if) */ - -/* - * STI font information. - * Note that fields of word-wide structure are not word aligned - * making access a little harder. - */ -struct stifont_bytewide { - stihalf sti_firstchar; /* 0x03: first character */ - stihalf sti_lastchar; /* 0x0b: last character */ - stibyte sti_fwidth; /* 0x13: font width */ - stibyte sti_fheight; /* 0x17: font height */ - stibyte sti_ftype; /* 0x1b: font type */ - stibyte sti_bpc; /* 0x1f: bytes per character */ - stiword sti_next; /* 0x23: offset of next font */ - stibyte sti_uheight; /* 0x33: underline height */ - stibyte sti_uoffset; /* 0x37: underline offset */ -}; - -struct stifont_wordwide { - u_short sti_firstchar; /* 0x00: first character */ - u_short sti_lastchar; /* 0x02: last character */ - u_char sti_fwidth; /* 0x04: font width */ - u_char sti_fheight; /* 0x05: font height */ - u_char sti_ftype; /* 0x06: font type */ - u_char sti_bpc; /* 0x07: bytes per character */ - u_int sti_next; /* 0x08: offset of next font */ - u_char sti_uheight; /* 0x0c: underline height */ - u_char sti_uoffset; /* 0x0d: underline offset */ - char sti_p0[2]; -}; - -#define STIF_FIRSTC(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((((struct stifont_bytewide *)(a))->sti_firstchar.b0 << 8) | \ - (((struct stifont_bytewide *)(a))->sti_firstchar.b1)) : \ - (((volatile u_int *)(a))[0] >> 16)) -#define STIF_LASTC(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((((struct stifont_bytewide *)(a))->sti_lastchar.b0 << 8) | \ - (((struct stifont_bytewide *)(a))->sti_lastchar.b1)) : \ - (((volatile u_int *)(a))[0] & 0xffff)) -#define STIF_FWIDTH(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_fwidth.b0 : \ - (((volatile u_int *)(a))[1] >> 24)) -#define STIF_FHEIGHT(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_fheight.b0 : \ - ((((volatile u_int *)(a))[1] >> 16) & 0xff)) -#define STIF_FTYPE(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_ftype.b0 : \ - ((((volatile u_int *)(a))[1] >> 8) & 0xff)) -#define STIF_BPC(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_bpc.b0 : \ - (((volatile u_int *)(a))[1] & 0xff)) -#define STIF_NEXT(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((((struct stifont_bytewide *)(a))->sti_next.b0 << 24) | \ - (((struct stifont_bytewide *)(a))->sti_next.b1 << 16) | \ - (((struct stifont_bytewide *)(a))->sti_next.b2 << 8) | \ - (((struct stifont_bytewide *)(a))->sti_next.b3)) : \ - ((volatile u_int *)(a))[2]) -#define STIF_UHEIGHT(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_uheight.b0 : \ - (((volatile u_int *)(a))[3] >> 24)) -#define STIF_UOFFSET(t,a) \ - (((t) == STI_TYPE_BWGRF) ? \ - ((struct stifont_bytewide *)(a))->sti_uoffset.b0 : \ - ((((volatile u_int *)(a))[3] >> 16) & 0xff)) - - - -/* - * Device region information. - */ -struct sti_region { - u_int offset :14, - sysonly :1, - cache :1, - btlb :1, - last :1, - length :14; -}; - -/* - * Global configuration information. There is one per STI device. - */ -struct sti_config { - u_int text_planes; - u_short dwidth; - u_short dheight; - u_short owidth; - u_short oheight; - u_short fbwidth; - u_short fbheight; - u_int regions[STI_REGIONS]; - u_int reentry_level; - u_int save_address; - u_int *future; -}; - -/* - * Font config - */ -struct sti_fontcfg { - u_short firstc; /* first character */ - u_short lastc; /* last character */ - u_char ftwidth; /* font width */ - u_char ftheight; /* font height */ - u_char ftype; /* font type */ - u_char bpc; /* bytes per character */ - u_char uheight; /* underline height */ - u_char uoffset; /* underline offset */ -}; - -/* - * Device initialization structures. - */ -struct sti_initflags { /* Initialization flags */ - u_int wait :1, - hardreset :1, - texton :1, /* ignored if no_change_text == 1 */ - graphon :1, /* ignored if no_change_graph == 1 */ - clear :1, - cmap_black :1, /* ignored if hardreset == 0 */ - bus_error_timer:1, /* ignored if no_change_bet == 1 */ - bus_error_int :1, /* ignored if no_change_bei == 1 */ - no_change_text :1, - no_change_graph:1, - no_change_bet :1, - no_change_bei :1, - init_text_cmap :1, - pad :19; - int *future; -}; - -struct sti_initin { /* Initialization input args */ - int text_planes; - int *future; -}; - -struct sti_initout { /* Initialization output args */ - int errno; - int text_planes; - int *future; -}; - -/* - * Inquire Configuration. - */ -struct sti_inquireflags { - u_int wait :1; - u_int pad :31; - int *future; -}; - -struct sti_inquirein { - int *future; -}; - -struct sti_inquireout { - int errno; - short dwidth; - short dheight; - short owidth; - short oheight; - short fbwidth; - short fbheight; - int bpp; - int bits; - int planes; - char devname[STI_NAMELEN]; - u_int attributes; - int *future; -}; - -/* - * Font Unpack/Move. - */ -struct sti_fontflags { - u_int wait :1; - u_int pad :31; - int *future; -}; - -struct sti_fontin { - int startaddr; - short index; - char fg_color; - char bg_color; - short dest_x; - short dest_y; - int *future; -}; - -struct sti_fontout { - int errno; - int *future; -}; - -/* - * Block Move. - */ -struct sti_moveflags { - u_int wait :1; - u_int color :1; - u_int clear :1; - u_int pad :29; - int *future; -}; - -struct sti_movein { - char fg_color; - char bg_color; - short src_x; - short src_y; - short dest_x; - short dest_y; - short wwidth; - short wheight; - int *future; -}; - -struct sti_moveout { - int errno; - int *future; -}; - -/* - * Error codes returned by STI ROM routines. - */ -#define NO_ERROR 0 -#define BAD_REENTRY_LEVEL 1 -#define NO_REGIONS_DEFINED 2 -#define ILLEGAL_NUMBER_PLANES 3 -#define INVALID_FONT_INDEX 4 -#define INVALID_FONT_LOCATION 5 -#define INVALID_COLOR 6 -#define INVALID_BLKMOVE_SRC 7 -#define INVALID_BLKMOVE_DST 8 -#define INVALID_BLKMOVE_SIZE 9 -#define NO_BUS_ERROR_INT 10 -#define BUS_ERROR 11 -#define HARDWARE_FAILURE 12 - -#endif /* _STIREG_H_ */ |