Annotation of sys/arch/arm/sa11x0/sa11x1_space.c, Revision 1.1
1.1 ! nbrk 1: /* $Id$ */
! 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:
! 80: /* Prototypes for all the bus_space structure functions */
! 81: bs_protos(sa11x1);
! 82: bs_protos(generic);
! 83: bs_protos(generic_armv4);
! 84: bs_protos(bs_notimpl);
! 85:
! 86: struct bus_space sa11x1_bs_tag = {
! 87: /* cookie */
! 88: (void *) 0,
! 89:
! 90: /* mapping/unmapping */
! 91: sa11x1_bs_map,
! 92: sa11x1_bs_unmap,
! 93: sa11x1_bs_subregion,
! 94:
! 95: /* allocation/deallocation */
! 96: sa11x1_bs_alloc, /* not implemented */
! 97: sa11x1_bs_free, /* not implemented */
! 98:
! 99: /* get kernel virtual address */
! 100: sa11x1_bs_vaddr,
! 101:
! 102: /* mmap */
! 103: bs_notimpl_bs_mmap,
! 104:
! 105: /* barrier */
! 106: sa11x1_bs_barrier,
! 107:
! 108: /* read (single) */
! 109: bs_notimpl_bs_r_1,
! 110: bs_notimpl_bs_r_2,
! 111: generic_bs_r_4,
! 112: bs_notimpl_bs_r_8,
! 113:
! 114: /* read multiple */
! 115: bs_notimpl_bs_rm_1,
! 116: bs_notimpl_bs_rm_2,
! 117: generic_bs_rm_4,
! 118: bs_notimpl_bs_rm_8,
! 119:
! 120: /* read region */
! 121: /* XXX only word-wide transactions on APB */
! 122: generic_bs_rr_1,
! 123: generic_armv4_bs_rr_2,
! 124: generic_bs_rr_4,
! 125: bs_notimpl_bs_rr_8,
! 126:
! 127: /* write (single) */
! 128: bs_notimpl_bs_w_1,
! 129: bs_notimpl_bs_w_2,
! 130: generic_bs_w_4,
! 131: bs_notimpl_bs_w_8,
! 132:
! 133: /* write multiple */
! 134: bs_notimpl_bs_wm_1,
! 135: bs_notimpl_bs_wm_2,
! 136: generic_bs_wm_4,
! 137: bs_notimpl_bs_wm_8,
! 138:
! 139: /* write region */
! 140: /* XXX only word-wide transactions on APB */
! 141: generic_bs_wr_1,
! 142: generic_armv4_bs_wr_2,
! 143: generic_bs_wr_4,
! 144: bs_notimpl_bs_wr_8,
! 145:
! 146: /* set multiple */
! 147: bs_notimpl_bs_sm_1,
! 148: bs_notimpl_bs_sm_2,
! 149: bs_notimpl_bs_sm_4,
! 150: bs_notimpl_bs_sm_8,
! 151:
! 152: /* set region */
! 153: generic_bs_sr_1,
! 154: generic_armv4_bs_sr_2,
! 155: bs_notimpl_bs_sr_4,
! 156: bs_notimpl_bs_sr_8,
! 157:
! 158: /* copy */
! 159: bs_notimpl_bs_c_1,
! 160: generic_armv4_bs_c_2,
! 161: bs_notimpl_bs_c_4,
! 162: bs_notimpl_bs_c_8,
! 163: };
! 164:
! 165: int
! 166: sa11x1_bs_map(void *t, bus_addr_t bpa, bus_size_t size,
! 167: int flag, bus_space_handle_t *bshp)
! 168: {
! 169: u_long startpa, endpa, pa;
! 170: vaddr_t va;
! 171: pt_entry_t *pte;
! 172:
! 173: /* XXX add our base address so we can use offsets in our address space */
! 174: bpa = *(bus_addr_t *)sa11x1_bs_tag.bs_cookie + bpa;
! 175:
! 176: startpa = trunc_page(bpa);
! 177: endpa = round_page(bpa + size);
! 178:
! 179: /* XXX use extent manager to check duplicate mapping */
! 180:
! 181: va = uvm_km_valloc(kernel_map, endpa - startpa);
! 182: if (! va)
! 183: return(ENOMEM);
! 184:
! 185: *bshp = (bus_space_handle_t)(va + (bpa - startpa));
! 186:
! 187: for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
! 188: pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
! 189: if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) {
! 190: pte = vtopte(va);
! 191: *pte &= ~L2_S_CACHE_MASK;
! 192: PTE_SYNC(pte);
! 193: /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of
! 194: * waste.
! 195: */
! 196: }
! 197: }
! 198: pmap_update(pmap_kernel());
! 199:
! 200: return(0);
! 201: }
! 202:
! 203: void
! 204: sa11x1_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
! 205: {
! 206:
! 207: if (bsh > (u_long)KERNEL_BASE)
! 208: return;
! 209:
! 210: uvm_km_free(kernel_map, bsh, size);
! 211: }
! 212:
! 213:
! 214: int
! 215: sa11x1_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
! 216: bus_size_t size, bus_space_handle_t *nbshp)
! 217: {
! 218:
! 219: *nbshp = bsh + offset;
! 220: return (0);
! 221: }
! 222:
! 223: void
! 224: sa11x1_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
! 225: bus_size_t len, int flags)
! 226: {
! 227:
! 228: /* Nothing to do. */
! 229: }
! 230:
! 231: void *
! 232: sa11x1_bs_vaddr(void *t, bus_space_handle_t bsh)
! 233: {
! 234:
! 235: return ((void *)bsh);
! 236: }
! 237:
! 238:
! 239: int
! 240: sa11x1_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
! 241: bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
! 242: bus_addr_t *bpap, bus_space_handle_t *bshp)
! 243: {
! 244:
! 245: panic("sa11x1_io_bs_alloc(): not implemented");
! 246: }
! 247:
! 248: void
! 249: sa11x1_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
! 250: {
! 251:
! 252: panic("sa11x1_io_bs_free(): not implemented");
! 253: }
! 254:
CVSweb