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

Annotation of sys/arch/arm/mainbus/mainbus_io.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: mainbus_io.c,v 1.3 2007/05/25 16:45:59 krw Exp $ */
                      2: /*     $NetBSD: mainbus_io.c,v 1.14 2003/12/06 22:05:33 bjh21 Exp $    */
                      3:
                      4: /*
                      5:  * Copyright (c) 1997 Mark Brinicombe.
                      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.
                     19:  * 4. The name of the company nor the name of the author may be used to
                     20:  *    endorse or promote products derived from this software without specific
                     21:  *    prior written permission.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     24:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
                     25:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     26:  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
                     27:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     28:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     29:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     33:  * SUCH DAMAGE.
                     34:  */
                     35:
                     36: /*
                     37:  * bus_space I/O functions for mainbus
                     38:  */
                     39:
                     40: #include <sys/param.h>
                     41: #include <sys/systm.h>
                     42: #include <sys/queue.h>
                     43:
                     44: #include <uvm/uvm.h>
                     45:
                     46: #include <machine/bus.h>
                     47: #include <machine/pmap.h>
                     48:
                     49: /* Prototypes for all the bus_space structure functions */
                     50:
                     51: bs_protos(mainbus);
                     52: bs_protos(bs_notimpl);
                     53:
                     54: /* Declare the mainbus bus space tag */
                     55:
                     56: struct bus_space mainbus_bs_tag = {
                     57:        /* cookie */
                     58:        NULL,
                     59:
                     60:        /* mapping/unmapping */
                     61:        mainbus_bs_map,
                     62:        mainbus_bs_unmap,
                     63:        mainbus_bs_subregion,
                     64:
                     65:        /* allocation/deallocation */
                     66:        mainbus_bs_alloc,
                     67:        mainbus_bs_free,
                     68:
                     69:        /* get kernel virtual address */
                     70:        0, /* there is no linear mapping */
                     71:
                     72:        /* Mmap bus space for user */
                     73:        mainbus_bs_mmap,
                     74:
                     75:        /* barrier */
                     76:        mainbus_bs_barrier,
                     77:
                     78:        /* read (single) */
                     79:        mainbus_bs_r_1,
                     80:        mainbus_bs_r_2,
                     81:        mainbus_bs_r_4,
                     82:        bs_notimpl_bs_r_8,
                     83:
                     84:        /* read multiple */
                     85:        bs_notimpl_bs_rm_1,
                     86:        mainbus_bs_rm_2,
                     87:        bs_notimpl_bs_rm_4,
                     88:        bs_notimpl_bs_rm_8,
                     89:
                     90:        /* read region */
                     91:        bs_notimpl_bs_rr_1,
                     92:        bs_notimpl_bs_rr_2,
                     93:        bs_notimpl_bs_rr_4,
                     94:        bs_notimpl_bs_rr_8,
                     95:
                     96:        /* write (single) */
                     97:        mainbus_bs_w_1,
                     98:        mainbus_bs_w_2,
                     99:        mainbus_bs_w_4,
                    100:        bs_notimpl_bs_w_8,
                    101:
                    102:        /* write multiple */
                    103:        mainbus_bs_wm_1,
                    104:        mainbus_bs_wm_2,
                    105:        bs_notimpl_bs_wm_4,
                    106:        bs_notimpl_bs_wm_8,
                    107:
                    108:        /* write region */
                    109:        bs_notimpl_bs_wr_1,
                    110:        bs_notimpl_bs_wr_2,
                    111:        bs_notimpl_bs_wr_4,
                    112:        bs_notimpl_bs_wr_8,
                    113:
                    114:        bs_notimpl_bs_sm_1,
                    115:        bs_notimpl_bs_sm_2,
                    116:        bs_notimpl_bs_sm_4,
                    117:        bs_notimpl_bs_sm_8,
                    118:
                    119:        /* set region */
                    120:        bs_notimpl_bs_sr_1,
                    121:        bs_notimpl_bs_sr_2,
                    122:        bs_notimpl_bs_sr_4,
                    123:        bs_notimpl_bs_sr_8,
                    124:
                    125:        /* copy */
                    126:        bs_notimpl_bs_c_1,
                    127:        bs_notimpl_bs_c_2,
                    128:        bs_notimpl_bs_c_4,
                    129:        bs_notimpl_bs_c_8,
                    130: };
                    131:
                    132: /* bus space functions */
                    133:
                    134: int
                    135: mainbus_bs_map(t, bpa, size, flags, bshp)
                    136:        void *t;
                    137:        bus_addr_t bpa;
                    138:        bus_size_t size;
                    139:        int flags;
                    140:        bus_space_handle_t *bshp;
                    141: {
                    142:        u_long startpa, endpa, pa;
                    143:        vaddr_t va;
                    144:        pt_entry_t *pte;
                    145:
                    146:        if ((u_long)bpa > (u_long)KERNEL_BASE) {
                    147:                /* XXX This is a temporary hack to aid transition. */
                    148:                *bshp = bpa;
                    149:                return(0);
                    150:        }
                    151:
                    152:        startpa = trunc_page(bpa);
                    153:        endpa = round_page(bpa + size);
                    154:
                    155:        /* XXX use extent manager to check duplicate mapping */
                    156:
                    157:        va = uvm_km_valloc(kernel_map, endpa - startpa);
                    158:        if (! va)
                    159:                return(ENOMEM);
                    160:
                    161:        *bshp = (bus_space_handle_t)(va + (bpa - startpa));
                    162:
                    163:        for(pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
                    164:                pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
                    165:                if ((flags & BUS_SPACE_MAP_CACHEABLE) == 0) {
                    166:                        pte = vtopte(va);
                    167:                        *pte &= ~L2_S_CACHE_MASK;
                    168:                        PTE_SYNC(pte);
                    169:                }
                    170:        }
                    171:        pmap_update(pmap_kernel());
                    172:
                    173:        return(0);
                    174: }
                    175:
                    176: int
                    177: mainbus_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
                    178:     bpap, bshp)
                    179:        void *t;
                    180:        bus_addr_t rstart, rend;
                    181:        bus_size_t size, alignment, boundary;
                    182:        int cacheable;
                    183:        bus_addr_t *bpap;
                    184:        bus_space_handle_t *bshp;
                    185: {
                    186:        panic("mainbus_bs_alloc(): Help!");
                    187: }
                    188:
                    189:
                    190: void
                    191: mainbus_bs_unmap(t, bsh, size)
                    192:        void *t;
                    193:        bus_space_handle_t bsh;
                    194:        bus_size_t size;
                    195: {
                    196:        /*
                    197:         * Temporary implementation
                    198:         */
                    199: }
                    200:
                    201: void
                    202: mainbus_bs_free(t, bsh, size)
                    203:        void *t;
                    204:        bus_space_handle_t bsh;
                    205:        bus_size_t size;
                    206: {
                    207:
                    208:        panic("mainbus_bs_free(): Help!");
                    209:        /* mainbus_bs_unmap() does all that we need to do. */
                    210: /*     mainbus_bs_unmap(t, bsh, size);*/
                    211: }
                    212:
                    213: int
                    214: mainbus_bs_subregion(t, bsh, offset, size, nbshp)
                    215:        void *t;
                    216:        bus_space_handle_t bsh;
                    217:        bus_size_t offset, size;
                    218:        bus_space_handle_t *nbshp;
                    219: {
                    220:
                    221:        *nbshp = bsh + (offset << 2);
                    222:        return (0);
                    223: }
                    224:
                    225: paddr_t
                    226: mainbus_bs_mmap(t, paddr, offset, prot, flags)
                    227:        void *t;
                    228:        bus_addr_t paddr;
                    229:        off_t offset;
                    230:        int prot;
                    231:        int flags;
                    232: {
                    233:        /*
                    234:         * mmap from address `paddr+offset' for one page
                    235:         */
                    236:         return (atop(paddr + offset));
                    237: }
                    238:
                    239: void
                    240: mainbus_bs_barrier(t, bsh, offset, len, flags)
                    241:        void *t;
                    242:        bus_space_handle_t bsh;
                    243:        bus_size_t offset, len;
                    244:        int flags;
                    245: {
                    246: }
                    247:
                    248: /* End of mainbus_io.c */

CVSweb