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

Annotation of sys/arch/mvme88k/mvme88k/autoconf.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: autoconf.c,v 1.39 2007/06/15 01:19:08 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>   /* enable/disable interrupts */
                     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: int    get_target(int *, int *, int *);
                     62:
                     63: int cold = 1;   /* 1 if still booting */
                     64:
                     65: paddr_t bootaddr;
                     66: int bootpart, bootbus;
                     67: struct device *bootdv; /* set by device drivers (if found) */
                     68:
                     69: /*
                     70:  * called at boot time, configure all devices on the system.
                     71:  */
                     72: void
                     73: cpu_configure()
                     74: {
                     75:        if (config_rootfound("mainbus", "mainbus") == 0)
                     76:                panic("no mainbus found");
                     77:
                     78:        /*
                     79:         * Turn external interrupts on.
                     80:         *
                     81:         * XXX We have a race here. If we enable interrupts after setroot(),
                     82:         * the kernel dies.
                     83:         */
                     84:        set_psr(get_psr() & ~PSR_IND);
                     85:        spl0();
                     86:
                     87:        /*
                     88:         * Finally switch to the real console driver,
                     89:         * and say goodbye to the BUG!
                     90:         */
                     91:        cn_tab = NULL;
                     92:        cninit();
                     93:        cold = 0;
                     94: }
                     95:
                     96: void
                     97: diskconf(void)
                     98: {
                     99:        printf("boot device: %s\n",
                    100:            (bootdv) ? bootdv->dv_xname : "<unknown>");
                    101:
                    102:        setroot(bootdv, bootpart, RB_USERREQ);
                    103:        dumpconf();
                    104: }
                    105:
                    106: void
                    107: device_register(struct device *dev, void *aux)
                    108: {
                    109:        if (bootpart == -1) /* ignore flag from controller driver? */
                    110:                return;
                    111:
                    112:        /*
                    113:         * scsi: sd,cd
                    114:         */
                    115:        if (strncmp("cd", dev->dv_xname, 2) == 0 ||
                    116:            strncmp("sd", dev->dv_xname, 2) == 0) {
                    117:                struct scsi_attach_args *sa = aux;
                    118:                int target, bus, lun;
                    119:
                    120:                if (get_target(&target, &bus, &lun) != 0)
                    121:                        return;
                    122:
                    123:                /* make sure we are on the expected scsibus */
                    124:                if (bootbus != bus)
                    125:                        return;
                    126:
                    127:                if (sa->sa_sc_link->target == target &&
                    128:                    sa->sa_sc_link->lun == lun) {
                    129:                        bootdv = dev;
                    130:                        return;
                    131:                }
                    132:        }
                    133:
                    134:        /*
                    135:         * ethernet: ie,le
                    136:         */
                    137:        else if (strncmp("ie", dev->dv_xname, 2) == 0 ||
                    138:            strncmp("le", dev->dv_xname, 2) == 0) {
                    139:                struct confargs *ca = aux;
                    140:
                    141:                if (ca->ca_paddr == bootaddr) {
                    142:                        bootdv = dev;
                    143:                        return;
                    144:                }
                    145:        }
                    146: }
                    147:
                    148: /*
                    149:  * Returns the ID of the SCSI disk based on Motorola's CLUN/DLUN stuff
                    150:  * bootdev == CLUN << 8 | DLUN.
                    151:  * This handles SBC SCSI and MVME32[78].
                    152:  */
                    153: int
                    154: get_target(int *target, int *bus, int *lun)
                    155: {
                    156:        extern int bootdev;
                    157:
                    158:        switch (bootdev >> 8) {
                    159:        /* built-in controller */
                    160:        case 0x00:
                    161:        /* MVME327 */
                    162:        case 0x02:
                    163:        case 0x03:
                    164:                *bus = 0;
                    165:                *target = (bootdev & 0x70) >> 4;
                    166:                *lun = (bootdev & 0x07);
                    167:                return (0);
                    168:        /* MVME328 */
                    169:        case 0x06:
                    170:        case 0x07:
                    171:        case 0x16:
                    172:        case 0x17:
                    173:        case 0x18:
                    174:        case 0x19:
                    175:                *bus = (bootdev & 0x40) >> 6;
                    176:                *target = (bootdev & 0x38) >> 3;
                    177:                *lun = (bootdev & 0x07);
                    178:                return (0);
                    179:        default:
                    180:                return (ENODEV);
                    181:        }
                    182: }
                    183:
                    184: struct nam2blk nam2blk[] = {
                    185:        { "sd",         4 },
                    186:        { "cd",         6 },
                    187:        { "rd",         7 },
                    188:        { NULL,         -1 }
                    189: };

CVSweb