Annotation of Net2/arch/hp300/dev/grf_tc.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1988 University of Utah.
                      3:  * Copyright (c) 1990 The Regents of the University of California.
                      4:  * All rights reserved.
                      5:  *
                      6:  * This code is derived from software contributed to Berkeley by
                      7:  * the Systems Programming Group of the University of Utah Computer
                      8:  * Science Department.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  *
                     38:  * from: Utah $Hdr: grf_tc.c 1.18 91/04/02$
                     39:  *
                     40:  *     @(#)grf_tc.c    7.4 (Berkeley) 5/7/91
                     41:  */
                     42: 
                     43: #include "grf.h"
                     44: #if NGRF > 0
                     45: 
                     46: /*
                     47:  * Graphics routines for TOPCAT frame buffer
                     48:  */
                     49: #include "sys/param.h"
                     50: #include "sys/errno.h"
                     51: 
                     52: #include "grfioctl.h"
                     53: #include "grfvar.h"
                     54: #include "grf_tcreg.h"
                     55: 
                     56: #include "../include/cpu.h"
                     57: 
                     58: /*
                     59:  * Initialize hardware.
                     60:  * Must fill in the grfinfo structure in g_softc.
                     61:  * Returns 0 if hardware not present, non-zero ow.
                     62:  */
                     63: tc_init(gp, addr)
                     64:        struct grf_softc *gp;
                     65:        caddr_t addr;
                     66: {
                     67:        register struct tcboxfb *tp = (struct tcboxfb *) addr;
                     68:        struct grfinfo *gi = &gp->g_display;
                     69:        volatile u_char *fbp;
                     70:        u_char save;
                     71:        int fboff;
                     72:        extern caddr_t sctopa(), iomap();
                     73: 
                     74:        if (ISIIOVA(addr))
                     75:                gi->gd_regaddr = (caddr_t) IIOP(addr);
                     76:        else
                     77:                gi->gd_regaddr = sctopa(vatosc(addr));
                     78:        gi->gd_regsize = 0x10000;
                     79:        gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb;
                     80:        gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb;
                     81:        gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
                     82:        fboff = (tp->fbomsb << 8) | tp->fbolsb;
                     83:        gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16);
                     84:        if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) {
                     85:                /*
                     86:                 * For DIO II space the fbaddr just computed is the offset
                     87:                 * from the select code base (regaddr) of the framebuffer.
                     88:                 * Hence it is also implicitly the size of the register set.
                     89:                 */
                     90:                gi->gd_regsize = (int) gi->gd_fbaddr;
                     91:                gi->gd_fbaddr += (int) gi->gd_regaddr;
                     92:                gp->g_regkva = addr;
                     93:                gp->g_fbkva = addr + gi->gd_regsize;
                     94:        } else {
                     95:                /*
                     96:                 * For DIO space we need to map the seperate framebuffer.
                     97:                 */
                     98:                gp->g_regkva = addr;
                     99:                gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize);
                    100:        }
                    101:        gi->gd_dwidth = (tp->dwmsb << 8) | tp->dwlsb;
                    102:        gi->gd_dheight = (tp->dhmsb << 8) | tp->dhlsb;
                    103:        gi->gd_planes = tp->num_planes;
                    104:        gi->gd_colors = 1 << gi->gd_planes;
                    105:        if (gi->gd_colors == 1) {
                    106:                fbp = (u_char *) gp->g_fbkva;
                    107:                tp->wen = ~0;
                    108:                tp->prr = 0x3;
                    109:                tp->fben = ~0;
                    110:                save = *fbp;
                    111:                *fbp = 0xFF;
                    112:                gi->gd_colors = *fbp + 1;
                    113:                *fbp = save;
                    114:        }
                    115:        return(1);
                    116: }
                    117: 
                    118: /*
                    119:  * Change the mode of the display.
                    120:  * Right now all we can do is grfon/grfoff.
                    121:  * Return a UNIX error number or 0 for success.
                    122:  * Function may not be needed anymore.
                    123:  */
                    124: /*ARGSUSED*/
                    125: tc_mode(gp, cmd)
                    126:        struct grf_softc *gp;
                    127: {
                    128:        int error = 0;
                    129: 
                    130:        switch (cmd) {
                    131:        case GM_GRFON:
                    132:        case GM_GRFOFF:
                    133:                break;
                    134:        default:
                    135:                error = EINVAL;
                    136:                break;
                    137:        }
                    138:        return(error);
                    139: }
                    140: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.