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

Annotation of sys/arch/arm/sa11x0/sa11x1_space.c, Revision 1.2

1.2     ! nbrk        1: /*     $Id: sa11x1_space.c,v 1.1.1.1 2008/03/04 16:05:17 nbrk Exp $    */
1.1       nbrk        2: /*
                      3:  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
                      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 for the NetBSD Project by
                     19:  *     Wasabi Systems, Inc.
                     20:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
                     21:  *    or promote products derived from this software without specific prior
                     22:  *    written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     26:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     27:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
                     28:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     29:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     30:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     31:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     32:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     33:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     34:  * POSSIBILITY OF SUCH DAMAGE.
                     35:  */
                     36: /*
                     37:  * Copyright (c) 1997 Mark Brinicombe.
                     38:  * Copyright (c) 1997 Causality Limited.
                     39:  * All rights reserved.
                     40:  *
                     41:  * This code is derived from software contributed to The NetBSD Foundation
                     42:  * by Ichiro FUKUHARA.
                     43:  *
                     44:  * Redistribution and use in source and binary forms, with or without
                     45:  * modification, are permitted provided that the following conditions
                     46:  * are met:
                     47:  * 1. Redistributions of source code must retain the above copyright
                     48:  *    notice, this list of conditions and the following disclaimer.
                     49:  * 2. Redistributions in binary form must reproduce the above copyright
                     50:  *    notice, this list of conditions and the following disclaimer in the
                     51:  *    documentation and/or other materials provided with the distribution.
                     52:  * 3. All advertising materials mentioning features or use of this software
                     53:  *    must display the following acknowledgement:
                     54:  *     This product includes software developed by Mark Brinicombe.
                     55:  * 4. The name of the company nor the name of the author may be used to
                     56:  *    endorse or promote products derived from this software without specific
                     57:  *    prior written permission.
                     58:  *
                     59:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     60:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
                     61:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     62:  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
                     63:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     64:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     65:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     66:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     67:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     68:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     69:  * SUCH DAMAGE.
                     70:  */
                     71: #include <sys/cdefs.h>
                     72:
                     73: #include <sys/param.h>
                     74: #include <sys/systm.h>
                     75:
                     76: #include <uvm/uvm_extern.h>
                     77:
                     78: #include <machine/bus.h>
                     79:
1.2     ! nbrk       80: /* XXX */
        !            81: uint8_t        sa11x1_h_bs_r_1(void *t, bus_space_handle_t bsh, bus_size_t addr);
        !            82:
1.1       nbrk       83: /* Prototypes for all the bus_space structure functions */
                     84: bs_protos(sa11x1);
                     85: bs_protos(generic);
                     86: bs_protos(generic_armv4);
                     87: bs_protos(bs_notimpl);
                     88:
                     89: struct bus_space sa11x1_bs_tag = {
                     90:        /* cookie */
                     91:        (void *) 0,
                     92:
                     93:        /* mapping/unmapping */
                     94:        sa11x1_bs_map,
                     95:        sa11x1_bs_unmap,
                     96:        sa11x1_bs_subregion,
                     97:
                     98:        /* allocation/deallocation */
                     99:        sa11x1_bs_alloc,        /* not implemented */
                    100:        sa11x1_bs_free,         /* not implemented */
                    101:
                    102:        /* get kernel virtual address */
                    103:        sa11x1_bs_vaddr,
                    104:
                    105:        /* mmap */
                    106:        bs_notimpl_bs_mmap,
                    107:
                    108:        /* barrier */
                    109:        sa11x1_bs_barrier,
                    110:
                    111:        /* read (single) */
1.2     ! nbrk      112:        sa11x1_h_bs_r_1,        /* XXX hack for pcmcia accesses */
1.1       nbrk      113:        bs_notimpl_bs_r_2,
                    114:        generic_bs_r_4,
                    115:        bs_notimpl_bs_r_8,
                    116:
                    117:        /* read multiple */
                    118:        bs_notimpl_bs_rm_1,
                    119:        bs_notimpl_bs_rm_2,
                    120:        generic_bs_rm_4,
                    121:        bs_notimpl_bs_rm_8,
                    122:
                    123:        /* read region */
                    124:        /* XXX only word-wide transactions on APB */
                    125:        generic_bs_rr_1,
                    126:        generic_armv4_bs_rr_2,
                    127:        generic_bs_rr_4,
                    128:        bs_notimpl_bs_rr_8,
                    129:
                    130:        /* write (single) */
                    131:        bs_notimpl_bs_w_1,
                    132:        bs_notimpl_bs_w_2,
                    133:        generic_bs_w_4,
                    134:        bs_notimpl_bs_w_8,
                    135:
                    136:        /* write multiple */
                    137:        bs_notimpl_bs_wm_1,
                    138:        bs_notimpl_bs_wm_2,
                    139:        generic_bs_wm_4,
                    140:        bs_notimpl_bs_wm_8,
                    141:
                    142:        /* write region */
                    143:        /* XXX only word-wide transactions on APB */
                    144:        generic_bs_wr_1,
                    145:        generic_armv4_bs_wr_2,
                    146:        generic_bs_wr_4,
                    147:        bs_notimpl_bs_wr_8,
                    148:
                    149:        /* set multiple */
                    150:        bs_notimpl_bs_sm_1,
                    151:        bs_notimpl_bs_sm_2,
                    152:        bs_notimpl_bs_sm_4,
                    153:        bs_notimpl_bs_sm_8,
                    154:
                    155:        /* set region */
                    156:        generic_bs_sr_1,
                    157:        generic_armv4_bs_sr_2,
                    158:        bs_notimpl_bs_sr_4,
                    159:        bs_notimpl_bs_sr_8,
                    160:
                    161:        /* copy */
                    162:        bs_notimpl_bs_c_1,
                    163:        generic_armv4_bs_c_2,
                    164:        bs_notimpl_bs_c_4,
                    165:        bs_notimpl_bs_c_8,
                    166: };
                    167:
                    168: int
                    169: sa11x1_bs_map(void *t, bus_addr_t bpa, bus_size_t size,
                    170:              int flag, bus_space_handle_t *bshp)
                    171: {
                    172:        u_long startpa, endpa, pa;
                    173:        vaddr_t va;
                    174:        pt_entry_t *pte;
                    175:
                    176:        /* XXX add our base address so we can use offsets in our address space */
                    177:        bpa = *(bus_addr_t *)sa11x1_bs_tag.bs_cookie + bpa;
                    178:
                    179:        startpa = trunc_page(bpa);
                    180:        endpa = round_page(bpa + size);
                    181:
                    182:        /* XXX use extent manager to check duplicate mapping */
                    183:
                    184:        va = uvm_km_valloc(kernel_map, endpa - startpa);
                    185:        if (! va)
                    186:                return(ENOMEM);
                    187:
                    188:        *bshp = (bus_space_handle_t)(va + (bpa - startpa));
                    189:
                    190:        for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
                    191:                pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
                    192:                if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) {
                    193:                        pte = vtopte(va);
                    194:                        *pte &= ~L2_S_CACHE_MASK;
                    195:                        PTE_SYNC(pte);
                    196:                        /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of
                    197:                         *      waste.
                    198:                         */
                    199:                }
                    200:        }
                    201:        pmap_update(pmap_kernel());
                    202:
                    203:        return(0);
                    204: }
                    205:
                    206: void
                    207: sa11x1_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
                    208: {
                    209:
                    210:        if (bsh > (u_long)KERNEL_BASE)
                    211:                return;
                    212:
                    213:        uvm_km_free(kernel_map, bsh, size);
                    214: }
                    215:
                    216:
                    217: int
                    218: sa11x1_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
                    219:     bus_size_t size, bus_space_handle_t *nbshp)
                    220: {
                    221:
                    222:        *nbshp = bsh + offset;
                    223:        return (0);
                    224: }
                    225:
                    226: void
                    227: sa11x1_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
                    228:     bus_size_t len, int flags)
                    229: {
                    230:
                    231:        /* Nothing to do. */
                    232: }
                    233:
                    234: void *
                    235: sa11x1_bs_vaddr(void *t, bus_space_handle_t bsh)
                    236: {
                    237:
                    238:        return ((void *)bsh);
                    239: }
                    240:
                    241:
                    242: int
                    243: sa11x1_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
                    244:     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
                    245:     bus_addr_t *bpap, bus_space_handle_t *bshp)
                    246: {
                    247:
                    248:        panic("sa11x1_io_bs_alloc(): not implemented");
                    249: }
                    250:
                    251: void
                    252: sa11x1_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
                    253: {
                    254:
                    255:        panic("sa11x1_io_bs_free(): not implemented");
1.2     ! nbrk      256: }
        !           257:
        !           258: uint8_t
        !           259: sa11x1_h_bs_r_1(void *t, bus_space_handle_t bsh, bus_size_t addr)
        !           260: {
        !           261:        return( bus_space_read_4((bus_space_tag_t)t, bsh, addr) & 0xff );
1.1       nbrk      262: }
                    263:

CVSweb