[BACK]Return to obio.c CVS log [TXT][DIR] Up to [local] / sys / arch / solbourne / dev

Annotation of sys/arch/solbourne/dev/obio.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: obio.c,v 1.1 2005/04/20 01:00:16 miod Exp $   */
                      2: /*     OpenBSD: obio.c,v 1.16 2004/09/29 07:35:11 miod Exp     */
                      3:
                      4: /*
                      5:  * Copyright (c) 1993, 1994 Theo de Raadt
                      6:  * Copyright (c) 1995, 1997 Paul Kranenburg
                      7:  * All rights reserved.
                      8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  * 3. The name of the author may not be used to endorse or promote products
                     18:  *    derived from this software without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     21:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     22:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     23:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     24:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     25:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     26:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     27:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     28:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     29:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31:
                     32: #include <sys/param.h>
                     33: #include <sys/systm.h>
                     34: #include <sys/device.h>
                     35:
                     36: #include <machine/autoconf.h>
                     37: #include <machine/cpu.h>
                     38: #include <machine/idt.h>
                     39:
                     40: /* autoconfiguration driver */
                     41: static int     obiomatch(struct device *, void *, void *);
                     42: static void    obioattach(struct device *, struct device *, void *);
                     43:
                     44: int            obioprint(void *, const char *);
                     45: int            obio_scan(struct device *, void *, void *);
                     46:
                     47: struct cfattach obio_ca = {
                     48:        sizeof(struct device), obiomatch, obioattach
                     49: };
                     50:
                     51: struct cfdriver obio_cd = {
                     52:        NULL, "obio", DV_DULL
                     53: };
                     54:
                     55: /*
                     56:  * A list of the on-board devices in the IDT systems. This is better than
                     57:  * having people playing with locators in their kernel configuration
                     58:  * files, and necessary because the device tree built by the PROM does not
                     59:  * list all on-board devices (audio and floppy are missing).
                     60:  */
                     61: const struct {
                     62:        char *devname;
                     63:        paddr_t address;
                     64:        int     intr;
                     65: } obio_devices[] = {
                     66:        { "tod",        TODCLOCK_BASE,  -1 },
                     67:        { "nvram",      NVRAM_BASE,     -1 },
                     68:        { "zs",         ZS0_BASE,       12 },
                     69:        { "zs",         ZS1_BASE,       12 },
                     70:        { "fdc",        FDC_BASE,       11 },
                     71:        { "audioamd",   AUDIO_BASE,     13 },
                     72:        { "wdsc",       SE_BASE + 0x20, 4 },
                     73:        { "le",         SE_BASE + 0x30, 6 },
                     74:        { NULL,         0 }
                     75: };
                     76:
                     77: int
                     78: obiomatch(parent, vcf, aux)
                     79:        struct device *parent;
                     80:        void *vcf, *aux;
                     81: {
                     82:        register struct cfdata *cf = vcf;
                     83:        register struct confargs *ca = aux;
                     84:        register struct romaux *ra = &ca->ca_ra;
                     85:
                     86:        return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0);
                     87: }
                     88:
                     89: int
                     90: obioprint(args, obio)
                     91:        void *args;
                     92:        const char *obio;
                     93: {
                     94:        register struct confargs *ca = args;
                     95:
                     96:        if (ca->ca_ra.ra_name == NULL)
                     97:                ca->ca_ra.ra_name = "<unknown>";
                     98:
                     99:        if (obio)
                    100:                printf("%s at %s", ca->ca_ra.ra_name, obio);
                    101:
                    102:        printf(" addr %p", ca->ca_ra.ra_paddr);
                    103:
                    104:        return (UNCONF);
                    105: }
                    106:
                    107: void
                    108: obioattach(parent, self, args)
                    109:        struct device *parent, *self;
                    110:        void *args;
                    111: {
                    112:        struct confargs *ca = args;
                    113:        struct confargs oca;
                    114:        int i;
                    115:
                    116:        if (self->dv_unit > 0) {
                    117:                printf(" unsupported\n");
                    118:                return;
                    119:        }
                    120:        printf("\n");
                    121:
                    122:        for (i = 0; obio_devices[i].devname != NULL; i++) {
                    123:                /* fake a rom_reg */
                    124:                bzero(&oca, sizeof oca);
                    125:                oca.ca_ra.ra_paddr = (caddr_t)obio_devices[i].address;
                    126:                oca.ca_ra.ra_vaddr = NULL;
                    127:                oca.ca_ra.ra_len = 0;
                    128:                oca.ca_ra.ra_nreg = 1;
                    129:                oca.ca_ra.ra_iospace = 0;
                    130:                oca.ca_ra.ra_intr[0].int_pri = obio_devices[i].intr;
                    131:                oca.ca_ra.ra_intr[0].int_vec = -1;
                    132:                oca.ca_ra.ra_nintr = oca.ca_ra.ra_intr[0].int_pri < 0 ? 0 : 1;
                    133:                oca.ca_ra.ra_name = obio_devices[i].devname;
                    134:                if (ca->ca_ra.ra_bp != NULL)
                    135:                        oca.ca_ra.ra_bp = ca->ca_ra.ra_bp + 1;
                    136:                else
                    137:                        oca.ca_ra.ra_bp = NULL;
                    138:                oca.ca_bustype = BUS_OBIO;
                    139:
                    140:                config_found(self, &oca, obioprint);
                    141:        }
                    142: }

CVSweb