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/mips/rmi/bus_space_rmi_pci.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 /*-
    2  * Copyright (c) 2009 RMI Corporation
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/8.4/sys/mips/rmi/bus_space_rmi_pci.c 215938 2010-11-27 12:26:40Z jchandra $
   27  */
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD: releng/8.4/sys/mips/rmi/bus_space_rmi_pci.c 215938 2010-11-27 12:26:40Z jchandra $");
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/bus.h>
   34 #include <sys/kernel.h>
   35 #include <sys/endian.h>
   36 #include <sys/malloc.h>
   37 #include <sys/ktr.h>
   38 
   39 #include <vm/vm.h>
   40 #include <vm/pmap.h>
   41 #include <vm/vm_kern.h>
   42 #include <vm/vm_extern.h>
   43 
   44 #include <machine/bus.h>
   45 #include <machine/cache.h>
   46 
   47 static int 
   48 rmi_pci_bus_space_map(void *t, bus_addr_t addr,
   49     bus_size_t size, int flags,
   50     bus_space_handle_t * bshp);
   51 
   52 static void 
   53 rmi_pci_bus_space_unmap(void *t, bus_space_handle_t bsh,
   54     bus_size_t size);
   55 
   56 static int 
   57 rmi_pci_bus_space_subregion(void *t,
   58     bus_space_handle_t bsh,
   59     bus_size_t offset, bus_size_t size,
   60     bus_space_handle_t * nbshp);
   61 
   62 static u_int8_t 
   63 rmi_pci_bus_space_read_1(void *t,
   64     bus_space_handle_t handle,
   65     bus_size_t offset);
   66 
   67 static u_int16_t 
   68 rmi_pci_bus_space_read_2(void *t,
   69     bus_space_handle_t handle,
   70     bus_size_t offset);
   71 
   72 static u_int32_t 
   73 rmi_pci_bus_space_read_4(void *t,
   74     bus_space_handle_t handle,
   75     bus_size_t offset);
   76 
   77 static void 
   78 rmi_pci_bus_space_read_multi_1(void *t,
   79     bus_space_handle_t handle,
   80     bus_size_t offset, u_int8_t * addr,
   81     size_t count);
   82 
   83 static void 
   84 rmi_pci_bus_space_read_multi_2(void *t,
   85     bus_space_handle_t handle,
   86     bus_size_t offset, u_int16_t * addr,
   87     size_t count);
   88 
   89 static void 
   90 rmi_pci_bus_space_read_multi_4(void *t,
   91     bus_space_handle_t handle,
   92     bus_size_t offset, u_int32_t * addr,
   93     size_t count);
   94 
   95 static void 
   96 rmi_pci_bus_space_read_region_1(void *t,
   97     bus_space_handle_t bsh,
   98     bus_size_t offset, u_int8_t * addr,
   99     size_t count);
  100 
  101 static void 
  102 rmi_pci_bus_space_read_region_2(void *t,
  103     bus_space_handle_t bsh,
  104     bus_size_t offset, u_int16_t * addr,
  105     size_t count);
  106 
  107 static void 
  108 rmi_pci_bus_space_read_region_4(void *t,
  109     bus_space_handle_t bsh,
  110     bus_size_t offset, u_int32_t * addr,
  111     size_t count);
  112 
  113 static void 
  114 rmi_pci_bus_space_write_1(void *t,
  115     bus_space_handle_t handle,
  116     bus_size_t offset, u_int8_t value);
  117 
  118 static void 
  119 rmi_pci_bus_space_write_2(void *t,
  120     bus_space_handle_t handle,
  121     bus_size_t offset, u_int16_t value);
  122 
  123 static void 
  124 rmi_pci_bus_space_write_4(void *t,
  125     bus_space_handle_t handle,
  126     bus_size_t offset, u_int32_t value);
  127 
  128 static void 
  129 rmi_pci_bus_space_write_multi_1(void *t,
  130     bus_space_handle_t handle,
  131     bus_size_t offset,
  132     const u_int8_t * addr,
  133     size_t count);
  134 
  135 static void 
  136 rmi_pci_bus_space_write_multi_2(void *t,
  137     bus_space_handle_t handle,
  138     bus_size_t offset,
  139     const u_int16_t * addr,
  140     size_t count);
  141 
  142 static void 
  143 rmi_pci_bus_space_write_multi_4(void *t,
  144     bus_space_handle_t handle,
  145     bus_size_t offset,
  146     const u_int32_t * addr,
  147     size_t count);
  148 
  149 static void 
  150 rmi_pci_bus_space_write_region_2(void *t,
  151     bus_space_handle_t bsh,
  152     bus_size_t offset,
  153     const u_int16_t * addr,
  154     size_t count);
  155 
  156 static void 
  157 rmi_pci_bus_space_write_region_4(void *t,
  158     bus_space_handle_t bsh,
  159     bus_size_t offset,
  160     const u_int32_t * addr,
  161     size_t count);
  162 
  163 
  164 static void 
  165 rmi_pci_bus_space_set_region_2(void *t,
  166     bus_space_handle_t bsh,
  167     bus_size_t offset, u_int16_t value,
  168     size_t count);
  169 static void 
  170 rmi_pci_bus_space_set_region_4(void *t,
  171     bus_space_handle_t bsh,
  172     bus_size_t offset, u_int32_t value,
  173     size_t count);
  174 
  175 static void 
  176 rmi_pci_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused,
  177     bus_size_t offset __unused, bus_size_t len __unused, int flags);
  178 
  179 static void 
  180 rmi_pci_bus_space_copy_region_2(void *t,
  181     bus_space_handle_t bsh1,
  182     bus_size_t off1,
  183     bus_space_handle_t bsh2,
  184     bus_size_t off2, size_t count);
  185 
  186 u_int8_t 
  187 rmi_pci_bus_space_read_stream_1(void *t, bus_space_handle_t handle,
  188     bus_size_t offset);
  189 
  190 static u_int16_t 
  191 rmi_pci_bus_space_read_stream_2(void *t, bus_space_handle_t handle,
  192     bus_size_t offset);
  193 
  194 static u_int32_t 
  195 rmi_pci_bus_space_read_stream_4(void *t, bus_space_handle_t handle,
  196     bus_size_t offset);
  197 static void 
  198 rmi_pci_bus_space_read_multi_stream_1(void *t,
  199     bus_space_handle_t handle,
  200     bus_size_t offset, u_int8_t * addr,
  201     size_t count);
  202 
  203 static void 
  204 rmi_pci_bus_space_read_multi_stream_2(void *t,
  205     bus_space_handle_t handle,
  206     bus_size_t offset, u_int16_t * addr,
  207     size_t count);
  208 
  209 static void 
  210 rmi_pci_bus_space_read_multi_stream_4(void *t,
  211     bus_space_handle_t handle,
  212     bus_size_t offset, u_int32_t * addr,
  213     size_t count);
  214 
  215 void 
  216 rmi_pci_bus_space_write_stream_1(void *t, bus_space_handle_t bsh,
  217     bus_size_t offset, u_int8_t value);
  218 static void 
  219 rmi_pci_bus_space_write_stream_2(void *t, bus_space_handle_t handle,
  220     bus_size_t offset, u_int16_t value);
  221 
  222 static void 
  223 rmi_pci_bus_space_write_stream_4(void *t, bus_space_handle_t handle,
  224     bus_size_t offset, u_int32_t value);
  225 
  226 static void 
  227 rmi_pci_bus_space_write_multi_stream_1(void *t,
  228     bus_space_handle_t handle,
  229     bus_size_t offset,
  230     const u_int8_t * addr,
  231     size_t count);
  232 static void 
  233 rmi_pci_bus_space_write_multi_stream_2(void *t,
  234     bus_space_handle_t handle,
  235     bus_size_t offset,
  236     const u_int16_t * addr,
  237     size_t count);
  238 
  239 static void 
  240 rmi_pci_bus_space_write_multi_stream_4(void *t,
  241     bus_space_handle_t handle,
  242     bus_size_t offset,
  243     const u_int32_t * addr,
  244     size_t count);
  245 
  246 #define TODO() printf("XLR memory bus space function '%s' unimplemented\n", __func__)
  247 
  248 static struct bus_space local_rmi_pci_bus_space = {
  249         /* cookie */
  250         (void *)0,
  251 
  252         /* mapping/unmapping */
  253         rmi_pci_bus_space_map,
  254         rmi_pci_bus_space_unmap,
  255         rmi_pci_bus_space_subregion,
  256 
  257         /* allocation/deallocation */
  258         NULL,
  259         NULL,
  260 
  261         /* barrier */
  262         rmi_pci_bus_space_barrier,
  263 
  264         /* read (single) */
  265         rmi_pci_bus_space_read_1,
  266         rmi_pci_bus_space_read_2,
  267         rmi_pci_bus_space_read_4,
  268         NULL,
  269 
  270         /* read multiple */
  271         rmi_pci_bus_space_read_multi_1,
  272         rmi_pci_bus_space_read_multi_2,
  273         rmi_pci_bus_space_read_multi_4,
  274         NULL,
  275 
  276         /* read region */
  277         rmi_pci_bus_space_read_region_1,
  278         rmi_pci_bus_space_read_region_2,
  279         rmi_pci_bus_space_read_region_4,
  280         NULL,
  281 
  282         /* write (single) */
  283         rmi_pci_bus_space_write_1,
  284         rmi_pci_bus_space_write_2,
  285         rmi_pci_bus_space_write_4,
  286         NULL,
  287 
  288         /* write multiple */
  289         rmi_pci_bus_space_write_multi_1,
  290         rmi_pci_bus_space_write_multi_2,
  291         rmi_pci_bus_space_write_multi_4,
  292         NULL,
  293 
  294         /* write region */
  295         NULL,
  296         rmi_pci_bus_space_write_region_2,
  297         rmi_pci_bus_space_write_region_4,
  298         NULL,
  299 
  300         /* set multiple */
  301         NULL,
  302         NULL,
  303         NULL,
  304         NULL,
  305 
  306         /* set region */
  307         NULL,
  308         rmi_pci_bus_space_set_region_2,
  309         rmi_pci_bus_space_set_region_4,
  310         NULL,
  311 
  312         /* copy */
  313         NULL,
  314         rmi_pci_bus_space_copy_region_2,
  315         NULL,
  316         NULL,
  317 
  318         /* read (single) stream */
  319         rmi_pci_bus_space_read_stream_1,
  320         rmi_pci_bus_space_read_stream_2,
  321         rmi_pci_bus_space_read_stream_4,
  322         NULL,
  323 
  324         /* read multiple stream */
  325         rmi_pci_bus_space_read_multi_stream_1,
  326         rmi_pci_bus_space_read_multi_stream_2,
  327         rmi_pci_bus_space_read_multi_stream_4,
  328         NULL,
  329 
  330         /* read region stream */
  331         rmi_pci_bus_space_read_region_1,
  332         rmi_pci_bus_space_read_region_2,
  333         rmi_pci_bus_space_read_region_4,
  334         NULL,
  335 
  336         /* write (single) stream */
  337         rmi_pci_bus_space_write_stream_1,
  338         rmi_pci_bus_space_write_stream_2,
  339         rmi_pci_bus_space_write_stream_4,
  340         NULL,
  341 
  342         /* write multiple stream */
  343         rmi_pci_bus_space_write_multi_stream_1,
  344         rmi_pci_bus_space_write_multi_stream_2,
  345         rmi_pci_bus_space_write_multi_stream_4,
  346         NULL,
  347 
  348         /* write region stream */
  349         NULL,
  350         rmi_pci_bus_space_write_region_2,
  351         rmi_pci_bus_space_write_region_4,
  352         NULL,
  353 };
  354 
  355 /* generic bus_space tag */
  356 bus_space_tag_t rmi_pci_bus_space = &local_rmi_pci_bus_space;
  357 
  358 /*
  359  * Map a region of device bus space into CPU virtual address space.
  360  */
  361 static int
  362 rmi_pci_bus_space_map(void *t __unused, bus_addr_t addr,
  363     bus_size_t size __unused, int flags __unused,
  364     bus_space_handle_t * bshp)
  365 {
  366         *bshp = addr;
  367         return (0);
  368 }
  369 
  370 /*
  371  * Unmap a region of device bus space.
  372  */
  373 static void
  374 rmi_pci_bus_space_unmap(void *t __unused, bus_space_handle_t bsh __unused,
  375     bus_size_t size __unused)
  376 {
  377 }
  378 
  379 /*
  380  * Get a new handle for a subregion of an already-mapped area of bus space.
  381  */
  382 
  383 static int
  384 rmi_pci_bus_space_subregion(void *t __unused, bus_space_handle_t bsh,
  385     bus_size_t offset, bus_size_t size __unused,
  386     bus_space_handle_t * nbshp)
  387 {
  388         *nbshp = bsh + offset;
  389         return (0);
  390 }
  391 
  392 /*
  393  * Read a 1, 2, 4, or 8 byte quantity from bus space
  394  * described by tag/handle/offset.
  395  */
  396 
  397 static u_int8_t
  398 rmi_pci_bus_space_read_1(void *tag, bus_space_handle_t handle,
  399     bus_size_t offset)
  400 {
  401         return (u_int8_t) (*(volatile u_int8_t *)(handle + offset));
  402 }
  403 
  404 static u_int16_t
  405 rmi_pci_bus_space_read_2(void *tag, bus_space_handle_t handle,
  406     bus_size_t offset)
  407 {
  408         return bswap16((u_int16_t) (*(volatile u_int16_t *)(handle + offset)));
  409 }
  410 
  411 static u_int32_t
  412 rmi_pci_bus_space_read_4(void *tag, bus_space_handle_t handle,
  413     bus_size_t offset)
  414 {
  415         return bswap32((*(volatile u_int32_t *)(handle + offset)));
  416 }
  417 
  418 
  419 /*
  420  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
  421  * described by tag/handle/offset and copy into buffer provided.
  422  */
  423 static void
  424 rmi_pci_bus_space_read_multi_1(void *tag, bus_space_handle_t handle,
  425     bus_size_t offset, u_int8_t * addr, size_t count)
  426 {
  427         while (count--) {
  428                 *addr = (*(volatile u_int8_t *)(handle + offset));
  429                 addr++;
  430         }
  431 }
  432 
  433 static void
  434 rmi_pci_bus_space_read_multi_2(void *tag, bus_space_handle_t handle,
  435     bus_size_t offset, u_int16_t * addr, size_t count)
  436 {
  437 
  438         while (count--) {
  439                 *addr = *(volatile u_int16_t *)(handle + offset);
  440                 *addr = bswap16(*addr);
  441                 addr++;
  442         }
  443 }
  444 
  445 static void
  446 rmi_pci_bus_space_read_multi_4(void *tag, bus_space_handle_t handle,
  447     bus_size_t offset, u_int32_t * addr, size_t count)
  448 {
  449 
  450         while (count--) {
  451                 *addr = *(volatile u_int32_t *)(handle + offset);
  452                 *addr = bswap32(*addr);
  453                 addr++;
  454         }
  455 }
  456 
  457 /*
  458  * Write the 1, 2, 4, or 8 byte value `value' to bus space
  459  * described by tag/handle/offset.
  460  */
  461 
  462 static void
  463 rmi_pci_bus_space_write_1(void *tag, bus_space_handle_t handle,
  464     bus_size_t offset, u_int8_t value)
  465 {
  466         mips_sync();
  467         *(volatile u_int8_t *)(handle + offset) = value;
  468 }
  469 
  470 static void
  471 rmi_pci_bus_space_write_2(void *tag, bus_space_handle_t handle,
  472     bus_size_t offset, u_int16_t value)
  473 {
  474         mips_sync();
  475         *(volatile u_int16_t *)(handle + offset) = bswap16(value);
  476 }
  477 
  478 
  479 static void
  480 rmi_pci_bus_space_write_4(void *tag, bus_space_handle_t handle,
  481     bus_size_t offset, u_int32_t value)
  482 {
  483         mips_sync();
  484         *(volatile u_int32_t *)(handle + offset) = bswap32(value);
  485 }
  486 
  487 /*
  488  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
  489  * provided to bus space described by tag/handle/offset.
  490  */
  491 
  492 
  493 static void
  494 rmi_pci_bus_space_write_multi_1(void *tag, bus_space_handle_t handle,
  495     bus_size_t offset, const u_int8_t * addr, size_t count)
  496 {
  497         mips_sync();
  498         while (count--) {
  499                 (*(volatile u_int8_t *)(handle + offset)) = *addr;
  500                 addr++;
  501         }
  502 }
  503 
  504 static void
  505 rmi_pci_bus_space_write_multi_2(void *tag, bus_space_handle_t handle,
  506     bus_size_t offset, const u_int16_t * addr, size_t count)
  507 {
  508         mips_sync();
  509         while (count--) {
  510                 (*(volatile u_int16_t *)(handle + offset)) = bswap16(*addr);
  511                 addr++;
  512         }
  513 }
  514 
  515 static void
  516 rmi_pci_bus_space_write_multi_4(void *tag, bus_space_handle_t handle,
  517     bus_size_t offset, const u_int32_t * addr, size_t count)
  518 {
  519         mips_sync();
  520         while (count--) {
  521                 (*(volatile u_int32_t *)(handle + offset)) = bswap32(*addr);
  522                 addr++;
  523         }
  524 }
  525 
  526 /*
  527  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
  528  * by tag/handle starting at `offset'.
  529  */
  530 
  531 static void
  532 rmi_pci_bus_space_set_region_2(void *t, bus_space_handle_t bsh,
  533     bus_size_t offset, u_int16_t value, size_t count)
  534 {
  535         bus_addr_t addr = bsh + offset;
  536 
  537         for (; count != 0; count--, addr += 2)
  538                 (*(volatile u_int16_t *)(addr)) = value;
  539 }
  540 
  541 static void
  542 rmi_pci_bus_space_set_region_4(void *t, bus_space_handle_t bsh,
  543     bus_size_t offset, u_int32_t value, size_t count)
  544 {
  545         bus_addr_t addr = bsh + offset;
  546 
  547         for (; count != 0; count--, addr += 4)
  548                 (*(volatile u_int32_t *)(addr)) = value;
  549 }
  550 
  551 
  552 /*
  553  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
  554  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
  555  */
  556 static void
  557 rmi_pci_bus_space_copy_region_2(void *t, bus_space_handle_t bsh1,
  558     bus_size_t off1, bus_space_handle_t bsh2,
  559     bus_size_t off2, size_t count)
  560 {
  561         TODO();
  562 }
  563 
  564 /*
  565  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
  566  * described by tag/handle/offset and copy into buffer provided.
  567  */
  568 
  569 u_int8_t
  570 rmi_pci_bus_space_read_stream_1(void *t, bus_space_handle_t handle,
  571     bus_size_t offset)
  572 {
  573 
  574         return *((volatile u_int8_t *)(handle + offset));
  575 }
  576 
  577 
  578 static u_int16_t
  579 rmi_pci_bus_space_read_stream_2(void *t, bus_space_handle_t handle,
  580     bus_size_t offset)
  581 {
  582         return *(volatile u_int16_t *)(handle + offset);
  583 }
  584 
  585 
  586 static u_int32_t
  587 rmi_pci_bus_space_read_stream_4(void *t, bus_space_handle_t handle,
  588     bus_size_t offset)
  589 {
  590         return (*(volatile u_int32_t *)(handle + offset));
  591 }
  592 
  593 
  594 static void
  595 rmi_pci_bus_space_read_multi_stream_1(void *tag, bus_space_handle_t handle,
  596     bus_size_t offset, u_int8_t * addr, size_t count)
  597 {
  598         while (count--) {
  599                 *addr = (*(volatile u_int8_t *)(handle + offset));
  600                 addr++;
  601         }
  602 }
  603 
  604 static void
  605 rmi_pci_bus_space_read_multi_stream_2(void *tag, bus_space_handle_t handle,
  606     bus_size_t offset, u_int16_t * addr, size_t count)
  607 {
  608         while (count--) {
  609                 *addr = (*(volatile u_int16_t *)(handle + offset));
  610                 addr++;
  611         }
  612 }
  613 
  614 static void
  615 rmi_pci_bus_space_read_multi_stream_4(void *tag, bus_space_handle_t handle,
  616     bus_size_t offset, u_int32_t * addr, size_t count)
  617 {
  618         while (count--) {
  619                 *addr = (*(volatile u_int32_t *)(handle + offset));
  620                 addr++;
  621         }
  622 }
  623 
  624 
  625 
  626 /*
  627  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
  628  * described by tag/handle and starting at `offset' and copy into
  629  * buffer provided.
  630  */
  631 void
  632 rmi_pci_bus_space_read_region_1(void *t, bus_space_handle_t bsh,
  633     bus_size_t offset, u_int8_t * addr, size_t count)
  634 {
  635         bus_addr_t baddr = bsh + offset;
  636 
  637         while (count--) {
  638                 *addr++ = (*(volatile u_int8_t *)(baddr));
  639                 baddr += 1;
  640         }
  641 }
  642 
  643 void
  644 rmi_pci_bus_space_read_region_2(void *t, bus_space_handle_t bsh,
  645     bus_size_t offset, u_int16_t * addr, size_t count)
  646 {
  647         bus_addr_t baddr = bsh + offset;
  648 
  649         while (count--) {
  650                 *addr++ = (*(volatile u_int16_t *)(baddr));
  651                 baddr += 2;
  652         }
  653 }
  654 
  655 void
  656 rmi_pci_bus_space_read_region_4(void *t, bus_space_handle_t bsh,
  657     bus_size_t offset, u_int32_t * addr, size_t count)
  658 {
  659         bus_addr_t baddr = bsh + offset;
  660 
  661         while (count--) {
  662                 *addr++ = (*(volatile u_int32_t *)(baddr));
  663                 baddr += 4;
  664         }
  665 }
  666 
  667 
  668 void
  669 rmi_pci_bus_space_write_stream_1(void *t, bus_space_handle_t handle,
  670     bus_size_t offset, u_int8_t value)
  671 {
  672         mips_sync();
  673         *(volatile u_int8_t *)(handle + offset) = value;
  674 }
  675 
  676 static void
  677 rmi_pci_bus_space_write_stream_2(void *t, bus_space_handle_t handle,
  678     bus_size_t offset, u_int16_t value)
  679 {
  680         mips_sync();
  681         *(volatile u_int16_t *)(handle + offset) = value;
  682 }
  683 
  684 
  685 static void
  686 rmi_pci_bus_space_write_stream_4(void *t, bus_space_handle_t handle,
  687     bus_size_t offset, u_int32_t value)
  688 {
  689         mips_sync();
  690         *(volatile u_int32_t *)(handle + offset) = value;
  691 }
  692 
  693 
  694 static void
  695 rmi_pci_bus_space_write_multi_stream_1(void *tag, bus_space_handle_t handle,
  696     bus_size_t offset, const u_int8_t * addr, size_t count)
  697 {
  698         mips_sync();
  699         while (count--) {
  700                 (*(volatile u_int8_t *)(handle + offset)) = *addr;
  701                 addr++;
  702         }
  703 }
  704 
  705 static void
  706 rmi_pci_bus_space_write_multi_stream_2(void *tag, bus_space_handle_t handle,
  707     bus_size_t offset, const u_int16_t * addr, size_t count)
  708 {
  709         mips_sync();
  710         while (count--) {
  711                 (*(volatile u_int16_t *)(handle + offset)) = *addr;
  712                 addr++;
  713         }
  714 }
  715 
  716 static void
  717 rmi_pci_bus_space_write_multi_stream_4(void *tag, bus_space_handle_t handle,
  718     bus_size_t offset, const u_int32_t * addr, size_t count)
  719 {
  720         mips_sync();
  721         while (count--) {
  722                 (*(volatile u_int32_t *)(handle + offset)) = *addr;
  723                 addr++;
  724         }
  725 }
  726 
  727 void
  728 rmi_pci_bus_space_write_region_2(void *t,
  729     bus_space_handle_t bsh,
  730     bus_size_t offset,
  731     const u_int16_t * addr,
  732     size_t count)
  733 {
  734         bus_addr_t baddr = (bus_addr_t) bsh + offset;
  735 
  736         while (count--) {
  737                 (*(volatile u_int16_t *)(baddr)) = *addr;
  738                 addr++;
  739                 baddr += 2;
  740         }
  741 }
  742 
  743 void
  744 rmi_pci_bus_space_write_region_4(void *t, bus_space_handle_t bsh,
  745     bus_size_t offset, const u_int32_t * addr, size_t count)
  746 {
  747         bus_addr_t baddr = bsh + offset;
  748 
  749         while (count--) {
  750                 (*(volatile u_int32_t *)(baddr)) = *addr;
  751                 addr++;
  752                 baddr += 4;
  753         }
  754 }
  755 
  756 static void
  757 rmi_pci_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused,
  758     bus_size_t offset __unused, bus_size_t len __unused, int flags)
  759 {
  760 
  761 }

Cache object: 35bd66552075d961e4a9b9467b2ef994


[ 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.