Annotation of 43BSDReno/sys/hp300/autoconf.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1988 University of Utah.
        !             3:  * Copyright (c) 1982, 1986, 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 is only permitted until one year after the first shipment
        !            11:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
        !            12:  * binary forms are permitted provided that: (1) source distributions retain
        !            13:  * this entire copyright notice and comment, and (2) distributions including
        !            14:  * binaries display the following acknowledgement:  This product includes
        !            15:  * software developed by the University of California, Berkeley and its
        !            16:  * contributors'' in the documentation or other materials provided with the
        !            17:  * distribution and in all advertising materials mentioning features or use
        !            18:  * of this software.  Neither the name of the University nor the names of
        !            19:  * its contributors may be used to endorse or promote products derived from
        !            20:  * this software without specific prior written permission.
        !            21:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            22:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            23:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            24:  *
        !            25:  * from: Utah $Hdr: autoconf.c 1.25 89/10/07$
        !            26:  *
        !            27:  *     @(#)autoconf.c  7.2 (Berkeley) 5/25/90
        !            28:  */
        !            29: 
        !            30: /*
        !            31:  * Setup the system to run on the current machine.
        !            32:  *
        !            33:  * Configure() is called at boot time.  Available
        !            34:  * devices are determined (from possibilities mentioned in ioconf.c),
        !            35:  * and the drivers are initialized.
        !            36:  */
        !            37: 
        !            38: #include "param.h"
        !            39: #include "systm.h"
        !            40: #include "map.h"
        !            41: #include "buf.h"
        !            42: #include "dkstat.h"
        !            43: #include "vm.h"
        !            44: #include "conf.h"
        !            45: #include "dmap.h"
        !            46: #include "reboot.h"
        !            47: 
        !            48: #include "pte.h"
        !            49: #include "cpu.h"
        !            50: #include "isr.h"
        !            51: #include "../hpdev/device.h"
        !            52: #include "../hpdev/grfioctl.h"
        !            53: #include "../hpdev/grfvar.h"
        !            54: 
        !            55: /*
        !            56:  * The following several variables are related to
        !            57:  * the configuration process, and are used in initializing
        !            58:  * the machine.
        !            59:  */
        !            60: int    cold;               /* if 1, still working on cold-start */
        !            61: int    dkn;                /* number of iostat dk numbers assigned so far */
        !            62: int    cpuspeed = MHZ_8;   /* relative cpu speed */
        !            63: struct isr isrqueue[NISR];
        !            64: struct hp_hw sc_table[MAX_CTLR];
        !            65: 
        !            66: extern int internalhpib;
        !            67: 
        !            68: #ifdef DEBUG
        !            69: int    acdebug = 0;
        !            70: #endif
        !            71: 
        !            72: /*
        !            73:  * Determine mass storage and memory configuration for a machine.
        !            74:  */
        !            75: configure()
        !            76: {
        !            77:        register struct hp_hw *hw;
        !            78:        int found;
        !            79: 
        !            80:        /*
        !            81:         * XXX: these should be consolidated into some kind of table
        !            82:         */
        !            83:        hilinit();
        !            84:        isrinit();
        !            85:        dmainit();
        !            86: 
        !            87:        /*
        !            88:         * Look over each hardware device actually found and attempt
        !            89:         * to match it with an ioconf.c table entry.
        !            90:         */
        !            91:        for (hw = sc_table; hw->hw_type; hw++) {
        !            92:                if (hw->hw_type & CONTROLLER)
        !            93:                        found = find_controller(hw);
        !            94:                else
        !            95:                        found = find_device(hw);
        !            96: #ifdef DEBUG
        !            97:                if (!found) {
        !            98:                        int sc = addrtosc((u_int)hw->hw_addr);
        !            99: 
        !           100:                        printf("unconfigured %s ", hw->hw_name);
        !           101:                        if (sc < 256)
        !           102:                                printf("at sc%d\n", sc);
        !           103:                        else
        !           104:                                printf("csr at %x\n", sc);
        !           105:                }
        !           106: #endif
        !           107:        }
        !           108: 
        !           109: #include "cd.h"
        !           110: #if NCD > 0
        !           111:        /*
        !           112:         * Now deal with concatenated disks
        !           113:         */
        !           114:        find_cdevices();
        !           115: #endif
        !           116: 
        !           117: #if GENERIC
        !           118:        if ((boothowto & RB_ASKNAME) == 0)
        !           119:                setroot();
        !           120:        setconf();
        !           121: #else
        !           122:        setroot();
        !           123: #endif
        !           124:        swapconf();
        !           125:        cold = 0;
        !           126: }
        !           127: 
        !           128: #define dr_type(d, s)  \
        !           129:        (strcmp((d)->d_name, (s)) == 0)
        !           130: 
        !           131: #define same_hw_ctlr(hw, hc) \
        !           132:        ((hw)->hw_type == HPIB && dr_type((hc)->hp_driver, "hpib") || \
        !           133:         (hw)->hw_type == SCSI && dr_type((hc)->hp_driver, "scsi"))
        !           134: 
        !           135: find_controller(hw)
        !           136:        register struct hp_hw *hw;
        !           137: {
        !           138:        register struct hp_ctlr *hc;
        !           139:        struct hp_ctlr *match_c;
        !           140:        caddr_t oaddr;
        !           141:        int sc;
        !           142: 
        !           143: #ifdef DEBUG
        !           144:        if (acdebug)
        !           145:                printf("find_controller: hw: %s at sc%d (%x), type %x...",
        !           146:                       hw->hw_name, hw->hw_sc, hw->hw_addr, hw->hw_type);
        !           147: #endif
        !           148:        sc = hw->hw_sc;
        !           149:        match_c = NULL;
        !           150:        for (hc = hp_cinit; hc->hp_driver; hc++) {
        !           151:                if (hc->hp_alive)
        !           152:                        continue;
        !           153:                /*
        !           154:                 * Make sure we are looking at the right
        !           155:                 * controller type.
        !           156:                 */
        !           157:                if (!same_hw_ctlr(hw, hc))
        !           158:                        continue;
        !           159:                /*
        !           160:                 * Exact match; all done
        !           161:                 */
        !           162:                if ((int)hc->hp_addr == sc) {
        !           163:                        match_c = hc;
        !           164:                        break;
        !           165:                }
        !           166:                /*
        !           167:                 * Wildcard; possible match so remember first instance
        !           168:                 * but continue looking for exact match.
        !           169:                 */
        !           170:                if ((int)hc->hp_addr == WILD_CARD_CTLR && match_c == NULL)
        !           171:                        match_c = hc;
        !           172:        }
        !           173: #ifdef DEBUG
        !           174:        if (acdebug) {
        !           175:                if (match_c)
        !           176:                        printf("found %s%d\n",
        !           177:                               match_c->hp_driver->d_name,
        !           178:                               match_c->hp_unit);
        !           179:                else
        !           180:                        printf("not found\n");
        !           181:        }
        !           182: #endif
        !           183:        /*
        !           184:         * Didn't find an ioconf entry for this piece of hardware,
        !           185:         * just ignore it.
        !           186:         */
        !           187:        if (match_c == NULL)
        !           188:                return(0);
        !           189:        /*
        !           190:         * Found a match, attempt to initialize and configure all attached
        !           191:         * slaves.  Note, we can still fail if HW won't initialize.
        !           192:         */
        !           193:        hc = match_c;
        !           194:        oaddr = hc->hp_addr;
        !           195:        hc->hp_addr = hw->hw_addr;
        !           196:        if ((*hc->hp_driver->d_init)(hc)) {
        !           197:                hc->hp_alive = 1;
        !           198:                printf("%s%d", hc->hp_driver->d_name, hc->hp_unit);
        !           199:                sc = addrtosc((u_int)hc->hp_addr);
        !           200:                if (sc < 256)
        !           201:                        printf(" at sc%d,", sc);
        !           202:                else
        !           203:                        printf(" csr 0x%x,", sc);
        !           204:                printf(" ipl %d", hc->hp_ipl);
        !           205:                if (hc->hp_flags)
        !           206:                        printf(" flags 0x%x", hc->hp_flags);
        !           207:                printf("\n");
        !           208:                find_slaves(hc);
        !           209:        } else
        !           210:                hc->hp_addr = oaddr;
        !           211:        return(1);
        !           212: }
        !           213: 
        !           214: find_device(hw)
        !           215:        register struct hp_hw *hw;
        !           216: {
        !           217:        register struct hp_device *hd;
        !           218:        struct hp_device *match_d;
        !           219:        caddr_t oaddr;
        !           220:        int sc;
        !           221: 
        !           222: #ifdef DEBUG
        !           223:        if (acdebug)
        !           224:                printf("find_device: hw: %s at sc%d (%x), type %x...",
        !           225:                       hw->hw_name, hw->hw_sc, hw->hw_addr, hw->hw_type);
        !           226: #endif
        !           227:        match_d = NULL;
        !           228:        for (hd = hp_dinit; hd->hp_driver; hd++) {
        !           229:                if (hd->hp_alive)
        !           230:                        continue;
        !           231:                /* Must not be a slave */
        !           232:                if (hd->hp_cdriver)
        !           233:                        continue;
        !           234:                /*
        !           235:                 * XXX: A graphics device that was found as part of the
        !           236:                 * console init will have the hp_addr field already set
        !           237:                 * (i.e. no longer the select code).  Gotta perform a
        !           238:                 * slightly different check for an exact match.
        !           239:                 */
        !           240:                if (hw->hw_type == BITMAP && hd->hp_addr >= (caddr_t)IOBASE) {
        !           241:                        /* must be an exact match */
        !           242:                        if (hd->hp_addr == hw->hw_addr) {
        !           243:                                match_d = hd;
        !           244:                                break;
        !           245:                        }
        !           246:                        continue;
        !           247:                }
        !           248:                sc = (int) hd->hp_addr;
        !           249:                /*
        !           250:                 * Exact match; all done.
        !           251:                 */
        !           252:                if (sc > 0 && sc == hw->hw_sc) {
        !           253:                        match_d = hd;
        !           254:                        break;
        !           255:                }
        !           256:                /*
        !           257:                 * Wildcard; possible match so remember first instance
        !           258:                 * but continue looking for exact match.
        !           259:                 */
        !           260:                if (sc == 0 && same_hw_device(hw, hd) && match_d == NULL)
        !           261:                        match_d = hd;
        !           262:        }
        !           263: #ifdef DEBUG
        !           264:        if (acdebug) {
        !           265:                if (match_d)
        !           266:                        printf("found %s%d\n",
        !           267:                               match_d->hp_driver->d_name,
        !           268:                               match_d->hp_unit);
        !           269:                else
        !           270:                        printf("not found\n");
        !           271:        }
        !           272: #endif
        !           273:        /*
        !           274:         * Didn't find an ioconf entry for this piece
        !           275:         * of hardware, just ignore it.
        !           276:         */
        !           277:        if (match_d == NULL)
        !           278:                return(0);
        !           279:        /*
        !           280:         * Found a match, attempt to initialize.
        !           281:         * Note, we can still fail if HW won't initialize.
        !           282:         */
        !           283:        hd = match_d;
        !           284:        oaddr = hd->hp_addr;
        !           285:        hd->hp_addr = hw->hw_addr;
        !           286:        if ((*hd->hp_driver->d_init)(hd)) {
        !           287:                hd->hp_alive = 1;
        !           288:                printf("%s%d", hd->hp_driver->d_name, hd->hp_unit);
        !           289:                sc = addrtosc((u_int)hd->hp_addr);
        !           290:                if (sc < 32)
        !           291:                        printf(" at sc%d", sc);
        !           292:                else
        !           293:                        printf(" csr 0x%x", sc);
        !           294:                if (hd->hp_ipl)
        !           295:                        printf(", ipl %d", hd->hp_ipl);
        !           296:                if (hd->hp_flags)
        !           297:                        printf(", flags 0x%x", hd->hp_flags);
        !           298:                printf("\n");
        !           299:        } else
        !           300:                hd->hp_addr = oaddr;
        !           301:        return(1);
        !           302: }
        !           303: 
        !           304: find_slaves(hc)
        !           305:        struct hp_ctlr *hc;
        !           306: {
        !           307:        /*
        !           308:         * The SCSI bus is structured very much like the HP-IB 
        !           309:         * except that the host adaptor is slave 7 so we only want
        !           310:         * to look at the first 6 slaves.
        !           311:         */
        !           312:        if (dr_type(hc->hp_driver, "hpib"))
        !           313:                find_busslaves(hc, MAXSLAVES);
        !           314:        else if (dr_type(hc->hp_driver, "scsi"))
        !           315:                find_busslaves(hc, MAXSLAVES-1);
        !           316: }
        !           317: 
        !           318: /*
        !           319:  * Search each BUS controller found for slaves attached to it.
        !           320:  * The bad news is that we don't know how to uniquely identify all slaves
        !           321:  * (e.g. PPI devices on HP-IB).  The good news is that we can at least
        !           322:  * differentiate those from slaves we can identify.  At worst (a totally
        !           323:  * wildcarded entry) this will cause us to locate such a slave at the first
        !           324:  * unused position instead of where it really is.  To save grief, non-
        !           325:  * identifing devices should always be fully qualified.
        !           326:  */
        !           327: find_busslaves(hc, maxslaves)
        !           328:        register struct hp_ctlr *hc;
        !           329:        int maxslaves;
        !           330: {
        !           331:        register int s;
        !           332:        register struct hp_device *hd;
        !           333:        struct hp_device *match_s;
        !           334:        int new_s, new_c, old_s, old_c;
        !           335:        int rescan;
        !           336:        
        !           337: #ifdef DEBUG
        !           338:        if (acdebug)
        !           339:                printf("find_busslaves: for %s%d\n",
        !           340:                       hc->hp_driver->d_name, hc->hp_unit);
        !           341: #endif
        !           342:        for (s = 0; s < maxslaves; s++) {
        !           343:                rescan = 1;
        !           344:                match_s = NULL;
        !           345:                for (hd = hp_dinit; hd->hp_driver; hd++) {
        !           346:                        /*
        !           347:                         * Rule out the easy ones:
        !           348:                         * 1. slave already assigned or not a slave
        !           349:                         * 2. not of the proper type
        !           350:                         * 3. controller specified but not this one
        !           351:                         * 4. slave specified but not this one
        !           352:                         */
        !           353:                        if (hd->hp_alive || hd->hp_cdriver == NULL)
        !           354:                                continue;
        !           355:                        if (!dr_type(hc->hp_driver, hd->hp_cdriver->d_name))
        !           356:                                continue;
        !           357:                        if (hd->hp_ctlr >= 0 && hd->hp_ctlr != hc->hp_unit)
        !           358:                                continue;
        !           359:                        if (hd->hp_slave >= 0 && hd->hp_slave != s)
        !           360:                                continue;
        !           361:                        /*
        !           362:                         * Case 0: first possible match.
        !           363:                         * Remember it and keep looking for better.
        !           364:                         */
        !           365:                        if (match_s == NULL) {
        !           366:                                match_s = hd;
        !           367:                                new_c = hc->hp_unit;
        !           368:                                new_s = s;
        !           369:                                continue;
        !           370:                        }
        !           371:                        /*
        !           372:                         * Case 1: exact match.
        !           373:                         * All done.  Note that we do not attempt any other
        !           374:                         * matches if this one fails.  This allows us to
        !           375:                         * "reserve" locations for dynamic addition of
        !           376:                         * disk/tape drives by fully qualifing the location.
        !           377:                         */
        !           378:                        if (hd->hp_slave == s && hd->hp_ctlr == hc->hp_unit) {
        !           379:                                match_s = hd;
        !           380:                                rescan = 0;
        !           381:                                break;
        !           382:                        }
        !           383:                        /*
        !           384:                         * Case 2: right controller, wildcarded slave.
        !           385:                         * Remember first and keep looking for an exact match.
        !           386:                         */
        !           387:                        if (hd->hp_ctlr == hc->hp_unit &&
        !           388:                            match_s->hp_ctlr < 0) {
        !           389:                                match_s = hd;
        !           390:                                new_s = s;
        !           391:                                continue;
        !           392:                        }
        !           393:                        /*
        !           394:                         * Case 3: right slave, wildcarded controller.
        !           395:                         * Remember and keep looking for a better match.
        !           396:                         */
        !           397:                        if (hd->hp_slave == s &&
        !           398:                            match_s->hp_ctlr < 0 && match_s->hp_slave < 0) {
        !           399:                                match_s = hd;
        !           400:                                new_c = hc->hp_unit;
        !           401:                                continue;
        !           402:                        }
        !           403:                        /*
        !           404:                         * OW: we had a totally wildcarded spec.
        !           405:                         * If we got this far, we have found a possible
        !           406:                         * match already (match_s != NULL) so there is no
        !           407:                         * reason to remember this one.
        !           408:                         */
        !           409:                        continue;
        !           410:                }
        !           411:                /*
        !           412:                 * Found a match.  We need to set hp_ctlr/hp_slave properly
        !           413:                 * for the init routines but we also need to remember all
        !           414:                 * the old values in case this doesn't pan out.
        !           415:                 */
        !           416:                if (match_s) {
        !           417:                        hd = match_s;
        !           418:                        old_c = hd->hp_ctlr;
        !           419:                        old_s = hd->hp_slave;
        !           420:                        if (hd->hp_ctlr < 0)
        !           421:                                hd->hp_ctlr = new_c;
        !           422:                        if (hd->hp_slave < 0)
        !           423:                                hd->hp_slave = new_s;
        !           424: #ifdef DEBUG
        !           425:                        if (acdebug)
        !           426:                                printf("looking for %s%d at slave %d...",
        !           427:                                       hd->hp_driver->d_name,
        !           428:                                       hd->hp_unit, hd->hp_slave);
        !           429: #endif
        !           430: 
        !           431:                        if ((*hd->hp_driver->d_init)(hd)) {
        !           432: #ifdef DEBUG
        !           433:                                if (acdebug)
        !           434:                                        printf("found\n");
        !           435: #endif
        !           436:                                printf("%s%d at %s%d, slave %d",
        !           437:                                       hd->hp_driver->d_name, hd->hp_unit,
        !           438:                                       hc->hp_driver->d_name, hd->hp_ctlr,
        !           439:                                       hd->hp_slave);
        !           440:                                if (hd->hp_flags)
        !           441:                                        printf(" flags 0x%x", hd->hp_flags);
        !           442:                                printf("\n");
        !           443:                                hd->hp_alive = 1;
        !           444:                                if (hd->hp_dk && dkn < DK_NDRIVE)
        !           445:                                        hd->hp_dk = dkn++;
        !           446:                                else
        !           447:                                        hd->hp_dk = -1;
        !           448:                                rescan = 1;
        !           449:                        } else {
        !           450: #ifdef DEBUG
        !           451:                                if (acdebug)
        !           452:                                        printf("not found\n");
        !           453: #endif
        !           454:                                hd->hp_ctlr = old_c;
        !           455:                                hd->hp_slave = old_s;
        !           456:                        }
        !           457:                        /*
        !           458:                         * XXX: This should be handled better.
        !           459:                         * Re-scan a slave.  There are two reasons to do this.
        !           460:                         * 1. It is possible to have both a tape and disk
        !           461:                         *    (e.g. 7946) or two disks (e.g. 9122) at the
        !           462:                         *    same slave address.  Here we need to rescan
        !           463:                         *    looking only at entries with a different
        !           464:                         *    physical unit number (hp_flags).
        !           465:                         * 2. It is possible that an init failed because the
        !           466:                         *    slave was there but of the wrong type.  In this
        !           467:                         *    case it may still be possible to match the slave
        !           468:                         *    to another ioconf entry of a different type.
        !           469:                         *    Here we need to rescan looking only at entries
        !           470:                         *    of different types.
        !           471:                         * In both cases we avoid looking at undesirable
        !           472:                         * ioconf entries of the same type by setting their
        !           473:                         * alive fields to -1.
        !           474:                         */
        !           475:                        if (rescan) {
        !           476:                                for (hd = hp_dinit; hd->hp_driver; hd++) {
        !           477:                                        if (hd->hp_alive)
        !           478:                                                continue;
        !           479:                                        if (match_s->hp_alive == 1) {   /* 1 */
        !           480:                                                if (hd->hp_flags == match_s->hp_flags)
        !           481:                                                        hd->hp_alive = -1;
        !           482:                                        } else {                        /* 2 */
        !           483:                                                if (hd->hp_driver == match_s->hp_driver)
        !           484:                                                        hd->hp_alive = -1;
        !           485:                                        }
        !           486:                                }
        !           487:                                s--;
        !           488:                                continue;
        !           489:                        }
        !           490:                }
        !           491:                /*
        !           492:                 * Reset bogon alive fields prior to attempting next slave
        !           493:                 */
        !           494:                for (hd = hp_dinit; hd->hp_driver; hd++)
        !           495:                        if (hd->hp_alive == -1)
        !           496:                                hd->hp_alive = 0;
        !           497:        }
        !           498: }
        !           499: 
        !           500: sctoaddr(addr)
        !           501:        register int addr;
        !           502: {
        !           503:        if (addr == 7 && internalhpib)
        !           504:                addr = internalhpib;
        !           505:        else if (addr < 32)
        !           506:                addr = IOV(EXTIOBASE + (addr * IOCARDSIZE));
        !           507:        else
        !           508:                addr = IOV(addr);
        !           509:        return(addr);
        !           510: }
        !           511: 
        !           512: addrtosc(addr)
        !           513:        register u_int addr;
        !           514: {
        !           515: #if defined(HP360) || defined(HP370)
        !           516:        extern char grfregs[];
        !           517: 
        !           518:        if (addr == (u_int)grfregs)
        !           519:                addr = 132;
        !           520:        else
        !           521: #endif
        !           522:        if (addr == internalhpib)
        !           523:                addr = 7;
        !           524:        else if (addr >= IOV(IOBASE)) {
        !           525:                addr = UNIOV(addr);
        !           526:                if (addr >= EXTIOBASE)
        !           527:                        addr = (addr - EXTIOBASE) / IOCARDSIZE;
        !           528:        }
        !           529:        return((int)addr);
        !           530: }
        !           531: 
        !           532: same_hw_device(hw, hd)
        !           533:        struct hp_hw *hw;
        !           534:        struct hp_device *hd;
        !           535: {
        !           536:        int found = 0;
        !           537: 
        !           538:        switch (hw->hw_type) {
        !           539:        case HPIB:
        !           540:        case RD:
        !           541:        case PPI:
        !           542:        case CT:
        !           543:                found = dr_type(hd->hp_driver, "hpib");
        !           544:                break;
        !           545:        case BITMAP:
        !           546:                found = dr_type(hd->hp_driver, "grf");
        !           547:                break;
        !           548:        case NET:
        !           549:                found = dr_type(hd->hp_driver, "le");
        !           550:                break;
        !           551:        case COMMDCA:
        !           552:                found = dr_type(hd->hp_driver, "dca");
        !           553:                break;
        !           554:        case COMMDCL:
        !           555:                found = dr_type(hd->hp_driver, "dcl");
        !           556:                break;
        !           557:        case COMMDCM:
        !           558:                found = dr_type(hd->hp_driver, "dcm");
        !           559:                break;
        !           560:        case SCSI:
        !           561:                found = dr_type(hd->hp_driver, "scsi");
        !           562:                break;
        !           563:        case FPA:    /* Unsupported so far */
        !           564:        case VME:
        !           565:        case FLINK:
        !           566:        case MISC:
        !           567:                break;
        !           568:        }
        !           569:        return(found);
        !           570: }
        !           571: 
        !           572: find_devs()
        !           573: {
        !           574:        short sc;
        !           575:        u_char *id_reg;
        !           576:        register int addr;
        !           577:        register struct hp_hw *hw;
        !           578: 
        !           579:        hw = sc_table;
        !           580:        for (sc = -1; sc < 32; sc++) {
        !           581: #if defined(HP360) || defined(HP370)
        !           582:                /*
        !           583:                 * XXX: special check for bit-mapped display
        !           584:                 * at SC132 in DIO II space on the 340.
        !           585:                 */
        !           586:                if (sc == -1 && machineid == HP_340) {
        !           587:                        extern struct pte Grfmap[];
        !           588:                        extern char grfregs[];
        !           589: 
        !           590:                        physaccess(Grfmap, (caddr_t)DIOIIBASE,
        !           591:                                   DIOIICSIZE, PG_RW|PG_CI);
        !           592:                        addr = (int) grfregs;
        !           593:                        /*
        !           594:                         * Nothing there or not a display,
        !           595:                         * try the usual internal display address.
        !           596:                         */
        !           597:                        if (badaddr((caddr_t)addr) ||
        !           598:                            (((u_char *)addr)[1] & 0xff) != 57)
        !           599:                                addr = IOV(GRFIADDR);
        !           600:                } else
        !           601: #endif
        !           602:                /*
        !           603:                 * Probe all select codes + internal display addr
        !           604:                 */
        !           605:                if (sc == -1)
        !           606:                        addr = IOV(GRFIADDR);
        !           607:                else
        !           608:                        addr = sctoaddr(sc);
        !           609:                if (badaddr((caddr_t)addr))
        !           610:                        continue;
        !           611: 
        !           612:                id_reg = (u_char *) addr;
        !           613:                hw->hw_id = id_reg[1] & 0xff;
        !           614:                hw->hw_sc = sc;
        !           615:                hw->hw_addr = (char *) addr;
        !           616:                /*
        !           617:                 * Internal HP-IB on some machines (345/375) doesn't return
        !           618:                 * consistant id info so we use the info gleaned from the
        !           619:                 * boot ROMs SYSFLAG.
        !           620:                 */
        !           621:                if (sc == 7 && internalhpib) {
        !           622:                        hw->hw_name = "98624A";
        !           623:                        hw->hw_type = HPIB;
        !           624:                        hw++;
        !           625:                        continue;
        !           626:                }
        !           627:                /*
        !           628:                 * XXX: the following could be in a big static table
        !           629:                 */
        !           630:                switch (hw->hw_id) {
        !           631:                /* Null device? */
        !           632:                case 0:
        !           633:                        break;
        !           634:                case 2:
        !           635:                case 128+2:
        !           636:                        hw->hw_name = "98626A";
        !           637:                        hw->hw_type = COMMDCA;
        !           638:                        break;
        !           639:                case 3:
        !           640:                        hw->hw_name = "98622A";
        !           641:                        hw->hw_type = MISC;
        !           642:                        break;
        !           643:                case 4:
        !           644:                        hw->hw_name = "98623A";
        !           645:                        hw->hw_type = MISC;
        !           646:                        break;
        !           647:                case 5:
        !           648:                case 128+5:
        !           649:                        hw->hw_name = "98642A";
        !           650:                        hw->hw_type = COMMDCM;
        !           651:                        break;
        !           652:                case 6:
        !           653:                        hw->hw_name = "Parallel Port";
        !           654:                        hw->hw_type = PPORT;
        !           655:                        break;
        !           656:                case 7:
        !           657:                case 39:
        !           658:                case 71:
        !           659:                case 103:
        !           660:                        hw->hw_name = "98265A";
        !           661:                        hw->hw_type = SCSI;
        !           662:                        break;
        !           663:                case 8:
        !           664:                        hw->hw_name = "98625B";
        !           665:                        hw->hw_type = HPIB;
        !           666:                        break;
        !           667:                case 9:
        !           668:                        hw->hw_name = "98287A";
        !           669:                        hw->hw_type = KEYBOARD;
        !           670:                        break;
        !           671:                case 10:
        !           672:                        hw->hw_name = "98635A";
        !           673:                        hw->hw_type = FPA;
        !           674:                        break;
        !           675:                case 11:
        !           676:                        hw->hw_name = "Timer";
        !           677:                        hw->hw_type = MISC;
        !           678:                        break;
        !           679:                case 18:
        !           680:                        hw->hw_name = "98640A";
        !           681:                        hw->hw_type = MISC;
        !           682:                        break;
        !           683:                case 21:
        !           684:                        hw->hw_name = "98643A";
        !           685:                        hw->hw_type = NET;
        !           686:                        break;
        !           687:                case 22:
        !           688:                        hw->hw_name = "98659A";
        !           689:                        hw->hw_type = MISC;
        !           690:                        break;
        !           691:                case 25:
        !           692:                        hw->hw_name = "237";
        !           693:                        hw->hw_type = BITMAP;
        !           694:                        break;
        !           695:                case 26:
        !           696:                        hw->hw_name = "Quad";
        !           697:                        hw->hw_type = MISC;
        !           698:                        break;
        !           699:                case 27:
        !           700:                        hw->hw_name = "98253A";
        !           701:                        hw->hw_type = MISC;
        !           702:                        break;
        !           703:                case 28:
        !           704:                        hw->hw_name = "98627A";
        !           705:                        hw->hw_type = BITMAP;
        !           706:                        break;
        !           707:                case 29:
        !           708:                        hw->hw_name = "98633A";
        !           709:                        hw->hw_type = BITMAP;
        !           710:                        break;
        !           711:                case 30:
        !           712:                        hw->hw_name = "98259A";
        !           713:                        hw->hw_type = MISC;
        !           714:                        break;
        !           715:                case 31:
        !           716:                        hw->hw_name = "8741";
        !           717:                        hw->hw_type = MISC;
        !           718:                        break;
        !           719:                case 49:
        !           720:                        hw->hw_name = "98577A";
        !           721:                        hw->hw_type = VME;
        !           722:                        sc++;
        !           723:                        break;
        !           724:                case 52:
        !           725:                case 180:
        !           726:                        hw->hw_name = "98628A";
        !           727:                        hw->hw_type = COMMDCL;
        !           728:                        break;
        !           729:                case 57:
        !           730:                        hw->hw_type = BITMAP;
        !           731:                        hw->hw_id2 = id_reg[0x15];
        !           732:                        switch (hw->hw_id2) {
        !           733:                        case 1:
        !           734:                                hw->hw_name = "98700 ";
        !           735:                                break;
        !           736:                        case 2:
        !           737:                                hw->hw_name = "TOPCAT";
        !           738:                                break;
        !           739:                        case 4:
        !           740:                                hw->hw_name = "98720 ";
        !           741:                                sc++;
        !           742:                                break;
        !           743:                        case 5:
        !           744:                        case 6:
        !           745:                        case 7:
        !           746:                        case 9:
        !           747:                                hw->hw_name = "CATSEYE";
        !           748:                                break;
        !           749:                        case 8:
        !           750:                                hw->hw_name = "98730 ";
        !           751:                                sc++;
        !           752:                                break;
        !           753:                        default:
        !           754:                                hw->hw_name = "987xx ";
        !           755:                                break;
        !           756:                        }
        !           757:                        break;
        !           758:                case 66:
        !           759:                case 128+66:
        !           760:                        hw->hw_name = "98644A";
        !           761:                        hw->hw_type = COMMDCA;
        !           762:                        break;
        !           763:                case 128:
        !           764:                        hw->hw_name = "98624A";
        !           765:                        hw->hw_type = HPIB;
        !           766:                        break;
        !           767:                default:
        !           768:                        hw->hw_name = "DEFAULT";
        !           769:                        hw->hw_type = MISC;
        !           770:                        break;
        !           771:                }
        !           772:                hw++;
        !           773:        }
        !           774: }
        !           775: 
        !           776: #if NCD > 0
        !           777: #include "../hpdev/cdvar.h"
        !           778: 
        !           779: find_cdevices()
        !           780: {
        !           781:        register struct cddevice *cd;
        !           782: 
        !           783:        for (cd = cddevice; cd->cd_unit >= 0; cd++) {
        !           784:                /*
        !           785:                 * XXX
        !           786:                 * Assign disk index first so that init routine
        !           787:                 * can use it (saves having the driver drag around
        !           788:                 * the cddevice pointer just to set up the dk_*
        !           789:                 * info in the open routine).
        !           790:                 */
        !           791:                if (dkn < DK_NDRIVE)
        !           792:                        cd->cd_dk = dkn++;
        !           793:                else
        !           794:                        cd->cd_dk = -1;
        !           795:                if (cdinit(cd))
        !           796:                        printf("cd%d configured\n", cd->cd_unit);
        !           797:                else if (cd->cd_dk >= 0) {
        !           798:                        cd->cd_dk = -1;
        !           799:                        dkn--;
        !           800:                }
        !           801:        }
        !           802: }
        !           803: #endif
        !           804: 
        !           805: isrinit()
        !           806: {
        !           807:        register int i;
        !           808: 
        !           809:        for (i = 0; i < NISR; i++)
        !           810:                isrqueue[i].isr_forw = isrqueue[i].isr_back = &isrqueue[i];
        !           811: }
        !           812: 
        !           813: void
        !           814: isrlink(isr)
        !           815:        register struct isr *isr;
        !           816: {
        !           817:        int i = ISRIPL(isr->isr_ipl);
        !           818: 
        !           819:        if (i < 0 || i >= NISR) {
        !           820:                printf("bad IPL %d\n", i);
        !           821:                panic("configure");
        !           822:        }
        !           823:        insque(isr, isrqueue[i].isr_back);
        !           824: }
        !           825: 
        !           826: /*
        !           827:  * Configure swap space and related parameters.
        !           828:  */
        !           829: swapconf()
        !           830: {
        !           831:        register struct swdevt *swp;
        !           832:        register int nblks;
        !           833: 
        !           834:        for (swp = swdevt; swp->sw_dev; swp++)
        !           835:                if (bdevsw[major(swp->sw_dev)].d_psize) {
        !           836:                        nblks =
        !           837:                          (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
        !           838:                        if (nblks != -1 &&
        !           839:                            (swp->sw_nblks == 0 || swp->sw_nblks > nblks))
        !           840:                                swp->sw_nblks = nblks;
        !           841:                }
        !           842:        dumpconf();
        !           843: }
        !           844: 
        !           845: #define        DOSWAP                  /* Change swdevt, argdev, and dumpdev too */
        !           846: u_long bootdev;                /* should be dev_t, but not until 32 bits */
        !           847: 
        !           848: static char devname[][2] = {
        !           849:        0,0,            /* 0 = ct */
        !           850:        0,0,            /* 1 = xx */
        !           851:        'r','d',        /* 2 = rd */
        !           852:        0,0,            /* 3 = sw */
        !           853:        's','d',        /* 4 = rd */
        !           854: };
        !           855: 
        !           856: #define        PARTITIONMASK   0x7
        !           857: #define        PARTITIONSHIFT  3
        !           858: 
        !           859: /*
        !           860:  * Attempt to find the device from which we were booted.
        !           861:  * If we can do so, and not instructed not to do so,
        !           862:  * change rootdev to correspond to the load device.
        !           863:  */
        !           864: setroot()
        !           865: {
        !           866:        register struct hp_ctlr *hc;
        !           867:        register struct hp_device *hd;
        !           868:        int  majdev, mindev, unit, part, adaptor;
        !           869:        dev_t temp, orootdev;
        !           870:        struct swdevt *swp;
        !           871: 
        !           872:        if (boothowto & RB_DFLTROOT ||
        !           873:            (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC)
        !           874:                return;
        !           875:        majdev = (bootdev >> B_TYPESHIFT) & B_TYPEMASK;
        !           876:        if (majdev > sizeof(devname) / sizeof(devname[0]))
        !           877:                return;
        !           878:        adaptor = (bootdev >> B_ADAPTORSHIFT) & B_ADAPTORMASK;
        !           879:        part = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK;
        !           880:        unit = (bootdev >> B_UNITSHIFT) & B_UNITMASK;
        !           881:        /*
        !           882:         * First, find the controller type which support this device.
        !           883:         */
        !           884:        for (hd = hp_dinit; hd->hp_driver; hd++)
        !           885:                if (hd->hp_driver->d_name[0] == devname[majdev][0] &&
        !           886:                    hd->hp_driver->d_name[1] == devname[majdev][1])
        !           887:                        break;
        !           888:        if (hd->hp_driver == 0)
        !           889:                return;
        !           890:        /*
        !           891:         * Next, find the controller of that type corresponding to
        !           892:         * the adaptor number.
        !           893:         */
        !           894:        for (hc = hp_cinit; hc->hp_driver; hc++)
        !           895:                if (hc->hp_alive && hc->hp_unit == adaptor &&
        !           896:                    hc->hp_driver == hd->hp_cdriver)
        !           897:                        break;
        !           898:        if (hc->hp_driver == 0)
        !           899:                return;
        !           900:        /*
        !           901:         * Finally, find the device in question attached to that controller.
        !           902:         */
        !           903:        for (hd = hp_dinit; hd->hp_driver; hd++)
        !           904:                if (hd->hp_alive && hd->hp_slave == unit &&
        !           905:                    hd->hp_cdriver == hc->hp_driver &&
        !           906:                    hd->hp_ctlr == hc->hp_unit)
        !           907:                        break;
        !           908:        if (hd->hp_driver == 0)
        !           909:                return;
        !           910:        mindev = hd->hp_unit;
        !           911:        /*
        !           912:         * Form a new rootdev
        !           913:         */
        !           914:        mindev = (mindev << PARTITIONSHIFT) + part;
        !           915:        orootdev = rootdev;
        !           916:        rootdev = makedev(majdev, mindev);
        !           917:        /*
        !           918:         * If the original rootdev is the same as the one
        !           919:         * just calculated, don't need to adjust the swap configuration.
        !           920:         */
        !           921:        if (rootdev == orootdev)
        !           922:                return;
        !           923: 
        !           924:        printf("Changing root device to %c%c%d%c\n",
        !           925:                devname[majdev][0], devname[majdev][1],
        !           926:                mindev >> PARTITIONSHIFT, part + 'a');
        !           927: 
        !           928: #ifdef DOSWAP
        !           929:        mindev &= ~PARTITIONMASK;
        !           930:        for (swp = swdevt; swp->sw_dev; swp++) {
        !           931:                if (majdev == major(swp->sw_dev) &&
        !           932:                    mindev == (minor(swp->sw_dev) & ~PARTITIONMASK)) {
        !           933:                        temp = swdevt[0].sw_dev;
        !           934:                        swdevt[0].sw_dev = swp->sw_dev;
        !           935:                        swp->sw_dev = temp;
        !           936:                        break;
        !           937:                }
        !           938:        }
        !           939:        if (swp->sw_dev == 0)
        !           940:                return;
        !           941: 
        !           942:        /*
        !           943:         * If argdev and dumpdev were the same as the old primary swap
        !           944:         * device, move them to the new primary swap device.
        !           945:         */
        !           946:        if (temp == dumpdev)
        !           947:                dumpdev = swdevt[0].sw_dev;
        !           948:        if (temp == argdev)
        !           949:                argdev = swdevt[0].sw_dev;
        !           950: #endif
        !           951: }
        !           952: 
        !           953: strcmp(s1, s2)
        !           954:        register char *s1, *s2;
        !           955: {
        !           956:        while (*s1 == *s2++)
        !           957:                if (*s1++=='\0')
        !           958:                        return (0);
        !           959:        return (*s1 - *--s2);
        !           960: }

unix.superglobalmegacorp.com

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