[BACK]Return to wscons_machdep.c CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / hp300

Annotation of sys/arch/hp300/hp300/wscons_machdep.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: wscons_machdep.c,v 1.8 2006/12/18 18:57:26 miod Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2005, Miodrag Vallat
        !             5:  *
        !             6:  * Redistribution and use in source and binary forms, with or without
        !             7:  * modification, are permitted provided that the following conditions
        !             8:  * are met:
        !             9:  * 1. Redistributions of source code must retain the above copyright
        !            10:  *    notice, this list of conditions and the following disclaimer.
        !            11:  * 2. Redistributions in binary form must reproduce the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer in the
        !            13:  *    documentation and/or other materials provided with the distribution.
        !            14:  *
        !            15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            18:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
        !            19:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            20:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            23:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        !            24:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            25:  * POSSIBILITY OF SUCH DAMAGE.
        !            26:  */
        !            27: /*
        !            28:  * Copyright (c) 2002 Michael Shalayeff
        !            29:  * All rights reserved.
        !            30:  *
        !            31:  * Redistribution and use in source and binary forms, with or without
        !            32:  * modification, are permitted provided that the following conditions
        !            33:  * are met:
        !            34:  * 1. Redistributions of source code must retain the above copyright
        !            35:  *    notice, this list of conditions and the following disclaimer.
        !            36:  * 2. Redistributions in binary form must reproduce the above copyright
        !            37:  *    notice, this list of conditions and the following disclaimer in the
        !            38:  *    documentation and/or other materials provided with the distribution.
        !            39:  * 3. The name of the author may not be used to endorse or promote products
        !            40:  *    derived from this software without specific prior written permission.
        !            41:  *
        !            42:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            43:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            44:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            45:  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
        !            46:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            47:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            48:  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            49:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            50:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
        !            51:  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
        !            52:  * THE POSSIBILITY OF SUCH DAMAGE.
        !            53:  */
        !            54:
        !            55: #include <sys/param.h>
        !            56: #include <sys/systm.h>
        !            57: #include <sys/kernel.h>
        !            58: #include <sys/conf.h>
        !            59: #include <sys/device.h>
        !            60:
        !            61: #include <machine/autoconf.h>
        !            62: #include <machine/cpu.h>
        !            63: #include <machine/hp300spu.h>
        !            64:
        !            65: #include <dev/cons.h>
        !            66:
        !            67: #include <dev/wscons/wsconsio.h>
        !            68: #include <dev/wscons/wsdisplayvar.h>
        !            69: #include <dev/rasops/rasops.h>
        !            70:
        !            71: #include "wsdisplay.h"
        !            72: #include "wskbd.h"
        !            73: #if NWSKBD > 0
        !            74: #include <dev/wscons/wskbdvar.h>
        !            75: #endif
        !            76:
        !            77: #include "dvbox.h"
        !            78: #include "gbox.h"
        !            79: #include "hyper.h"
        !            80: #include "rbox.h"
        !            81: #include "topcat.h"
        !            82: #include "tvrx.h"
        !            83: #if NDVBOX > 0 || NGBOX > 0 || NHYPER > 0 || NRBOX > 0 || NTOPCAT > 0 || NTVRX > 0
        !            84: #include <hp300/dev/dioreg.h>
        !            85: #include <hp300/dev/diovar.h>
        !            86: #include <hp300/dev/diofbreg.h>
        !            87: #include <hp300/dev/diofbvar.h>
        !            88: struct diofb diofb_cn;
        !            89: #endif
        !            90:
        !            91: #include "sti.h"
        !            92: #if NSTI > 0
        !            93: #include <machine/bus.h>
        !            94: #include <hp300/dev/sgcreg.h>
        !            95: #include <hp300/dev/sgcvar.h>
        !            96: #include <dev/ic/stireg.h>
        !            97: #include <dev/ic/stivar.h>
        !            98: extern int sti_console_scan(int);
        !            99: extern void sticninit(void);
        !           100: #endif
        !           101:
        !           102: extern caddr_t internalhpib;
        !           103:
        !           104: cons_decl(ws);
        !           105:
        !           106: void (*wsfbcninit)(void) = NULL;
        !           107:
        !           108: #if NDVBOX > 0 || NGBOX > 0 || NHYPER > 0 || NRBOX > 0 || NTOPCAT > 0 || NTVRX > 0
        !           109: int    dio_fbidentify(struct diofbreg *);
        !           110:
        !           111: /*
        !           112:  * Identify a DIO frame buffer and set up wsfbcninit accordingly.
        !           113:  */
        !           114: int
        !           115: dio_fbidentify(struct diofbreg *fbr)
        !           116: {
        !           117:        if (fbr->id == GRFHWID)
        !           118:                switch (fbr->fbid) {
        !           119: #if NDVBOX > 0
        !           120:                case GID_DAVINCI:
        !           121:                        wsfbcninit = dvboxcninit;
        !           122:                        return (1);
        !           123: #endif
        !           124: #if NGBOX > 0
        !           125:                case GID_GATORBOX:
        !           126:                        wsfbcninit = gboxcninit;
        !           127:                        return (1);
        !           128: #endif
        !           129: #if NHYPER > 0
        !           130:                case GID_HYPERION:
        !           131:                        wsfbcninit = hypercninit;
        !           132:                        return (1);
        !           133: #endif
        !           134: #if NRBOX > 0
        !           135:                case GID_RENAISSANCE:
        !           136:                        wsfbcninit = rboxcninit;
        !           137:                        return (1);
        !           138: #endif
        !           139: #if NTOPCAT > 0
        !           140:                case GID_TOPCAT:
        !           141:                case GID_LRCATSEYE:
        !           142:                case GID_HRCCATSEYE:
        !           143:                case GID_HRMCATSEYE:
        !           144:                        wsfbcninit = topcatcninit;
        !           145:                        return (1);
        !           146: #endif
        !           147: #if NTVRX > 0
        !           148:                case GID_TIGER:
        !           149:                        wsfbcninit = tvrxcninit;
        !           150:                        return (1);
        !           151: #endif
        !           152:                default:
        !           153:                        break;
        !           154:                }
        !           155:
        !           156:        return (0);
        !           157: }
        !           158: #endif
        !           159:
        !           160: /*
        !           161:  * This routine handles the dirty work of picking the best frame buffer
        !           162:  * suitable for the console.
        !           163:  * We try to behave as close as possible to the PROM's logic, by preferring
        !           164:  * devices for which we have drivers, in that order:
        !           165:  * - internal video.
        !           166:  * - lowest select code on DIO bus.
        !           167:  * - lowest slot on SGC bus.
        !           168:  */
        !           169: void
        !           170: wscnprobe(struct consdev *cp)
        !           171: {
        !           172:        int maj, tmpconscode;
        !           173:        vsize_t mapsize;
        !           174:        vaddr_t va;
        !           175: #if NDVBOX > 0 || NGBOX > 0 || NHYPER > 0 || NRBOX > 0 || NTOPCAT > 0 || NTVRX > 0
        !           176:        paddr_t pa;
        !           177:        u_int scode, sctop;
        !           178:        struct diofbreg *fbr;
        !           179: #endif
        !           180:
        !           181:        for (maj = 0; maj < nchrdev; maj++) {
        !           182:                if (cdevsw[maj].d_open == wsdisplayopen)
        !           183:                        break;
        !           184:        }
        !           185:
        !           186:        cp->cn_dev = makedev(maj, 0);
        !           187:        wsfbcninit = NULL;
        !           188:
        !           189: #if NDVBOX > 0 || NGBOX > 0 || NRBOX > 0 || NTOPCAT > 0
        !           190:        /*
        !           191:         * Look for an ``internal'' frame buffer.
        !           192:         */
        !           193:        va = IIOV(GRFIADDR);
        !           194:        fbr = (struct diofbreg *)va;
        !           195:        if (!badaddr((caddr_t)va)) {
        !           196:                if (dio_fbidentify(fbr)) {
        !           197:                        tmpconscode = CONSCODE_INTERNAL;
        !           198:                        mapsize = 0;
        !           199:                        goto found;
        !           200:                }
        !           201:        }
        !           202: #endif
        !           203:
        !           204: #if NDVBOX > 0 || NGBOX > 0 || NHYPER > 0 || NRBOX > 0 || NTOPCAT > 0 || NTVRX > 0
        !           205:        /*
        !           206:         * Scan the DIO bus.
        !           207:         */
        !           208:        sctop = DIO_SCMAX(machineid);
        !           209:        for (scode = 0; scode < sctop; scode++) {
        !           210:                /*
        !           211:                 * Skip over the select code hole and the internal
        !           212:                 * HP-IB controller.
        !           213:                 */
        !           214:                if (DIO_INHOLE(scode) || (scode == 7 && internalhpib))
        !           215:                        continue;
        !           216:
        !           217:                /* Map current PA. */
        !           218:                pa = (paddr_t)dio_scodetopa(scode);
        !           219:                va = (vaddr_t)iomap((caddr_t)pa, PAGE_SIZE);
        !           220:                if (va == NULL)
        !           221:                        continue;
        !           222:
        !           223:                /* Check to see if hardware exists. */
        !           224:                if (badaddr((caddr_t)va)) {
        !           225:                        iounmap((caddr_t)va, PAGE_SIZE);
        !           226:                        continue;
        !           227:                }
        !           228:
        !           229:                /* Check hardware. */
        !           230:                fbr = (struct diofbreg *)va;
        !           231:                if (dio_fbidentify(fbr)) {
        !           232:                        tmpconscode = scode;
        !           233:                        mapsize = DIO_SIZE(scode, va);
        !           234:                        iounmap((caddr_t)va, PAGE_SIZE);
        !           235:                        va = (vaddr_t)iomap((caddr_t)pa, mapsize);
        !           236:                        if (va == NULL)
        !           237:                                continue;
        !           238:                        goto found;
        !           239:                } else
        !           240:                        iounmap((caddr_t)va, PAGE_SIZE);
        !           241:        }
        !           242: #endif
        !           243:
        !           244: #if NSTI > 0
        !           245:        /*
        !           246:         * Scan the SGC bus.
        !           247:         */
        !           248:        for (scode = 0; scode < SGC_NSLOTS; scode++) {
        !           249:                int rv;
        !           250:
        !           251:                /* Map current PA. */
        !           252:                pa = (paddr_t)sgc_slottopa(scode);
        !           253:                va = (vaddr_t)iomap((caddr_t)pa, PAGE_SIZE);
        !           254:                if (va == NULL)
        !           255:                        continue;
        !           256:
        !           257:                /* Check to see if hardware exists. */
        !           258:                rv = badaddr((caddr_t)va);
        !           259:                iounmap((caddr_t)va, PAGE_SIZE);
        !           260:                if (rv != 0)
        !           261:                        continue;
        !           262:
        !           263:                /* Check hardware. */
        !           264:                if (sti_console_scan(scode) != 0) {
        !           265:                        wsfbcninit = sticninit;
        !           266:                        tmpconscode = SGC_SLOT_TO_CONSCODE(scode);
        !           267:                        mapsize = 0;
        !           268:                        va = 0;
        !           269:                        goto found;
        !           270:                }
        !           271:        }
        !           272: #endif
        !           273:
        !           274:        return;
        !           275:
        !           276: found:
        !           277:        cp->cn_pri = CN_INTERNAL;
        !           278: #ifdef CONSCODE
        !           279:        if (CONSCODE == tmpconscode)
        !           280:                cp->cn_pri = CN_FORCED;
        !           281: #endif
        !           282:
        !           283:        /*
        !           284:         * If our priority is higher than the currently remembered console,
        !           285:         * install ourselves, and unmap whichever device might be currently
        !           286:         * mapped.
        !           287:         */
        !           288:        if (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri) {
        !           289:                cn_tab = cp;
        !           290:                /* Free last mapping. */
        !           291:                if (convasize)
        !           292:                        iounmap(conaddr, convasize);
        !           293:                conscode = tmpconscode;
        !           294:                conaddr = (caddr_t)va;
        !           295:                convasize = mapsize;
        !           296:
        !           297:        }
        !           298: }
        !           299:
        !           300: void
        !           301: wscninit(struct consdev *cp)
        !           302: {
        !           303:        /*
        !           304:         * Note that this relies on the fact that DIO frame buffers will cause
        !           305:         * cn_tab to switch to wsdisplaycons, so their cninit function will
        !           306:         * never get invoked a second time during the second console pass.
        !           307:         */
        !           308:        if (wsfbcninit != NULL)
        !           309:                (*wsfbcninit)();
        !           310: }
        !           311:
        !           312: void
        !           313: wscnputc(dev_t dev, int i)
        !           314: {
        !           315: #if NWSDISPLAY > 0
        !           316:        wsdisplay_cnputc(dev, i);
        !           317: #endif
        !           318: }
        !           319:
        !           320: int
        !           321: wscngetc(dev_t dev)
        !           322: {
        !           323: #if NWSKBD > 0
        !           324:        return (wskbd_cngetc(dev));
        !           325: #else
        !           326:        return (0);
        !           327: #endif
        !           328: }
        !           329:
        !           330: void
        !           331: wscnpollc(dev_t dev, int on)
        !           332: {
        !           333: #if NWSKBD > 0
        !           334:        wskbd_cnpollc(dev, on);
        !           335: #endif
        !           336: }

CVSweb