[BACK]Return to autoconf.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / cats / cats

Annotation of src/sys/arch/cats/cats/autoconf.c, Revision 1.9.2.3

1.9.2.3 ! yamt        1: /*     $NetBSD: autoconf.c,v 1.9.2.2 2007/12/07 17:24:24 yamt Exp $    */
1.1       chris       2:
                      3: /*
                      4:  * Copyright (c) 1994-1998 Mark Brinicombe.
                      5:  * Copyright (c) 1994 Brini.
                      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 Mark Brinicombe for
                     19:  *      the NetBSD project.
                     20:  * 4. The name of the company nor the name of the author may be used to
                     21:  *    endorse or promote products derived from this software without specific
                     22:  *    prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     25:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
                     26:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     27:  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
                     28:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     29:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     30:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  * RiscBSD kernel project
                     37:  *
                     38:  * autoconf.c
                     39:  *
                     40:  * Autoconfiguration functions
                     41:  */
1.6       lukem      42:
                     43: #include <sys/cdefs.h>
1.9.2.3 ! yamt       44: __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9.2.2 2007/12/07 17:24:24 yamt Exp $");
1.1       chris      45:
                     46: #include "opt_md.h"
                     47:
                     48: #include <sys/param.h>
                     49: #include <sys/systm.h>
                     50: #include <sys/reboot.h>
                     51: #include <sys/disklabel.h>
                     52: #include <sys/device.h>
                     53: #include <sys/conf.h>
                     54: #include <sys/kernel.h>
                     55: #include <sys/malloc.h>
                     56: #include <machine/bootconfig.h>
1.2       matt       57: #include <machine/intr.h>
1.9.2.3 ! yamt       58: #include <dev/pci/pcivar.h>
1.1       chris      59:
                     60: #include "isa.h"
                     61:
1.9       chris      62: void isa_intr_init(void);
1.1       chris      63:
1.9       chris      64: static void get_device(const char *name);
                     65: static void set_root_device(void);
1.1       chris      66:
                     67: /* Decode a device name to a major and minor number */
                     68:
                     69: static void
1.9       chris      70: get_device(const char *name)
1.1       chris      71: {
1.3       gehenna    72:        int unit, part;
1.9       chris      73:        char devname[16], buf[32];
                     74:        const char *cp;
1.1       chris      75:        struct device *dv;
                     76:
                     77:        if (strncmp(name, "/dev/", 5) == 0)
                     78:                name += 5;
                     79:
1.3       gehenna    80:        if (devsw_name2blk(name, devname, sizeof(devname)) == -1)
                     81:                return;
                     82:
                     83:        name += strlen(devname);
                     84:        unit = part = 0;
                     85:
                     86:        cp = name;
                     87:        while (*cp >= '0' && *cp <= '9')
                     88:                unit = (unit * 10) + (*cp++ - '0');
                     89:        if (cp == name)
                     90:                return;
                     91:
                     92:        if (*cp >= 'a' && *cp <= ('a' + MAXPARTITIONS))
                     93:                part = *cp - 'a';
                     94:        else if (*cp != '\0' && *cp != ' ')
                     95:                return;
                     96:        sprintf(buf, "%s%d", devname, unit);
1.8       chris      97:        TAILQ_FOREACH(dv, &alldevs, dv_list) {
1.3       gehenna    98:                if (strcmp(buf, dv->dv_xname) == 0) {
                     99:                        booted_device = dv;
                    100:                        booted_partition = part;
                    101:                        return;
1.1       chris     102:                }
1.3       gehenna   103:        }
1.1       chris     104: }
                    105:
                    106: static void
                    107: set_root_device()
                    108: {
                    109:        char *ptr;
                    110:
                    111:        if (boot_file)
                    112:                get_device(boot_file);
                    113:        if (boot_args &&
                    114:            get_bootconf_option(boot_args, "root", BOOTOPT_TYPE_STRING, &ptr))
                    115:                get_device(ptr);
                    116: }
                    117:
                    118: /*
                    119:  * Set up the root device from the boot args
                    120:  */
                    121: void
                    122: cpu_rootconf(void)
                    123: {
                    124:        set_root_device();
                    125:        printf("boot device: %s\n",
                    126:            booted_device != NULL ? booted_device->dv_xname : "<unknown>");
                    127:        setroot(booted_device, booted_partition);
                    128: }
                    129:
                    130:
                    131: /*
                    132:  * void cpu_configure()
                    133:  *
                    134:  * Configure all the root devices
                    135:  * The root devices are expected to configure their own children
                    136:  */
1.4       chris     137: extern int footbridge_imask[NIPL];
                    138:
1.1       chris     139: void
                    140: cpu_configure(void)
                    141: {
                    142:        /*
                    143:         * Since various PCI interrupts could be routed via the ICU
                    144:         * (for PCI devices in the bridge) we need to set up the ICU
                    145:         * now so that these interrupts can be established correctly
                    146:         * i.e. This is a hack.
                    147:         */
                    148:        isa_intr_init();
                    149:
1.4       chris     150:
1.1       chris     151:        config_rootfound("mainbus", NULL);
                    152:
1.9.2.1   yamt      153: #if defined(DEBUG)
1.1       chris     154:        /* Debugging information */
1.5       thorpej   155:        printf("ipl_bio=%08x ipl_net=%08x ipl_tty=%08x ipl_vm=%08x\n",
1.4       chris     156:            footbridge_imask[IPL_BIO], footbridge_imask[IPL_NET],
1.5       thorpej   157:            footbridge_imask[IPL_TTY], footbridge_imask[IPL_VM]);
1.1       chris     158:        printf("ipl_audio=%08x ipl_imp=%08x ipl_high=%08x ipl_serial=%08x\n",
1.4       chris     159:            footbridge_imask[IPL_AUDIO], footbridge_imask[IPL_CLOCK],
                    160:            footbridge_imask[IPL_HIGH], footbridge_imask[IPL_SERIAL]);
1.9.2.1   yamt      161: #endif /* defined(DEBUG) */
1.1       chris     162:
                    163:        /* Time to start taking interrupts so lets open the flood gates .... */
                    164:        (void)spl0();
                    165: }
                    166:
                    167: void
                    168: device_register(struct device *dev, void *aux)
                    169: {
1.9.2.3 ! yamt      170:        struct device *pdev;
        !           171:         if ((pdev = device_parent(dev)) != NULL &&
        !           172:            device_is_a(pdev, "pci")) {
        !           173:                /*
        !           174:                 * cats builtin aceride is on 0:16:0
        !           175:                 */
        !           176:                struct pci_attach_args *pa = aux;
        !           177:                if (((pa)->pa_bus == 0
        !           178:                    && (pa)->pa_device == 16
        !           179:                    && (pa)->pa_function == 0)) {
        !           180:                        if (prop_dictionary_set_bool(device_properties(dev),
        !           181:                                                "ali1543-ide-force-compat-mode",
        !           182:                                                true) == false) {
        !           183:                                printf("WARNING: unable to set "
        !           184:                                        "ali1543-ide-force-compat-mode "
        !           185:                                        "property for %s\n", dev->dv_xname);
        !           186:                        }
        !           187:                }
        !           188:        }
1.1       chris     189: }
                    190: /* End of autoconf.c */

CVSweb <webmaster@jp.NetBSD.org>