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

Cache object: 0ecc5ff9a6dbef76212021347eaf527f


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