The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/xscale/i80321/i80321_space.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: i80321_space.c,v 1.6 2003/10/06 15:43:35 thorpej Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
    5  * All rights reserved.
    6  *
    7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
    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. All advertising materials mentioning features or use of this software
   18  *    must display the following acknowledgement:
   19  *      This product includes software developed for the NetBSD Project by
   20  *      Wasabi Systems, Inc.
   21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
   22  *    or promote products derived from this software without specific prior
   23  *    written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
   29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   35  * POSSIBILITY OF SUCH DAMAGE.
   36  */
   37 
   38 /*
   39  * bus_space functions for i80321 I/O Processor.
   40  */
   41 
   42 #include <sys/cdefs.h>
   43 __FBSDID("$FreeBSD$");
   44 
   45 #include <sys/param.h>
   46 #include <sys/systm.h>
   47 #include <sys/bus.h>
   48 
   49 #include <machine/pcb.h>
   50 
   51 #include <vm/vm.h>
   52 #include <vm/vm_kern.h>
   53 #include <vm/pmap.h>
   54 #include <vm/vm_page.h>
   55 #include <vm/vm_extern.h>
   56 
   57 #include <machine/bus.h>
   58 
   59 #include <arm/xscale/i80321/i80321reg.h>
   60 #include <arm/xscale/i80321/i80321var.h>
   61 
   62 /* Prototypes for all the bus_space structure functions */
   63 bs_protos(i80321);
   64 bs_protos(i80321_io);
   65 bs_protos(i80321_mem);
   66 bs_protos(generic);
   67 bs_protos(generic_armv4);
   68 
   69 /*
   70  * Template bus_space -- copied, and the bits that are NULL are
   71  * filled in.
   72  */
   73 const struct bus_space i80321_bs_tag_template = {
   74         /* cookie */
   75         (void *) 0,
   76 
   77         /* mapping/unmapping */
   78         NULL,
   79         NULL,
   80         i80321_bs_subregion,
   81 
   82         /* allocation/deallocation */
   83         NULL,
   84         NULL,
   85 
   86         /* barrier */
   87         i80321_bs_barrier,
   88 
   89         /* read (single) */
   90         generic_bs_r_1,
   91         generic_armv4_bs_r_2,
   92         generic_bs_r_4,
   93         NULL,
   94 
   95         /* read multiple */
   96         generic_bs_rm_1,
   97         generic_armv4_bs_rm_2,
   98         generic_bs_rm_4,
   99         NULL,
  100 
  101         /* read region */
  102         NULL,
  103         generic_armv4_bs_rr_2,
  104         generic_bs_rr_4,
  105         NULL,
  106 
  107         /* write (single) */
  108         generic_bs_w_1,
  109         generic_armv4_bs_w_2,
  110         generic_bs_w_4,
  111         NULL,
  112 
  113         /* write multiple */
  114         generic_bs_wm_1,
  115         generic_armv4_bs_wm_2,
  116         generic_bs_wm_4,
  117         NULL,
  118 
  119         /* write region */
  120         NULL,
  121         generic_armv4_bs_wr_2,
  122         generic_bs_wr_4,
  123         NULL,
  124 
  125         /* set multiple */
  126         NULL,
  127         NULL,
  128         NULL,
  129         NULL,
  130 
  131         /* set region */
  132         NULL,
  133         generic_armv4_bs_sr_2,
  134         generic_bs_sr_4,
  135         NULL,
  136 
  137         /* copy */
  138         NULL,
  139         generic_armv4_bs_c_2,
  140         NULL,
  141         NULL,
  142                 /* read (single) stream */
  143         generic_bs_r_1,
  144         generic_armv4_bs_r_2,
  145         generic_bs_r_4,
  146         NULL,
  147 
  148         /* read multiple stream */
  149         generic_bs_rm_1,
  150         generic_armv4_bs_rm_2,
  151         generic_bs_rm_4,
  152         NULL,
  153 
  154         /* read region stream */
  155         generic_bs_rr_1,
  156         generic_armv4_bs_rr_2,
  157         generic_bs_rr_4,
  158         NULL,
  159 
  160         /* write (single) stream */
  161         generic_bs_w_1,
  162         generic_armv4_bs_w_2,
  163         generic_bs_w_4,
  164         NULL,
  165 
  166         /* write multiple stream */
  167         generic_bs_wm_1,
  168         generic_armv4_bs_wm_2,
  169         generic_bs_wm_4,
  170         NULL,
  171 
  172         /* write region stream */
  173         NULL,
  174         generic_armv4_bs_wr_2,
  175         generic_bs_wr_4,
  176         NULL,
  177 
  178 };
  179 
  180 void
  181 i80321_bs_init(bus_space_tag_t bs, void *cookie)
  182 {
  183 
  184         *bs = i80321_bs_tag_template;
  185         bs->bs_cookie = cookie;
  186 }
  187 
  188 void
  189 i80321_io_bs_init(bus_space_tag_t bs, void *cookie)
  190 {
  191 
  192         *bs = i80321_bs_tag_template;
  193         bs->bs_cookie = cookie;
  194 
  195         bs->bs_map = i80321_io_bs_map;
  196         bs->bs_unmap = i80321_io_bs_unmap;
  197         bs->bs_alloc = i80321_io_bs_alloc;
  198         bs->bs_free = i80321_io_bs_free;
  199 
  200 }
  201 
  202 void
  203 i80321_mem_bs_init(bus_space_tag_t bs, void *cookie)
  204 {
  205 
  206         *bs = i80321_bs_tag_template;
  207         bs->bs_cookie = cookie;
  208 
  209         bs->bs_map = i80321_mem_bs_map;
  210         bs->bs_unmap = i80321_mem_bs_unmap;
  211         bs->bs_alloc = i80321_mem_bs_alloc;
  212         bs->bs_free = i80321_mem_bs_free;
  213 
  214 }
  215 
  216 /* *** Routines shared by i80321, PCI IO, and PCI MEM. *** */
  217 
  218 int
  219 i80321_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
  220     bus_size_t size, bus_space_handle_t *nbshp)
  221 {
  222 
  223         *nbshp = bsh + offset;
  224         return (0);
  225 }
  226 
  227 void
  228 i80321_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
  229     bus_size_t len, int flags)
  230 {
  231 
  232         /* Nothing to do. */
  233 }
  234 
  235 /* *** Routines for PCI IO. *** */
  236 
  237 extern struct i80321_softc *i80321_softc;
  238 int
  239 i80321_io_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
  240     bus_space_handle_t *bshp)
  241 {
  242         struct i80321_softc *sc = i80321_softc;
  243         vm_offset_t winvaddr;
  244         uint32_t busbase;
  245 
  246         if (bpa >= sc->sc_ioout_xlate &&
  247             bpa < (sc->sc_ioout_xlate + VERDE_OUT_XLATE_IO_WIN_SIZE)) {
  248                 busbase = sc->sc_ioout_xlate;
  249                 winvaddr = sc->sc_iow_vaddr;
  250         } else
  251                 return (EINVAL);
  252 
  253         if ((bpa + size) >= (busbase + VERDE_OUT_XLATE_IO_WIN_SIZE))
  254                 return (EINVAL);
  255 
  256         /*
  257          * Found the window -- PCI I/O space is mapped at a fixed
  258          * virtual address by board-specific code.  Translate the
  259          * bus address to the virtual address.
  260          */
  261         *bshp = winvaddr + (bpa - busbase);
  262 
  263         return (0);
  264 }
  265 
  266 void
  267 i80321_io_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
  268 {
  269 
  270         /* Nothing to do. */
  271 }
  272 
  273 int
  274 i80321_io_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
  275     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
  276     bus_addr_t *bpap, bus_space_handle_t *bshp)
  277 {
  278 
  279         panic("i80321_io_bs_alloc(): not implemented");
  280 }
  281 
  282 void    
  283 i80321_io_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
  284 {
  285 
  286         panic("i80321_io_bs_free(): not implemented");
  287 }
  288 
  289 
  290 /* *** Routines for PCI MEM. *** */
  291 extern int badaddr_read(void *, int, void *);
  292 int
  293 i80321_mem_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
  294     bus_space_handle_t *bshp)
  295 {
  296 
  297         vm_offset_t va;
  298         uint32_t busbase;
  299         vm_paddr_t pa, endpa, physbase;
  300 
  301         /*
  302          * Found the window -- PCI MEM space is not mapped by allocating
  303          * some kernel VA space and mapping the pages with pmap_enter().
  304          * pmap_enter() will map unmanaged pages as non-cacheable.
  305          */
  306         pa = trunc_page((bpa - busbase) + physbase);
  307         endpa = round_page(((bpa - busbase) + physbase) + size);
  308         pa = trunc_page(bpa);
  309         endpa = round_page(bpa + size);
  310 
  311         *bshp = va + (bpa & PAGE_MASK);
  312         *bshp = pa;
  313         *bshp = (vm_offset_t)pmap_mapdev(pa, endpa - pa);
  314                        
  315         return (0);
  316 }
  317 
  318 void
  319 i80321_mem_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
  320 {
  321         vm_offset_t va, endva;
  322 
  323         va = trunc_page((vm_offset_t)t);
  324         endva = va + round_page(size);
  325 
  326         /* Free the kernel virtual mapping. */
  327         kmem_free(kernel_map, va, endva - va);
  328 }
  329 
  330 int
  331 i80321_mem_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
  332     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
  333     bus_addr_t *bpap, bus_space_handle_t *bshp)
  334 {
  335 
  336         panic("i80321_mem_bs_alloc(): not implemented");
  337 }
  338 
  339 void    
  340 i80321_mem_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
  341 {
  342 
  343         panic("i80321_mem_bs_free(): not implemented");
  344 }

Cache object: c2c7234cb3ae6d730c66a210ef95ca25


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.