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/sparc64/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: releng/8.2/sys/sparc64/include/bus.h 178860 2008-05-08 21:10:39Z marius $
   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 
   85 /*
   86  * Nexus and SBus spaces are non-cached and big endian
   87  * (except for RAM and PROM)
   88  *
   89  * PCI spaces are non-cached and little endian
   90  */
   91 #define NEXUS_BUS_SPACE         0
   92 #define SBUS_BUS_SPACE          1
   93 #define PCI_CONFIG_BUS_SPACE    2
   94 #define PCI_IO_BUS_SPACE        3
   95 #define PCI_MEMORY_BUS_SPACE    4
   96 #define LAST_BUS_SPACE          5
   97 
   98 extern const int bus_type_asi[];
   99 extern const int bus_stream_asi[];
  100 
  101 #define __BUS_SPACE_HAS_STREAM_METHODS  1
  102 
  103 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
  104 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
  105 #define BUS_SPACE_MAXSIZE       0xFFFFFFFFFFFFFFFF
  106 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
  107 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
  108 #define BUS_SPACE_MAXADDR       0xFFFFFFFF
  109 
  110 #define BUS_SPACE_UNRESTRICTED  (~0)
  111 
  112 struct bus_space_tag {
  113         void            *bst_cookie;
  114         bus_space_tag_t bst_parent;
  115         int             bst_type;
  116 
  117         void            (*bst_bus_barrier)(bus_space_tag_t, bus_space_handle_t,
  118                             bus_size_t, bus_size_t, int);
  119 };
  120 
  121 /*
  122  * Bus space function prototypes.
  123  */
  124 static void bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t,
  125     bus_size_t, int);
  126 static int bus_space_subregion(bus_space_tag_t, bus_space_handle_t,
  127     bus_size_t, bus_size_t, bus_space_handle_t *);
  128 
  129 /*
  130  * Map a region of device bus space into CPU virtual address space.
  131  */
  132 
  133 static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
  134     bus_size_t size, int flags, bus_space_handle_t *bshp);
  135 
  136 static __inline int
  137 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
  138     bus_size_t size __unused, int flags __unused, bus_space_handle_t *bshp)
  139 {
  140 
  141         *bshp = addr;
  142         return (0);
  143 }
  144 
  145 /*
  146  * Unmap a region of device bus space.
  147  */
  148 static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
  149     bus_size_t size);
  150 
  151 static __inline void
  152 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
  153     bus_size_t size __unused)
  154 {
  155 
  156 }
  157 
  158 /* This macro finds the first "upstream" implementation of method `f' */
  159 #define _BS_CALL(t,f)                                                   \
  160         while (t->f == NULL)                                            \
  161                 t = t->bst_parent;                                      \
  162         return (*(t)->f)
  163 
  164 static __inline void
  165 bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  166     bus_size_t s, int f)
  167 {
  168 
  169         _BS_CALL(t, bst_bus_barrier)(t, h, o, s, f);
  170 }
  171 
  172 static __inline int
  173 bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  174     bus_size_t s, bus_space_handle_t *hp)
  175 {
  176 
  177         *hp = h + o;
  178         return (0);
  179 }
  180 
  181 /* flags for bus space map functions */
  182 #define BUS_SPACE_MAP_CACHEABLE         0x0001
  183 #define BUS_SPACE_MAP_LINEAR            0x0002
  184 #define BUS_SPACE_MAP_READONLY          0x0004
  185 #define BUS_SPACE_MAP_PREFETCHABLE      0x0008
  186 /* placeholders for bus functions... */
  187 #define BUS_SPACE_MAP_BUS1              0x0100
  188 #define BUS_SPACE_MAP_BUS2              0x0200
  189 #define BUS_SPACE_MAP_BUS3              0x0400
  190 #define BUS_SPACE_MAP_BUS4              0x0800
  191 
  192 /* flags for bus_space_barrier() */
  193 #define BUS_SPACE_BARRIER_READ          0x01    /* force read barrier */
  194 #define BUS_SPACE_BARRIER_WRITE         0x02    /* force write barrier */
  195 
  196 #ifdef BUS_SPACE_DEBUG
  197 #define KTR_BUS                         KTR_CT2
  198 #define __BUS_DEBUG_ACCESS(h, o, desc, sz) do {                         \
  199         CTR4(KTR_BUS, "bus space: %s %d: handle %#lx, offset %#lx",     \
  200             (desc), (sz), (h), (o));                                    \
  201 } while (0)
  202 #else
  203 #define __BUS_DEBUG_ACCESS(h, o, desc, sz)
  204 #endif
  205 
  206 static __inline uint8_t
  207 bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  208 {
  209 
  210         __BUS_DEBUG_ACCESS(h, o, "read", 1);
  211         return (lduba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  212 }
  213 
  214 static __inline uint16_t
  215 bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  216 {
  217 
  218         __BUS_DEBUG_ACCESS(h, o, "read", 2);
  219         return (lduha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  220 }
  221 
  222 static __inline uint32_t
  223 bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  224 {
  225 
  226         __BUS_DEBUG_ACCESS(h, o, "read", 4);
  227         return (lduwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  228 }
  229 
  230 static __inline uint64_t
  231 bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  232 {
  233 
  234         __BUS_DEBUG_ACCESS(h, o, "read", 8);
  235         return (ldxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
  236 }
  237 
  238 static __inline void
  239 bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  240     uint8_t *a, size_t c)
  241 {
  242 
  243         while (c-- > 0)
  244                 *a++ = bus_space_read_1(t, h, o);
  245 }
  246 
  247 static __inline void
  248 bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  249     uint16_t *a, size_t c)
  250 {
  251 
  252         while (c-- > 0)
  253                 *a++ = bus_space_read_2(t, h, o);
  254 }
  255 
  256 static __inline void
  257 bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  258     uint32_t *a, size_t c)
  259 {
  260 
  261         while (c-- > 0)
  262                 *a++ = bus_space_read_4(t, h, o);
  263 }
  264 
  265 static __inline void
  266 bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  267     uint64_t *a, size_t c)
  268 {
  269 
  270         while (c-- > 0)
  271                 *a++ = bus_space_read_8(t, h, o);
  272 }
  273 
  274 static __inline void
  275 bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  276     uint8_t v)
  277 {
  278 
  279         __BUS_DEBUG_ACCESS(h, o, "write", 1);
  280         stba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  281 }
  282 
  283 static __inline void
  284 bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  285     uint16_t v)
  286 {
  287 
  288         __BUS_DEBUG_ACCESS(h, o, "write", 2);
  289         stha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  290 }
  291 
  292 static __inline void
  293 bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  294     uint32_t v)
  295 {
  296 
  297         __BUS_DEBUG_ACCESS(h, o, "write", 4);
  298         stwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  299 }
  300 
  301 static __inline void
  302 bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  303     uint64_t v)
  304 {
  305 
  306         __BUS_DEBUG_ACCESS(h, o, "write", 8);
  307         stxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
  308 }
  309 
  310 static __inline void
  311 bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  312     const uint8_t *a, size_t c)
  313 {
  314 
  315         while (c-- > 0)
  316                 bus_space_write_1(t, h, o, *a++);
  317 }
  318 
  319 static __inline void
  320 bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  321     const uint16_t *a, size_t c)
  322 {
  323 
  324         while (c-- > 0)
  325                 bus_space_write_2(t, h, o, *a++);
  326 }
  327 
  328 static __inline void
  329 bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  330     const uint32_t *a, size_t c)
  331 {
  332 
  333         while (c-- > 0)
  334                 bus_space_write_4(t, h, o, *a++);
  335 }
  336 
  337 static __inline void
  338 bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  339     const uint64_t *a, size_t c)
  340 {
  341 
  342         while (c-- > 0)
  343                 bus_space_write_8(t, h, o, *a++);
  344 }
  345 
  346 static __inline void
  347 bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  348     uint8_t v, size_t c)
  349 {
  350 
  351         while (c-- > 0)
  352                 bus_space_write_1(t, h, o, v);
  353 }
  354 
  355 static __inline void
  356 bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  357     uint16_t v, size_t c)
  358 {
  359 
  360         while (c-- > 0)
  361                 bus_space_write_2(t, h, o, v);
  362 }
  363 
  364 static __inline void
  365 bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  366     uint32_t v, size_t c)
  367 {
  368 
  369         while (c-- > 0)
  370                 bus_space_write_4(t, h, o, v);
  371 }
  372 
  373 static __inline void
  374 bus_space_set_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  375     uint64_t v, size_t c)
  376 {
  377 
  378         while (c-- > 0)
  379                 bus_space_write_8(t, h, o, v);
  380 }
  381 
  382 static __inline void
  383 bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  384     uint8_t *a, bus_size_t c)
  385 {
  386 
  387         for (; c; a++, c--, o++)
  388                 *a = bus_space_read_1(t, h, o);
  389 }
  390 
  391 static __inline void
  392 bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  393     uint16_t *a, bus_size_t c)
  394 {
  395 
  396         for (; c; a++, c--, o += 2)
  397                 *a = bus_space_read_2(t, h, o);
  398 }
  399 
  400 static __inline void
  401 bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  402     uint32_t *a, bus_size_t c)
  403 {
  404 
  405         for (; c; a++, c--, o += 4)
  406                 *a = bus_space_read_4(t, h, o);
  407 }
  408 
  409 static __inline void
  410 bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  411     uint64_t *a, bus_size_t c)
  412 {
  413 
  414         for (; c; a++, c--, o += 8)
  415                 *a = bus_space_read_8(t, h, o);
  416 }
  417 
  418 static __inline void
  419 bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  420     const uint8_t *a, bus_size_t c)
  421 {
  422 
  423         for (; c; a++, c--, o++)
  424                 bus_space_write_1(t, h, o, *a);
  425 }
  426 
  427 static __inline void
  428 bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  429     const uint16_t *a, bus_size_t c)
  430 {
  431 
  432         for (; c; a++, c--, o += 2)
  433                 bus_space_write_2(t, h, o, *a);
  434 }
  435 
  436 static __inline void
  437 bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  438     const uint32_t *a, bus_size_t c)
  439 {
  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 uint64_t *a, bus_size_t c)
  448 {
  449 
  450         for (; c; a++, c--, o += 8)
  451                 bus_space_write_8(t, h, o, *a);
  452 }
  453 
  454 static __inline void
  455 bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  456     const uint8_t v, bus_size_t c)
  457 {
  458 
  459         for (; c; c--, o++)
  460                 bus_space_write_1(t, h, o, v);
  461 }
  462 
  463 static __inline void
  464 bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  465     const uint16_t v, bus_size_t c)
  466 {
  467 
  468         for (; c; c--, o += 2)
  469                 bus_space_write_2(t, h, o, v);
  470 }
  471 
  472 static __inline void
  473 bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  474     const uint32_t v, bus_size_t c)
  475 {
  476 
  477         for (; c; c--, o += 4)
  478                 bus_space_write_4(t, h, o, v);
  479 }
  480 
  481 static __inline void
  482 bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  483     const uint64_t v, bus_size_t c)
  484 {
  485 
  486         for (; c; c--, o += 8)
  487                 bus_space_write_8(t, h, o, v);
  488 }
  489 
  490 static __inline void
  491 bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1,
  492     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  493 {
  494 
  495         for (; c; c--, o1++, o2++)
  496             bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
  497 }
  498 
  499 static __inline void
  500 bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1,
  501     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  502 {
  503 
  504         for (; c; c--, o1 += 2, o2 += 2)
  505             bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
  506 }
  507 
  508 static __inline void
  509 bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1,
  510     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  511 {
  512 
  513         for (; c; c--, o1 += 4, o2 += 4)
  514             bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
  515 }
  516 
  517 static __inline void
  518 bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1,
  519     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  520 {
  521 
  522         for (; c; c--, o1 += 8, o2 += 8)
  523             bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
  524 }
  525 
  526 static __inline uint8_t
  527 bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  528 {
  529 
  530         __BUS_DEBUG_ACCESS(h, o, "read stream", 1);
  531         return (lduba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  532 }
  533 
  534 static __inline uint16_t
  535 bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  536 {
  537 
  538         __BUS_DEBUG_ACCESS(h, o, "read stream", 2);
  539         return (lduha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  540 }
  541 
  542 static __inline uint32_t
  543 bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  544 {
  545 
  546         __BUS_DEBUG_ACCESS(h, o, "read stream", 4);
  547         return (lduwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  548 }
  549 
  550 static __inline uint64_t
  551 bus_space_read_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
  552 {
  553 
  554         __BUS_DEBUG_ACCESS(h, o, "read stream", 8);
  555         return (ldxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
  556 }
  557 
  558 static __inline void
  559 bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  560     bus_size_t o, uint8_t *a, size_t c)
  561 {
  562 
  563         while (c-- > 0)
  564                 *a++ = bus_space_read_stream_1(t, h, o);
  565 }
  566 
  567 static __inline void
  568 bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  569     bus_size_t o, uint16_t *a, size_t c)
  570 {
  571 
  572         while (c-- > 0)
  573                 *a++ = bus_space_read_stream_2(t, h, o);
  574 }
  575 
  576 static __inline void
  577 bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  578     bus_size_t o, uint32_t *a, size_t c)
  579 {
  580 
  581         while (c-- > 0)
  582                 *a++ = bus_space_read_stream_4(t, h, o);
  583 }
  584 
  585 static __inline void
  586 bus_space_read_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  587     bus_size_t o, uint64_t *a, size_t c)
  588 {
  589 
  590         while (c-- > 0)
  591                 *a++ = bus_space_read_stream_8(t, h, o);
  592 }
  593 
  594 static __inline void
  595 bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  596     uint8_t v)
  597 {
  598 
  599         __BUS_DEBUG_ACCESS(h, o, "write stream", 1);
  600         stba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  601 }
  602 
  603 static __inline void
  604 bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  605     uint16_t v)
  606 {
  607 
  608         __BUS_DEBUG_ACCESS(h, o, "write stream", 2);
  609         stha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  610 }
  611 
  612 static __inline void
  613 bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  614     uint32_t v)
  615 {
  616 
  617         __BUS_DEBUG_ACCESS(h, o, "write stream", 4);
  618         stwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  619 }
  620 
  621 static __inline void
  622 bus_space_write_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  623     uint64_t v)
  624 {
  625 
  626         __BUS_DEBUG_ACCESS(h, o, "write stream", 8);
  627         stxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
  628 }
  629 
  630 static __inline void
  631 bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  632     bus_size_t o, const uint8_t *a, size_t c)
  633 {
  634 
  635         while (c-- > 0)
  636                 bus_space_write_stream_1(t, h, o, *a++);
  637 }
  638 
  639 static __inline void
  640 bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  641     bus_size_t o, const uint16_t *a, size_t c)
  642 {
  643 
  644         while (c-- > 0)
  645                 bus_space_write_stream_2(t, h, o, *a++);
  646 }
  647 
  648 static __inline void
  649 bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  650     bus_size_t o, const uint32_t *a, size_t c)
  651 {
  652 
  653         while (c-- > 0)
  654                 bus_space_write_stream_4(t, h, o, *a++);
  655 }
  656 
  657 static __inline void
  658 bus_space_write_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  659     bus_size_t o, const uint64_t *a, size_t c)
  660 {
  661 
  662         while (c-- > 0)
  663                 bus_space_write_stream_8(t, h, o, *a++);
  664 }
  665 
  666 static __inline void
  667 bus_space_set_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  668     bus_size_t o, uint8_t v, size_t c)
  669 {
  670 
  671         while (c-- > 0)
  672                 bus_space_write_stream_1(t, h, o, v);
  673 }
  674 
  675 static __inline void
  676 bus_space_set_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  677     bus_size_t o, uint16_t v, size_t c)
  678 {
  679 
  680         while (c-- > 0)
  681                 bus_space_write_stream_2(t, h, o, v);
  682 }
  683 
  684 static __inline void
  685 bus_space_set_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  686     bus_size_t o, uint32_t v, size_t c)
  687 {
  688 
  689         while (c-- > 0)
  690                 bus_space_write_stream_4(t, h, o, v);
  691 }
  692 
  693 static __inline void
  694 bus_space_set_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  695     bus_size_t o, uint64_t v, size_t c)
  696 {
  697 
  698         while (c-- > 0)
  699                 bus_space_write_stream_8(t, h, o, v);
  700 }
  701 
  702 static __inline void
  703 bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  704     bus_size_t o, uint8_t *a, bus_size_t c)
  705 {
  706 
  707         for (; c; a++, c--, o++)
  708                 *a = bus_space_read_stream_1(t, h, o);
  709 }
  710 
  711 static __inline void
  712 bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  713     bus_size_t o, uint16_t *a, bus_size_t c)
  714 {
  715 
  716         for (; c; a++, c--, o += 2)
  717                 *a = bus_space_read_stream_2(t, h, o);
  718 }
  719 
  720 static __inline void
  721 bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  722     bus_size_t o, uint32_t *a, bus_size_t c)
  723 {
  724 
  725         for (; c; a++, c--, o += 4)
  726                 *a = bus_space_read_stream_4(t, h, o);
  727 }
  728 
  729 static __inline void
  730 bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  731     bus_size_t o, uint64_t *a, bus_size_t c)
  732 {
  733 
  734         for (; c; a++, c--, o += 8)
  735                 *a = bus_space_read_stream_8(t, h, o);
  736 }
  737 
  738 static __inline void
  739 bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  740     bus_size_t o, const uint8_t *a, bus_size_t c)
  741 {
  742 
  743         for (; c; a++, c--, o++)
  744                 bus_space_write_stream_1(t, h, o, *a);
  745 }
  746 
  747 static __inline void
  748 bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  749     bus_size_t o, const uint16_t *a, bus_size_t c)
  750 {
  751 
  752         for (; c; a++, c--, o += 2)
  753                 bus_space_write_stream_2(t, h, o, *a);
  754 }
  755 
  756 static __inline void
  757 bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  758     bus_size_t o, const uint32_t *a, bus_size_t c)
  759 {
  760 
  761         for (; c; a++, c--, o += 4)
  762                 bus_space_write_stream_4(t, h, o, *a);
  763 }
  764 
  765 static __inline void
  766 bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  767     bus_size_t o, const uint64_t *a, bus_size_t c)
  768 {
  769 
  770         for (; c; a++, c--, o += 8)
  771                 bus_space_write_stream_8(t, h, o, *a);
  772 }
  773 
  774 static __inline void
  775 bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
  776     bus_size_t o, const uint8_t v, bus_size_t c)
  777 {
  778 
  779         for (; c; c--, o++)
  780                 bus_space_write_stream_1(t, h, o, v);
  781 }
  782 
  783 static __inline void
  784 bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
  785     bus_size_t o, const uint16_t v, bus_size_t c)
  786 {
  787 
  788         for (; c; c--, o += 2)
  789                 bus_space_write_stream_2(t, h, o, v);
  790 }
  791 
  792 static __inline void
  793 bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
  794     bus_size_t o, const uint32_t v, bus_size_t c)
  795 {
  796 
  797         for (; c; c--, o += 4)
  798                 bus_space_write_stream_4(t, h, o, v);
  799 }
  800 
  801 static __inline void
  802 bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
  803     bus_size_t o, const uint64_t v, bus_size_t c)
  804 {
  805 
  806         for (; c; c--, o += 8)
  807                 bus_space_write_stream_8(t, h, o, v);
  808 }
  809 
  810 static __inline void
  811 bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1,
  812     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  813 {
  814 
  815         for (; c; c--, o1++, o2++)
  816             bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2,
  817                 o2));
  818 }
  819 
  820 static __inline void
  821 bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1,
  822     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  823 {
  824 
  825         for (; c; c--, o1 += 2, o2 += 2)
  826             bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2,
  827                 o2));
  828 }
  829 
  830 static __inline void
  831 bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1,
  832     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  833 {
  834 
  835         for (; c; c--, o1 += 4, o2 += 4)
  836             bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2,
  837                 o2));
  838 }
  839 
  840 static __inline void
  841 bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1,
  842     bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
  843 {
  844 
  845         for (; c; c--, o1 += 8, o2 += 8)
  846             bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2));
  847 }
  848 
  849 static __inline int
  850 bus_space_peek_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  851         uint8_t *a)
  852 {
  853 
  854         __BUS_DEBUG_ACCESS(h, o, "peek", 1);
  855         return (fasword8(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
  856 }
  857 
  858 static __inline int
  859 bus_space_peek_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  860         uint16_t *a)
  861 {
  862 
  863         __BUS_DEBUG_ACCESS(h, o, "peek", 2);
  864         return (fasword16(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
  865 }
  866 
  867 static __inline int
  868 bus_space_peek_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
  869         uint32_t *a)
  870 {
  871 
  872         __BUS_DEBUG_ACCESS(h, o, "peek", 4);
  873         return (fasword32(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
  874 }
  875 
  876 #include <machine/bus_dma.h>
  877 
  878 #endif /* !_MACHINE_BUS_H_ */

Cache object: 683d8a6c6f8755fea0fae6233060a1cb


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