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

Annotation of sys/arch/aviion/dev/mainbus.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: mainbus.c,v 1.2 2006/05/21 12:22:02 miod Exp $ */
                      2: /*
                      3:  * Copyright (c) 1998 Steve Murphree, Jr.
                      4:  * Copyright (c) 2004, Miodrag Vallat.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     18:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
                     19:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     20:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     23:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                     24:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     25:  * POSSIBILITY OF SUCH DAMAGE.
                     26:  */
                     27:
                     28: #include <sys/param.h>
                     29: #include <sys/systm.h>
                     30: #include <sys/reboot.h>
                     31: #include <sys/conf.h>
                     32: #include <sys/device.h>
                     33: #include <sys/disklabel.h>
                     34: #include <sys/extent.h>
                     35:
                     36: #include <uvm/uvm_extern.h>
                     37:
                     38: #include <machine/autoconf.h>
                     39: #include <machine/bus.h>
                     40: #include <machine/cmmu.h>
                     41: #include <machine/cpu.h>
                     42: #include <machine/prom.h>
                     43:
                     44: void   mainbus_attach(struct device *, struct device *, void *);
                     45: int    mainbus_match(struct device *, void *, void *);
                     46: int    mainbus_print(void *, const char *);
                     47: int    mainbus_scan(struct device *, void *, void *);
                     48:
                     49: /*
                     50:  * bus_space routines for 1:1 obio mappings
                     51:  */
                     52:
                     53: int    mainbus_map(bus_addr_t, bus_size_t, int, bus_space_handle_t *);
                     54: void   mainbus_unmap(bus_space_handle_t, bus_size_t);
                     55: int    mainbus_subregion(bus_space_handle_t, bus_size_t, bus_size_t,
                     56:            bus_space_handle_t *);
                     57: void   *mainbus_vaddr(bus_space_handle_t);
                     58:
                     59: const struct aviion_bus_space_tag mainbus_bustag = {
                     60:        mainbus_map,
                     61:        mainbus_unmap,
                     62:        mainbus_subregion,
                     63:        mainbus_vaddr
                     64: };
                     65:
                     66: /*
                     67:  * Obio (internal IO) space is mapped 1:1 (see pmap_bootstrap() for details).
                     68:  */
                     69:
                     70: int
                     71: mainbus_map(bus_addr_t addr, bus_size_t size, int flags,
                     72:     bus_space_handle_t *ret)
                     73: {
                     74:        *ret = (bus_space_handle_t)addr;
                     75:        return 0;
                     76: }
                     77:
                     78: void
                     79: mainbus_unmap(bus_space_handle_t handle, bus_size_t size)
                     80: {
                     81:        /* nothing to do */
                     82: }
                     83:
                     84: int
                     85: mainbus_subregion(bus_space_handle_t handle, bus_addr_t offset,
                     86:     bus_size_t size, bus_space_handle_t *ret)
                     87: {
                     88:        *ret = handle + offset;
                     89:        return (0);
                     90: }
                     91:
                     92: void *
                     93: mainbus_vaddr(bus_space_handle_t handle)
                     94: {
                     95:        return (void *)handle;
                     96: }
                     97:
                     98: /*
                     99:  * Configuration glue
                    100:  */
                    101:
                    102: struct cfattach mainbus_ca = {
                    103:        sizeof(struct device), mainbus_match, mainbus_attach
                    104: };
                    105:
                    106: struct cfdriver mainbus_cd = {
                    107:        NULL, "mainbus", DV_DULL
                    108: };
                    109:
                    110: int
                    111: mainbus_match(struct device *parent, void *cf, void *args)
                    112: {
                    113:        return (mainbus_cd.cd_ndevs == 0);
                    114: }
                    115:
                    116: void
                    117: mainbus_attach(struct device *parent, struct device *self, void *args)
                    118: {
                    119:        extern char cpu_model[];
                    120:        extern int32_t cpuid, sysid;
                    121:
                    122:        printf(": %s, cpuid 0x%x", cpu_model, cpuid);
                    123:        if (sysid != -1)
                    124:                printf(", sysid %x", sysid);
                    125:        printf("\n");
                    126:
                    127:        /*
                    128:         * Display cpu/mmu details for the main processor.
                    129:         */
                    130:        cpu_configuration_print(1);
                    131:
                    132:        (void)config_search(mainbus_scan, self, args);
                    133: }
                    134:
                    135: int
                    136: mainbus_scan(struct device *parent, void *child, void *args)
                    137: {
                    138:        struct cfdata *cf = child;
                    139:        struct confargs oca;
                    140:
                    141:        oca.ca_iot = &mainbus_bustag;
                    142:        oca.ca_paddr = (paddr_t)cf->cf_loc[0];
                    143:        oca.ca_offset = (paddr_t)-1;
                    144:        oca.ca_ipl = (u_int)-1;
                    145:
                    146:        if ((*cf->cf_attach->ca_match)(parent, cf, &oca) == 0)
                    147:                return (0);
                    148:
                    149:        config_attach(parent, cf, &oca, mainbus_print);
                    150:        return (1);
                    151: }
                    152:
                    153: int
                    154: mainbus_print(void *args, const char *bus)
                    155: {
                    156:        struct confargs *ca = args;
                    157:
                    158:        if (ca->ca_paddr != (paddr_t)-1)
                    159:                printf(" addr 0x%08x", ca->ca_paddr);
                    160:        return (UNCONF);
                    161: }

CVSweb