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

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

1.1       nbrk        1: /*     $OpenBSD: autoconf.c,v 1.12 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: void   get_autoboot_device(void);
                     62:
                     63: int cold = 1;   /* 1 if still booting */
                     64:
                     65: void *bootaddr;
                     66: int bootpart;
                     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:
                     76:        if (config_rootfound("mainbus", "mainbus") == 0)
                     77:                panic("no mainbus found");
                     78:
                     79:        /*
                     80:         * Turn external interrupts on.
                     81:         *
                     82:         * XXX We have a race here. If we enable interrupts after setroot(),
                     83:         * the kernel dies.
                     84:         */
                     85:        set_psr(get_psr() & ~PSR_IND);
                     86:        spl0();
                     87:        cold = 0;
                     88: }
                     89:
                     90: void
                     91: diskconf(void)
                     92: {
                     93:        printf("boot device: %s\n",
                     94:            (bootdv) ? bootdv->dv_xname : "<unknown>");
                     95:        setroot(bootdv, 0, RB_USERREQ);
                     96:        dumpconf();
                     97: }
                     98:
                     99: /*
                    100:  * Get 'auto-boot' information from NVRAM
                    101:  *
                    102:  * XXX Right now we can not handle network boot.
                    103:  */
                    104: struct autoboot_t
                    105: {
                    106:        char    cont[16];
                    107:        int     targ;
                    108:        int     part;
                    109: } autoboot;
                    110:
                    111: void
                    112: get_autoboot_device(void)
                    113: {
                    114:        char *value, c;
                    115:        int i, len, part;
                    116:        extern char *nvram_by_symbol(char *);           /* machdep.c */
                    117:
                    118:        /* Assume default controller is internal spc (spc0) */
                    119:        strlcpy(autoboot.cont, "spc0", sizeof(autoboot.cont));
                    120:
                    121:        /* Get boot controler and SCSI target from NVRAM */
                    122:        value = nvram_by_symbol("boot_unit");
                    123:        if (value != NULL) {
                    124:                len = strlen(value);
                    125:                if (len == 1) {
                    126:                        c = value[0];
                    127:                } else if (len == 2) {
                    128:                        if (value[0] == '1') {
                    129:                                /* External spc (spc1) */
                    130:                                strlcpy(autoboot.cont, "spc1", sizeof(autoboot.cont));
                    131:                                c = value[1];
                    132:                        }
                    133:                }
                    134:
                    135:                if ((c >= '0') && (c <= '6'))
                    136:                        autoboot.targ = 6 - (c - '0');
                    137:        }
                    138:
                    139:        /* Get partition number from NVRAM */
                    140:        value = nvram_by_symbol("boot_partition");
                    141:        if (value != NULL) {
                    142:                len = strlen(value);
                    143:                part = 0;
                    144:                for (i = 0; i < len; i++)
                    145:                        part = part * 10 + (value[i] - '0');
                    146:                autoboot.part = part;
                    147:        }
                    148: }
                    149:
                    150: void
                    151: device_register(struct device *dev, void *aux)
                    152: {
                    153:         /*
                    154:          * scsi: sd,cd  XXX: Can LUNA88K boot from CD-ROM?
                    155:          */
                    156:         if (strncmp("sd", dev->dv_xname, 2) == 0 ||
                    157:             strncmp("cd", dev->dv_xname, 2) == 0) {
                    158:                struct scsi_attach_args *sa = aux;
                    159:                struct device *spcsc;
                    160:
                    161:                spcsc = dev->dv_parent->dv_parent;
                    162:
                    163:                 if (strncmp(autoboot.cont, spcsc->dv_xname, 4) == 0 &&
                    164:                    sa->sa_sc_link->target == autoboot.targ &&
                    165:                    sa->sa_sc_link->lun == 0) {
                    166:                         bootdv = dev;
                    167:                        bootpart = autoboot.part;
                    168:                         return;
                    169:                 }
                    170:         }
                    171: }
                    172:
                    173: struct nam2blk nam2blk[] = {
                    174:        { "sd",         4 },
                    175:        { "st",         5 },
                    176:        { "rd",         7 },
                    177:        { NULL,         -1 }
                    178: };

CVSweb