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

Cache object: bfb9fd6bb2a4edff43beebe8ff5272c0


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