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

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

1.1     ! nbrk        1: /*     $OpenBSD: autoconf.c,v 1.5 2007/06/15 01:19:06 deraadt Exp $    */
        !             2: /*
        !             3:  * Copyright (c) 1998 Steve Murphree, Jr.
        !             4:  * Copyright (c) 1996 Nivas Madhur
        !             5:  * Copyright (c) 1994 Christian E. Hopps
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  * 3. All advertising materials mentioning features or use of this software
        !            17:  *    must display the following acknowledgement:
        !            18:  *      This product includes software developed by Christian E. Hopps.
        !            19:  * 4. The name of the author may not be used to endorse or promote products
        !            20:  *    derived from this software without specific prior written permission
        !            21:  *
        !            22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            32:  *
        !            33:  */
        !            34: #include <sys/param.h>
        !            35: #include <sys/systm.h>
        !            36: #include <sys/buf.h>
        !            37: #include <sys/dkstat.h>
        !            38: #include <sys/reboot.h>
        !            39: #include <sys/conf.h>
        !            40: #include <sys/device.h>
        !            41: #include <sys/disklabel.h>
        !            42: #include <sys/kernel.h>
        !            43:
        !            44: #include <machine/asm_macro.h>
        !            45: #include <machine/autoconf.h>
        !            46: #include <machine/cpu.h>
        !            47: #include <machine/vmparam.h>
        !            48:
        !            49: #include <scsi/scsi_all.h>
        !            50: #include <scsi/scsiconf.h>
        !            51:
        !            52: #include <dev/cons.h>
        !            53:
        !            54: /*
        !            55:  * The following several variables are related to
        !            56:  * the configuration process, and are used in initializing
        !            57:  * the machine.
        !            58:  */
        !            59:
        !            60: void   dumpconf(void);
        !            61:
        !            62: int cold = 1;   /* 1 if still booting */
        !            63:
        !            64: struct device *bootdv; /* set by device drivers (if found) */
        !            65:
        !            66: u_int bootdevtype;
        !            67:
        !            68: #define        BT_CIEN         0x6369656e
        !            69: #define        BT_DGEN         0x6467656e
        !            70: #define        BT_HKEN         0x686b656e
        !            71: #define        BT_INEN         0x696e656e
        !            72: #define        BT_INSC         0x696e7363
        !            73: #define        BT_NCSC         0x6e637363
        !            74:
        !            75: /*
        !            76:  * called at boot time, configure all devices on the system.
        !            77:  */
        !            78: void
        !            79: cpu_configure()
        !            80: {
        !            81:        printf("bootpath: '%s' dev %u unit %u part %u\n",
        !            82:            bootargs, bootdev, bootunit, bootpart);
        !            83:
        !            84:        if (config_rootfound("mainbus", "mainbus") == 0)
        !            85:                panic("no mainbus found");
        !            86:
        !            87:        /*
        !            88:         * Turn external interrupts on.
        !            89:         */
        !            90:        set_psr(get_psr() & ~PSR_IND);
        !            91:        spl0();
        !            92:        cold = 0;
        !            93: }
        !            94:
        !            95: void
        !            96: diskconf(void)
        !            97: {
        !            98:        printf("boot device: %s\n",
        !            99:            (bootdv) ? bootdv->dv_xname : "<unknown>");
        !           100:
        !           101:        setroot(bootdv, bootpart, RB_USERREQ);
        !           102:        dumpconf();
        !           103:
        !           104: }
        !           105:
        !           106: /*
        !           107:  * Parse the commandline.
        !           108:  *
        !           109:  * This has two goals: first, turn the necessary options into boothowto
        !           110:  * flags; second, convert the PROM boot device into the matching OpenBSD
        !           111:  * driver name.
        !           112:  */
        !           113:
        !           114: static char *stws(char *);
        !           115: static char *
        !           116: stws(char *p)
        !           117: {
        !           118:        while (*p != ' ' && *p != '\0')
        !           119:                p++;
        !           120:
        !           121:        while (*p == ' ')
        !           122:                p++;
        !           123:
        !           124:        return (p);
        !           125: }
        !           126:
        !           127: void
        !           128: cmdline_parse(void)
        !           129: {
        !           130:        char *p;
        !           131:
        !           132:        /*
        !           133:         * Skip boot device ``foo(ctrl,dev,lun)'' and filename,
        !           134:         * i.e. eat everything until whitespace.
        !           135:         */
        !           136:        p = stws(bootargs);
        !           137:        while (*p != '\0') {
        !           138:                if (*p++ == '-')
        !           139:                        switch (*p) {
        !           140:                        case 'a':
        !           141:                                boothowto |= RB_ASKNAME;
        !           142:                                break;
        !           143:                        case 'b':
        !           144:                                boothowto |= RB_KDB;
        !           145:                                break;
        !           146:                        case 'c':
        !           147:                                boothowto |= RB_CONFIG;
        !           148:                                break;
        !           149:                        case 's':
        !           150:                                boothowto |= RB_SINGLE;
        !           151:                                break;
        !           152:                        }
        !           153:                p = stws(p);
        !           154:        }
        !           155:
        !           156:        /*
        !           157:         * Now parse the boot device. We are only interested in the
        !           158:         * device type, since the PROM has cracked the controller, unit
        !           159:         * and partition numbers for us already, and we do not care about
        !           160:         * our own filename...
        !           161:         *
        !           162:         * Actually we rely upon the fact that all device strings are
        !           163:         * exactly 4 characters long, and appears at the beginning of the
        !           164:         * commandline, so we can simply use its numerical value, as a
        !           165:         * word, to tell device types apart.
        !           166:         */
        !           167:        bootdevtype = *(int *)bootargs;
        !           168: }
        !           169:
        !           170: void
        !           171: device_register(struct device *dev, void *aux)
        !           172: {
        !           173:        if (bootdv != NULL)
        !           174:                return;
        !           175:
        !           176:        switch (bootdevtype) {
        !           177:        case BT_INEN:
        !           178:                /*
        !           179:                 * Internal ethernet is le at syscon only, and we do not
        !           180:                 * care about controller and unit numbers.
        !           181:                 */
        !           182:                if (strncmp("le", dev->dv_xname, 2) == 0 &&
        !           183:                    strncmp("syscon", dev->dv_parent->dv_xname, 6) == 0)
        !           184:                        bootdv = dev;
        !           185:                break;
        !           186:        }
        !           187: }
        !           188:
        !           189: struct nam2blk nam2blk[] = {
        !           190:        { "sd",         4 },
        !           191:        { "cd",         6 },
        !           192:        { "rd",         7 },
        !           193:        { NULL,         -1 }
        !           194: };

CVSweb