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

Annotation of sys/arch/alpha/alpha/autoconf.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: autoconf.c,v 1.31 2007/06/01 19:25:09 deraadt Exp $   */
        !             2: /*     $NetBSD: autoconf.c,v 1.16 1996/11/13 21:13:04 cgd Exp $        */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1992, 1993
        !             6:  *     The Regents of the University of California.  All rights reserved.
        !             7:  *
        !             8:  * This software was developed by the Computer Systems Engineering group
        !             9:  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
        !            10:  * contributed to Berkeley.
        !            11:  *
        !            12:  * All advertising materials mentioning features or use of this software
        !            13:  * must display the following acknowledgement:
        !            14:  *     This product includes software developed by the University of
        !            15:  *     California, Lawrence Berkeley Laboratory.
        !            16:  *
        !            17:  * Redistribution and use in source and binary forms, with or without
        !            18:  * modification, are permitted provided that the following conditions
        !            19:  * are met:
        !            20:  * 1. Redistributions of source code must retain the above copyright
        !            21:  *    notice, this list of conditions and the following disclaimer.
        !            22:  * 2. Redistributions in binary form must reproduce the above copyright
        !            23:  *    notice, this list of conditions and the following disclaimer in the
        !            24:  *    documentation and/or other materials provided with the distribution.
        !            25:  * 3. Neither the name of the University nor the names of its contributors
        !            26:  *    may be used to endorse or promote products derived from this software
        !            27:  *    without specific prior written permission.
        !            28:  *
        !            29:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            30:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            31:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            32:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            33:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            34:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            35:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            36:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            37:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            38:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            39:  * SUCH DAMAGE.
        !            40:  *
        !            41:  *     @(#)autoconf.c  8.4 (Berkeley) 10/1/93
        !            42:  */
        !            43:
        !            44: #include <sys/param.h>
        !            45: #include <sys/systm.h>
        !            46: #include <sys/buf.h>
        !            47: #include <sys/disklabel.h>
        !            48: #include <sys/conf.h>
        !            49: #include <sys/reboot.h>
        !            50: #include <sys/device.h>
        !            51:
        !            52: #include <uvm/uvm_extern.h>
        !            53:
        !            54: #include <machine/autoconf.h>
        !            55: #include <machine/rpb.h>
        !            56: #include <machine/prom.h>
        !            57: #include <machine/cpuconf.h>
        !            58: #include <machine/intr.h>
        !            59:
        !            60: #include <dev/cons.h>
        !            61:
        !            62: extern char            root_device[17];                /* XXX */
        !            63:
        !            64: struct device          *booted_device;
        !            65: int                    booted_partition;
        !            66: struct bootdev_data    *bootdev_data;
        !            67: char                   boot_dev[128];
        !            68:
        !            69: void   parse_prom_bootdev(void);
        !            70: int    atoi(char *);
        !            71:
        !            72: /*
        !            73:  * cpu_configure:
        !            74:  * called at boot time, configure all devices on system
        !            75:  */
        !            76: void
        !            77: cpu_configure()
        !            78: {
        !            79:        parse_prom_bootdev();
        !            80:        softintr_init();
        !            81:
        !            82:        /*
        !            83:         * Disable interrupts during autoconfiguration.  splhigh() won't
        !            84:         * work, because it simply _raises_ the IPL, so if machine checks
        !            85:         * are disabled, they'll stay disabled.  Machine checks are needed
        !            86:         * during autoconfig.
        !            87:         */
        !            88:        (void)alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH);
        !            89:        if (config_rootfound("mainbus", "mainbus") == NULL)
        !            90:                panic("no mainbus found");
        !            91:        (void)spl0();
        !            92:
        !            93:        hwrpb_restart_setup();
        !            94:        cold = 0;
        !            95: }
        !            96:
        !            97: void
        !            98: diskconf(void)
        !            99: {
        !           100:        struct device *bootdv;
        !           101:        int bootpartition;
        !           102:
        !           103:        if (booted_device == NULL)
        !           104:                printf("WARNING: can't figure what device matches \"%s\"\n",
        !           105:                    boot_dev);
        !           106:        bootdv = booted_device;
        !           107:        bootpartition = booted_partition;
        !           108:
        !           109:        setroot(bootdv, bootpartition, RB_USERREQ);
        !           110:        dumpconf();
        !           111: }
        !           112:
        !           113: void
        !           114: parse_prom_bootdev()
        !           115: {
        !           116:        static char hacked_boot_dev[128];
        !           117:        static struct bootdev_data bd;
        !           118:        char *cp, *scp, *boot_fields[8];
        !           119:        int i, done;
        !           120:
        !           121:        booted_device = NULL;
        !           122:        booted_partition = 0;
        !           123:        bootdev_data = NULL;
        !           124:
        !           125:        bcopy(bootinfo.booted_dev, hacked_boot_dev, sizeof hacked_boot_dev);
        !           126: #if 0
        !           127:        printf("parse_prom_bootdev: boot dev = \"%s\"\n", boot_dev);
        !           128: #endif
        !           129:
        !           130:        i = 0;
        !           131:        scp = cp = hacked_boot_dev;
        !           132:        for (done = 0; !done; cp++) {
        !           133:                if (*cp != ' ' && *cp != '\0')
        !           134:                        continue;
        !           135:                if (*cp == '\0')
        !           136:                        done = 1;
        !           137:
        !           138:                *cp = '\0';
        !           139:                boot_fields[i++] = scp;
        !           140:                scp = cp + 1;
        !           141:                if (i == 8)
        !           142:                        done = 1;
        !           143:        }
        !           144:        if (i != 8)
        !           145:                return;         /* doesn't look like anything we know! */
        !           146:
        !           147: #if 0
        !           148:        printf("i = %d, done = %d\n", i, done);
        !           149:        for (i--; i >= 0; i--)
        !           150:                printf("%d = %s\n", i, boot_fields[i]);
        !           151: #endif
        !           152:
        !           153:        bd.protocol = boot_fields[0];
        !           154:        bd.bus = atoi(boot_fields[1]);
        !           155:        bd.slot = atoi(boot_fields[2]);
        !           156:        bd.channel = atoi(boot_fields[3]);
        !           157:        bd.remote_address = boot_fields[4];
        !           158:        bd.unit = atoi(boot_fields[5]);
        !           159:        bd.boot_dev_type = atoi(boot_fields[6]);
        !           160:        bd.ctrl_dev_type = boot_fields[7];
        !           161:
        !           162: #if 0
        !           163:        printf("parsed: proto = %s, bus = %d, slot = %d, channel = %d,\n",
        !           164:            bd.protocol, bd.bus, bd.slot, bd.channel);
        !           165:        printf("\tremote = %s, unit = %d, dev_type = %d, ctrl_type = %s\n",
        !           166:            bd.remote_address, bd.unit, bd.boot_dev_type, bd.ctrl_dev_type);
        !           167: #endif
        !           168:
        !           169:        bootdev_data = &bd;
        !           170: }
        !           171:
        !           172: int
        !           173: atoi(s)
        !           174:        char *s;
        !           175: {
        !           176:        int n, neg;
        !           177:
        !           178:        n = 0;
        !           179:        neg = 0;
        !           180:
        !           181:        while (*s == '-') {
        !           182:                s++;
        !           183:                neg = !neg;
        !           184:        }
        !           185:
        !           186:        while (*s != '\0') {
        !           187:                if (*s < '0' || *s > '9')
        !           188:                        break;
        !           189:
        !           190:                n = (10 * n) + (*s - '0');
        !           191:                s++;
        !           192:        }
        !           193:
        !           194:        return (neg ? -n : n);
        !           195: }
        !           196:
        !           197: void
        !           198: device_register(dev, aux)
        !           199:        struct device *dev;
        !           200:        void *aux;
        !           201: {
        !           202:        if (bootdev_data == NULL) {
        !           203:                /*
        !           204:                 * There is no hope.
        !           205:                 */
        !           206:                return;
        !           207:        }
        !           208:
        !           209:        if (platform.device_register)
        !           210:                (*platform.device_register)(dev, aux);
        !           211: }
        !           212:
        !           213: struct nam2blk nam2blk[] = {
        !           214:        { "st",         2 },
        !           215:        { "cd",         3 },
        !           216:        { "fd",         4 },
        !           217:        { "rd",         6 },
        !           218:        { "sd",         8 },
        !           219:        { "wd",         0 },
        !           220:        { "raid",       16 },
        !           221:        { NULL,         -1 }
        !           222: };

CVSweb