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/sun4v/include/bus.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
    3  * All rights reserved.
    4  *
    5  * This code is derived from software contributed to The NetBSD Foundation
    6  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    7  * NASA Ames Research Center.
    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 by the NetBSD
   20  *      Foundation, Inc. and its contributors.
   21  * 4. Neither the name of The NetBSD Foundation nor the names of its
   22  *    contributors may be used to endorse or promote products derived
   23  *    from this software without specific prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   26  * ``AS IS'' AND 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 THE FOUNDATION OR CONTRIBUTORS
   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  * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved.
   39  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
   40  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
   41  *
   42  * Redistribution and use in source and binary forms, with or without
   43  * modification, are permitted provided that the following conditions
   44  * are met:
   45  * 1. Redistributions of source code must retain the above copyright
   46  *    notice, this list of conditions and the following disclaimer.
   47  * 2. Redistributions in binary form must reproduce the above copyright
   48  *    notice, this list of conditions and the following disclaimer in the
   49  *    documentation and/or other materials provided with the distribution.
   50  * 3. All advertising materials mentioning features or use of this software
   51  *    must display the following acknowledgement:
   52  *      This product includes software developed by Christopher G. Demetriou
   53  *      for the NetBSD Project.
   54  * 4. The name of the author may not be used to endorse or promote products
   55  *    derived from this software without specific prior written permission
   56  *
   57  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   60  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   61  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   62  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   63  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   64  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   65  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   66  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   67  *
   68  *      from: NetBSD: bus.h,v 1.28 2001/07/19 15:32:19 thorpej Exp
   69  *      and
   70  *      from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09
   71  *
   72  * $FreeBSD$
   73  */
   74 
   75 #ifndef _MACHINE_BUS_H_
   76 #define _MACHINE_BUS_H_
   77 
   78 #ifdef BUS_SPACE_DEBUG
   79 #include <sys/ktr.h>
   80 #endif
   81 
   82 #include <machine/_bus.h>
   83 #include <machine/cpufunc.h>
   84 #include <machine/upa.h>
   85 
   86 /*
   87  * Nexus and SBus spaces are non-cached and big endian
   88  * (except for RAM and PROM)
   89  *
   90  * PCI spaces are non-cached and little endian
   91  */
   92 #define NEXUS_BUS_SPACE         0
   93 #define SBUS_BUS_SPACE          1
   94 #define PCI_CONFIG_BUS_SPACE    2
   95 #define PCI_IO_BUS_SPACE        3
   96 #define PCI_MEMORY_BUS_SPACE    4
   97 #define LAST_BUS_SPACE          5
   98 
   99 extern int bus_type_asi[];
  100 extern int bus_stream_asi[];
  101 
  102 #define __BUS_SPACE_HAS_STREAM_METHODS  1
  103 
  104 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
  105 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
  106 #define BUS_SPACE_MAXSIZE       0xFFFFFFFFFFFFFFFF
  107 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
  108 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
  109 #define BUS_SPACE_MAXADDR       0xFFFFFFFF
  110 
  111 #define BUS_SPACE_UNRESTRICTED  (~0)
  112 
  113 /*
  114  * Access methods for bus resources and address space.
  115  */
  116 struct bus_space_tag {
  117         void            *bst_cookie;
  118         bus_space_tag_t bst_parent;
  119         int             bst_type;
  120 
  121         void            (*bst_bus_barrier)(bus_space_tag_t, bus_space_handle_t,
  122             bus_size_t, bus_size_t, int);
  123 };
  124 
  125 /*
  126  * Bus space function prototypes.
  127  */
  128 static void bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t,
  129     bus_size_t, int);
  130 static int bus_space_subregion(bus_space_tag_t, bus_space_handle_t,
  131     bus_size_t, bus_size_t, bus_space_handle_t *);
  132 
  133 /*
  134  * Map a region of device bus space into CPU virtual address space.
  135  */
  136 
  137 static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
  138                                   bus_size_t size, int flags,
  139                                   bus_space_handle_t *bshp);
  140 
  141 static __inline int
  142 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
  143               bus_size_t size __unused, int flags __unused,
  144               bus_space_handle_t *bshp)
  145 {
  146 
  147         *bshp = addr;
  148         return (0);
  149 }
  150 
  151 /*
  152  * Unmap a region of device bus space.
  153  */
  154 static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
  155                                      bus_size_t size);
  156 
  157 static __inline void
  158 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
  159                 bus_size_t size __unused)
  160 {
  161 }
  162 
  163 /* This macro finds the first "upstream" implementation of method `f' */
  164 #define _BS_CALL(t,f)                                                   \
  165         while (t->f == NULL)                                            \
  166                 t = t->bst_parent;                                              \
  167         return (*(t)->f)
  168 
  169 static __inline void
  170 bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  171     bus_size_t s, int f)
  172 {
  173         _BS_CALL(t, bst_bus_barrier)(t, h, o, s, f);
  174 }
  175 
  176 static __inline int
  177 bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  178     bus_size_t s, bus_space_handle_t *hp)
  179 {
  180         *hp = h + o;
  181         return (0);
  182 }
  183 
  184 /* flags for bus space map functions */
  185 #define BUS_SPACE_MAP_CACHEABLE         0x0001
  186 #define BUS_SPACE_MAP_LINEAR            0x0002
  187 #define BUS_SPACE_MAP_READONLY          0x0004
  188 #define BUS_SPACE_MAP_PREFETCHABLE      0x0008
  189 /* placeholders for bus functions... */
  190 #define BUS_SPACE_MAP_BUS1              0x0100
  191 #define BUS_SPACE_MAP_BUS2              0x0200
  192 #define BUS_SPACE_MAP_BUS3              0x0400
  193 #define BUS_SPACE_MAP_BUS4              0x0800
  194 
  195 /* flags for bus_space_barrier() */
  196 #define BUS_SPACE_BARRIER_READ          0x01    /* force read barrier */
  197 #define BUS_SPACE_BARRIER_WRITE         0x02    /* force write barrier */
  198 
  199 #ifdef BUS_SPACE_DEBUG
  200 #define KTR_BUS                         KTR_CT2
  201 #define BUS_HANDLE_MIN                  UPA_MEMSTART
  202 #define __BUS_DEBUG_ACCESS(h, o, desc, sz) do {                         \
  203         CTR4(KTR_BUS, "bus space: %s %d: handle %#lx, offset %#lx",     \
  204             (desc), (sz), (h), (o));                                    \
  205         if ((h) + (o) < BUS_HANDLE_MIN)                                 \
  206                 panic("bus space access at %#lx out of range",          \
  207                     (h) + (o));                                         \
  208 } while (0)
  209 #else
  210 #define __BUS_DEBUG_ACCESS(h, o, desc, sz)
  211 #endif
  212 
  213 static __inline uint8_t
  214 bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  215 {
  216 
  217         __BUS_DEBUG_ACCESS(h, o, "read", 1);
  218         return (lduba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  219 }
  220 
  221 static __inline uint16_t
  222 bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  223 {
  224 
  225         __BUS_DEBUG_ACCESS(h, o, "read", 2);
  226         return (lduha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  227 }
  228 
  229 static __inline uint32_t
  230 bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  231 {
  232 
  233         __BUS_DEBUG_ACCESS(h, o, "read", 4);
  234         return (lduwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  235 }
  236 
  237 static __inline uint64_t
  238 bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  239 {
  240 
  241         __BUS_DEBUG_ACCESS(h, o, "read", 8);
  242         return (ldxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  243 }
  244 
  245 static __inline void
  246 bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  247     uint8_t *a, size_t c)
  248 {
  249 
  250         while (c-- > 0)
  251                 *a++ = bus_space_read_1(t, h, o);
  252 }
  253 
  254 static __inline void
  255 bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  256     uint16_t *a, size_t c)
  257 {
  258 
  259         while (c-- > 0)
  260                 *a++ = bus_space_read_2(t, h, o);
  261 }
  262 
  263 static __inline void
  264 bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  265     uint32_t *a, size_t c)
  266 {
  267 
  268         while (c-- > 0)
  269                 *a++ = bus_space_read_4(t, h, o);
  270 }
  271 
  272 static __inline void
  273 bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  274     uint64_t *a, size_t c)
  275 {
  276 
  277         while (c-- > 0)
  278                 *a++ = bus_space_read_8(t, h, o);
  279 }
  280 
  281 static __inline void
  282 bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  283     uint8_t v)
  284 {
  285 
  286         __BUS_DEBUG_ACCESS(h, o, "write", 1);
  287         stba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  288 }
  289 
  290 static __inline void
  291 bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  292     uint16_t v)
  293 {
  294 
  295         __BUS_DEBUG_ACCESS(h, o, "write", 2);
  296         stha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  297 }
  298 
  299 static __inline void
  300 bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  301     uint32_t v)
  302 {
  303 
  304         __BUS_DEBUG_ACCESS(h, o, "write", 4);
  305         stwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  306 }
  307 
  308 static __inline void
  309 bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  310     uint64_t v)
  311 {
  312 
  313         __BUS_DEBUG_ACCESS(h, o, "write", 8);
  314         stxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  315 }
  316 
  317 static __inline void
  318 bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  319     uint8_t *a, size_t c)
  320 {
  321 
  322         while (c-- > 0)
  323                 bus_space_write_1(t, h, o, *a++);
  324 }
  325 
  326 static __inline void
  327 bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  328     uint16_t *a, size_t c)
  329 {
  330 
  331         while (c-- > 0)
  332                 bus_space_write_2(t, h, o, *a++);
  333 }
  334 
  335 static __inline void
  336 bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  337     uint32_t *a, size_t c)
  338 {
  339 
  340         while (c-- > 0)
  341                 bus_space_write_4(t, h, o, *a++);
  342 }
  343 
  344 static __inline void
  345 bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  346     uint64_t *a, size_t c)
  347 {
  348 
  349         while (c-- > 0)
  350                 bus_space_write_8(t, h, o, *a++);
  351 }
  352 
  353 static __inline void
  354 bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  355     uint8_t v, size_t c)
  356 {
  357 
  358         while (c-- > 0)
  359                 bus_space_write_1(t, h, o, v);
  360 }
  361 
  362 static __inline void
  363 bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  364     uint16_t v, size_t c)
  365 {
  366 
  367         while (c-- > 0)
  368                 bus_space_write_2(t, h, o, v);
  369 }
  370 
  371 static __inline void
  372 bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  373     uint32_t v, size_t c)
  374 {
  375 
  376         while (c-- > 0)
  377                 bus_space_write_4(t, h, o, v);
  378 }
  379 
  380 static __inline void
  381 bus_space_set_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  382     uint64_t v, size_t c)
  383 {
  384 
  385         while (c-- > 0)
  386                 bus_space_write_8(t, h, o, v);
  387 }
  388 
  389 static __inline void
  390 bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  391     u_int8_t *a, bus_size_t c)
  392 {
  393         for (; c; a++, c--, o++)
  394                 *a = bus_space_read_1(t, h, o);
  395 }
  396 
  397 static __inline void
  398 bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  399     u_int16_t *a, bus_size_t c)
  400 {
  401         for (; c; a++, c--, o+=2)
  402                 *a = bus_space_read_2(t, h, o);
  403 }
  404 
  405 static __inline void
  406 bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  407     u_int32_t *a, bus_size_t c)
  408 {
  409         for (; c; a++, c--, o+=4)
  410                 *a = bus_space_read_4(t, h, o);
  411 }
  412 
  413 static __inline void
  414 bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  415     u_int64_t *a, bus_size_t c)
  416 {
  417         for (; c; a++, c--, o+=8)
  418                 *a = bus_space_read_8(t, h, o);
  419 }
  420 
  421 static __inline void
  422 bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  423     const u_int8_t *a, bus_size_t c)
  424 {
  425         for (; c; a++, c--, o++)
  426                 bus_space_write_1(t, h, o, *a);
  427 }
  428 
  429 static __inline void
  430 bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  431     const u_int16_t *a, bus_size_t c)
  432 {
  433         for (; c; a++, c--, o+=2)
  434                 bus_space_write_2(t, h, o, *a);
  435 }
  436 
  437 static __inline void
  438 bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  439     const u_int32_t *a, bus_size_t c)
  440 {
  441         for (; c; a++, c--, o+=4)
  442                 bus_space_write_4(t, h, o, *a);
  443 }
  444 
  445 static __inline void
  446 bus_space_write_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  447     const u_int64_t *a, bus_size_t c)
  448 {
  449         for (; c; a++, c--, o+=8)
  450                 bus_space_write_8(t, h, o, *a);
  451 }
  452 
  453 static __inline void
  454 bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  455     const u_int8_t v, bus_size_t c)
  456 {
  457         for (; c; c--, o++)
  458                 bus_space_write_1(t, h, o, v);
  459 }
  460 
  461 static __inline void
  462 bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  463     const u_int16_t v, bus_size_t c)
  464 {
  465         for (; c; c--, o+=2)
  466                 bus_space_write_2(t, h, o, v);
  467 }
  468 
  469 static __inline void
  470 bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  471     const u_int32_t v, bus_size_t c)
  472 {
  473         for (; c; c--, o+=4)
  474                 bus_space_write_4(t, h, o, v);
  475 }
  476 
  477 static __inline void
  478 bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  479     const u_int64_t v, bus_size_t c)
  480 {
  481         for (; c; c--, o+=8)
  482                 bus_space_write_8(t, h, o, v);
  483 }
  484 
  485 static __inline void
  486 bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1,
  487     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  488 {
  489         for (; c; c--, o1++, o2++)
  490             bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
  491 }
  492 
  493 static __inline void
  494 bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1,
  495     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  496 {
  497         for (; c; c--, o1+=2, o2+=2)
  498             bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
  499 }
  500 
  501 static __inline void
  502 bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1,
  503     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  504 {
  505         for (; c; c--, o1+=4, o2+=4)
  506             bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
  507 }
  508 
  509 static __inline void
  510 bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1,
  511     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  512 {
  513         for (; c; c--, o1+=8, o2+=8)
  514             bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
  515 }
  516 
  517 static __inline uint8_t
  518 bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  519 {
  520 
  521         __BUS_DEBUG_ACCESS(h, o, "read stream", 1);
  522         return (lduba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  523 }
  524 
  525 static __inline uint16_t
  526 bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  527 {
  528 
  529         __BUS_DEBUG_ACCESS(h, o, "read stream", 2);
  530         return (lduha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  531 }
  532 
  533 static __inline uint32_t
  534 bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  535 {
  536 
  537         __BUS_DEBUG_ACCESS(h, o, "read stream", 4);
  538         return (lduwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  539 }
  540 
  541 static __inline uint64_t
  542 bus_space_read_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  543 {
  544 
  545         __BUS_DEBUG_ACCESS(h, o, "read stream", 8);
  546         return (ldxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  547 }
  548 
  549 static __inline void
  550 bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  551     bus_size_t o, uint8_t *a, size_t c)
  552 {
  553 
  554         while (c-- > 0)
  555                 *a++ = bus_space_read_stream_1(t, h, o);
  556 }
  557 
  558 static __inline void
  559 bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  560     bus_size_t o, uint16_t *a, size_t c)
  561 {
  562 
  563         while (c-- > 0)
  564                 *a++ = bus_space_read_stream_2(t, h, o);
  565 }
  566 
  567 static __inline void
  568 bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  569     bus_size_t o, uint32_t *a, size_t c)
  570 {
  571 
  572         while (c-- > 0)
  573                 *a++ = bus_space_read_stream_4(t, h, o);
  574 }
  575 
  576 static __inline void
  577 bus_space_read_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  578     bus_size_t o, uint64_t *a, size_t c)
  579 {
  580 
  581         while (c-- > 0)
  582                 *a++ = bus_space_read_stream_8(t, h, o);
  583 }
  584 
  585 static __inline void
  586 bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  587     uint8_t v)
  588 {
  589 
  590         __BUS_DEBUG_ACCESS(h, o, "write stream", 1);
  591         stba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  592 }
  593 
  594 static __inline void
  595 bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  596     uint16_t v)
  597 {
  598 
  599         __BUS_DEBUG_ACCESS(h, o, "write stream", 2);
  600         stha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  601 }
  602 
  603 static __inline void
  604 bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  605     uint32_t v)
  606 {
  607 
  608         __BUS_DEBUG_ACCESS(h, o, "write stream", 4);
  609         stwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  610 }
  611 
  612 static __inline void
  613 bus_space_write_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  614     uint64_t v)
  615 {
  616 
  617         __BUS_DEBUG_ACCESS(h, o, "write stream", 8);
  618         stxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  619 }
  620 
  621 static __inline void
  622 bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  623     bus_size_t o, const uint8_t *a, size_t c)
  624 {
  625 
  626         while (c-- > 0)
  627                 bus_space_write_stream_1(t, h, o, *a++);
  628 }
  629 
  630 static __inline void
  631 bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  632     bus_size_t o, const uint16_t *a, size_t c)
  633 {
  634 
  635         while (c-- > 0)
  636                 bus_space_write_stream_2(t, h, o, *a++);
  637 }
  638 
  639 static __inline void
  640 bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  641     bus_size_t o, const uint32_t *a, size_t c)
  642 {
  643 
  644         while (c-- > 0)
  645                 bus_space_write_stream_4(t, h, o, *a++);
  646 }
  647 
  648 static __inline void
  649 bus_space_write_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  650     bus_size_t o, const uint64_t *a, size_t c)
  651 {
  652 
  653         while (c-- > 0)
  654                 bus_space_write_stream_8(t, h, o, *a++);
  655 }
  656 
  657 static __inline void
  658 bus_space_set_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  659     bus_size_t o, uint8_t v, size_t c)
  660 {
  661 
  662         while (c-- > 0)
  663                 bus_space_write_stream_1(t, h, o, v);
  664 }
  665 
  666 static __inline void
  667 bus_space_set_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  668     bus_size_t o, uint16_t v, size_t c)
  669 {
  670 
  671         while (c-- > 0)
  672                 bus_space_write_stream_2(t, h, o, v);
  673 }
  674 
  675 static __inline void
  676 bus_space_set_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  677     bus_size_t o, uint32_t v, size_t c)
  678 {
  679 
  680         while (c-- > 0)
  681                 bus_space_write_stream_4(t, h, o, v);
  682 }
  683 
  684 static __inline void
  685 bus_space_set_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  686     bus_size_t o, uint64_t v, size_t c)
  687 {
  688 
  689         while (c-- > 0)
  690                 bus_space_write_stream_8(t, h, o, v);
  691 }
  692 
  693 static __inline void
  694 bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  695     bus_size_t o, u_int8_t *a, bus_size_t c)
  696 {
  697 
  698         for (; c; a++, c--, o++)
  699                 *a = bus_space_read_stream_1(t, h, o);
  700 }
  701 
  702 static __inline void
  703 bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  704     bus_size_t o, u_int16_t *a, bus_size_t c)
  705 {
  706 
  707         for (; c; a++, c--, o+=2)
  708                 *a = bus_space_read_stream_2(t, h, o);
  709 }
  710 
  711 static __inline void
  712 bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  713     bus_size_t o, u_int32_t *a, bus_size_t c)
  714 {
  715 
  716         for (; c; a++, c--, o+=4)
  717                 *a = bus_space_read_stream_4(t, h, o);
  718 }
  719 
  720 static __inline void
  721 bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  722     bus_size_t o, u_int64_t *a, bus_size_t c)
  723 {
  724 
  725         for (; c; a++, c--, o+=8)
  726                 *a = bus_space_read_stream_8(t, h, o);
  727 }
  728 
  729 static __inline void
  730 bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  731     bus_size_t o, const u_int8_t *a, bus_size_t c)
  732 {
  733 
  734         for (; c; a++, c--, o++)
  735                 bus_space_write_stream_1(t, h, o, *a);
  736 }
  737 
  738 static __inline void
  739 bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  740     bus_size_t o, const u_int16_t *a, bus_size_t c)
  741 {
  742 
  743         for (; c; a++, c--, o+=2)
  744                 bus_space_write_stream_2(t, h, o, *a);
  745 }
  746 
  747 static __inline void
  748 bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  749     bus_size_t o, const u_int32_t *a, bus_size_t c)
  750 {
  751 
  752         for (; c; a++, c--, o+=4)
  753                 bus_space_write_stream_4(t, h, o, *a);
  754 }
  755 
  756 static __inline void
  757 bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  758     bus_size_t o, const u_int64_t *a, bus_size_t c)
  759 {
  760 
  761         for (; c; a++, c--, o+=8)
  762                 bus_space_write_stream_8(t, h, o, *a);
  763 }
  764 
  765 static __inline void
  766 bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  767     bus_size_t o, const u_int8_t v, bus_size_t c)
  768 {
  769 
  770         for (; c; c--, o++)
  771                 bus_space_write_stream_1(t, h, o, v);
  772 }
  773 
  774 static __inline void
  775 bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  776     bus_size_t o, const u_int16_t v, bus_size_t c)
  777 {
  778 
  779         for (; c; c--, o+=2)
  780                 bus_space_write_stream_2(t, h, o, v);
  781 }
  782 
  783 static __inline void
  784 bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  785     bus_size_t o, const u_int32_t v, bus_size_t c)
  786 {
  787 
  788         for (; c; c--, o+=4)
  789                 bus_space_write_stream_4(t, h, o, v);
  790 }
  791 
  792 static __inline void
  793 bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  794     bus_size_t o, const u_int64_t v, bus_size_t c)
  795 {
  796 
  797         for (; c; c--, o+=8)
  798                 bus_space_write_stream_8(t, h, o, v);
  799 }
  800 
  801 static __inline void
  802 bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1,
  803     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  804 {
  805 
  806         for (; c; c--, o1++, o2++)
  807             bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2,
  808                 o2));
  809 }
  810 
  811 static __inline void
  812 bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1,
  813     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  814 {
  815 
  816         for (; c; c--, o1+=2, o2+=2)
  817             bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2,
  818                 o2));
  819 }
  820 
  821 static __inline void
  822 bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1,
  823     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  824 {
  825 
  826         for (; c; c--, o1+=4, o2+=4)
  827             bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2,
  828                 o2));
  829 }
  830 
  831 static __inline void
  832 bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1,
  833     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  834 {
  835 
  836         for (; c; c--, o1+=8, o2+=8)
  837             bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2));
  838 }
  839 
  840 #include <machine/bus_dma.h>
  841 
  842 #endif /* !_MACHINE_BUS_H_ */

Cache object: 34a68b53a57d86510e66c003d7dbda65


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