Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/include Pull up revision 1.31, a...



details:   https://anonhg.NetBSD.org/src/rev/704b4cfb2710
branches:  sommerfeld_i386mp_1
changeset: 482374:704b4cfb2710
user:      he <he%NetBSD.org@localhost>
date:      Sat Mar 10 19:41:46 2001 +0000

description:
Pull up revision 1.31, approved by sommerfeld:
  Add the BUS_DMA_STREAMING flag.

diffstat:

 sys/arch/i386/include/bus.h |  1210 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1210 insertions(+), 0 deletions(-)

diffs (truncated from 1214 to 300 lines):

diff -r 616bec3ae8dd -r 704b4cfb2710 sys/arch/i386/include/bus.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/include/bus.h       Sat Mar 10 19:41:46 2001 +0000
@@ -0,0 +1,1210 @@
+/*     $NetBSD: bus.h,v 1.30.2.2 2001/03/10 19:41:46 he Exp $  */
+
+/*-
+ * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Christopher G. Demetriou
+ *     for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _I386_BUS_H_
+#define _I386_BUS_H_
+
+#include <machine/pio.h>
+
+#ifdef BUS_SPACE_DEBUG
+#include <sys/systm.h> /* for printf() prototype */
+/*
+ * Macros for sanity-checking the aligned-ness of pointers passed to
+ * bus space ops.  These are not strictly necessary on the x86, but
+ * could lead to performance improvements, and help catch problems
+ * with drivers that would creep up on other architectures.
+ */
+#define        __BUS_SPACE_ALIGNED_ADDRESS(p, t)                               \
+       ((((u_long)(p)) & (sizeof(t)-1)) == 0)
+
+#define        __BUS_SPACE_ADDRESS_SANITY(p, t, d)                             \
+({                                                                     \
+       if (__BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) {                 \
+               printf("%s 0x%lx not aligned to %d bytes %s:%d\n",      \
+                   d, (u_long)(p), sizeof(t), __FILE__, __LINE__);     \
+       }                                                               \
+       (void) 0;                                                       \
+})
+
+#define BUS_SPACE_ALIGNED_POINTER(p, t) __BUS_SPACE_ALIGNED_ADDRESS(p, t)
+#else
+#define        __BUS_SPACE_ADDRESS_SANITY(p,t,d)       (void) 0
+#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
+#endif /* BUS_SPACE_DEBUG */
+
+/*
+ * Values for the i386 bus space tag, not to be used directly by MI code.
+ */
+#define        I386_BUS_SPACE_IO       0       /* space is i/o space */
+#define I386_BUS_SPACE_MEM     1       /* space is mem space */
+
+#define __BUS_SPACE_HAS_STREAM_METHODS 1
+
+/*
+ * Bus address and size types
+ */
+typedef u_long bus_addr_t;
+typedef u_long bus_size_t;
+
+/*
+ * Access methods for bus resources and address space.
+ */
+typedef        int bus_space_tag_t;
+typedef        u_long bus_space_handle_t;
+
+/*
+ *     int bus_space_map  __P((bus_space_tag_t t, bus_addr_t addr,
+ *         bus_size_t size, int flags, bus_space_handle_t *bshp));
+ *
+ * Map a region of bus space.
+ */
+
+#define        BUS_SPACE_MAP_CACHEABLE         0x01
+#define        BUS_SPACE_MAP_LINEAR            0x02
+#define        BUS_SPACE_MAP_PREFETCHABLE      0x04
+
+int    i386_memio_map __P((bus_space_tag_t t, bus_addr_t addr,
+           bus_size_t size, int flags, bus_space_handle_t *bshp));
+/* like map, but without extent map checking/allocation */
+int    _i386_memio_map __P((bus_space_tag_t t, bus_addr_t addr,
+           bus_size_t size, int flags, bus_space_handle_t *bshp));
+
+#define        bus_space_map(t, a, s, f, hp)                                   \
+       i386_memio_map((t), (a), (s), (f), (hp))
+
+/*
+ *     int bus_space_unmap __P((bus_space_tag_t t,
+ *         bus_space_handle_t bsh, bus_size_t size));
+ *
+ * Unmap a region of bus space.
+ */
+
+void   i386_memio_unmap __P((bus_space_tag_t t, bus_space_handle_t bsh,
+           bus_size_t size));
+
+#define bus_space_unmap(t, h, s)                                       \
+       i386_memio_unmap((t), (h), (s))
+
+/*
+ *     int bus_space_subregion __P((bus_space_tag_t t,
+ *         bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
+ *         bus_space_handle_t *nbshp));
+ *
+ * Get a new handle for a subregion of an already-mapped area of bus space.
+ */
+
+int    i386_memio_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh,
+           bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp));
+
+#define bus_space_subregion(t, h, o, s, nhp)                           \
+       i386_memio_subregion((t), (h), (o), (s), (nhp))
+
+/*
+ *     int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
+ *         bus_addr_t rend, bus_size_t size, bus_size_t align,
+ *         bus_size_t boundary, int flags, bus_addr_t *addrp,
+ *         bus_space_handle_t *bshp));
+ *
+ * Allocate a region of bus space.
+ */
+
+int    i386_memio_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
+           bus_addr_t rend, bus_size_t size, bus_size_t align,
+           bus_size_t boundary, int flags, bus_addr_t *addrp,
+           bus_space_handle_t *bshp));
+
+#define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)                 \
+       i386_memio_alloc((t), (rs), (re), (s), (a), (b), (f), (ap), (hp))
+
+/*
+ *     int bus_space_free __P((bus_space_tag_t t,
+ *         bus_space_handle_t bsh, bus_size_t size));
+ *
+ * Free a region of bus space.
+ */
+
+void   i386_memio_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
+           bus_size_t size));
+
+#define bus_space_free(t, h, s)                                                \
+       i386_memio_free((t), (h), (s))
+
+/*
+ *     void *bus_space_vaddr __P((bus_space_tag_t, bus_space_handle_t));
+ *
+ * Get the kernel virtual address for the mapped bus space.
+ * Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
+ *  (XXX not enforced)
+ */
+#define bus_space_vaddr(t, h) \
+       ((t) == I386_BUS_SPACE_MEM ? (void *)(h) : (void *)0)
+
+/*
+ *     u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset));
+ *
+ * Read a 1, 2, 4, or 8 byte quantity from bus space
+ * described by tag/handle/offset.
+ */
+
+#define        bus_space_read_1(t, h, o)                                       \
+       ((t) == I386_BUS_SPACE_IO ? (inb((h) + (o))) :                  \
+           (*(volatile u_int8_t *)((h) + (o))))
+
+#define        bus_space_read_2(t, h, o)                                       \
+        (__BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"), \
+         ((t) == I386_BUS_SPACE_IO ? (inw((h) + (o))) :                \
+           (*(volatile u_int16_t *)((h) + (o)))))
+
+#define        bus_space_read_4(t, h, o)                                       \
+        (__BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"), \
+         ((t) == I386_BUS_SPACE_IO ? (inl((h) + (o))) :                \
+           (*(volatile u_int32_t *)((h) + (o)))))
+
+#define bus_space_read_stream_1 bus_space_read_1
+#define bus_space_read_stream_2 bus_space_read_2
+#define bus_space_read_stream_4 bus_space_read_4
+
+#if 0  /* Cause a link error for bus_space_read_8 */
+#define        bus_space_read_8(t, h, o)       !!! bus_space_read_8 unimplemented !!!
+#define        bus_space_read_stream_8(t, h, o)        \
+               !!! bus_space_read_stream_8 unimplemented !!!
+#endif
+
+/*
+ *     void bus_space_read_multi_N __P((bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, size_t count));
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+
+#define        bus_space_read_multi_1(t, h, o, a, c)                           \
+do {                                                                   \
+       if ((t) == I386_BUS_SPACE_IO) {                                 \
+               insb((h) + (o), (a), (c));                              \
+       } else {                                                        \
+               void *dummy1;                                           \
+               int dummy2;                                             \
+               int __x __asm__("%eax");                                \
+               __asm __volatile("                                      \
+                       cld                                     ;       \
+               1:      movb (%1),%%al                          ;       \
+                       stosb                                   ;       \
+                       loop 1b"                                :       \
+                   "=&a" (__x), "=D" (dummy1), "=c" (dummy2)   :       \
+                   "r" ((h) + (o)), "1" ((a)), "2" ((c))       :       \
+                   "memory");                                          \
+       }                                                               \
+} while (0)
+
+#define        bus_space_read_multi_2(t, h, o, a, c)                           \
+do {                                                                   \
+       __BUS_SPACE_ADDRESS_SANITY((a), u_int16_t, "buffer");           \
+       __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr");   \
+       if ((t) == I386_BUS_SPACE_IO) {                                 \
+               insw((h) + (o), (a), (c));                              \
+       } else {                                                        \
+               void *dummy1;                                           \
+               int dummy2;                                             \
+               int __x __asm__("%eax");                                \
+               __asm __volatile("                                      \
+                       cld                                     ;       \
+               1:      movw (%1),%%ax                          ;       \
+                       stosw                                   ;       \
+                       loop 1b"                                :       \
+                   "=&a" (__x), "=D" (dummy1), "=c" (dummy2)   :       \
+                   "r" ((h) + (o)), "1" ((a)), "2" ((c))       :       \
+                   "memory");                                          \
+       }                                                               \
+} while (0)
+
+#define        bus_space_read_multi_4(t, h, o, a, c)                           \
+do {                                                                   \
+       __BUS_SPACE_ADDRESS_SANITY((a), u_int32_t, "buffer");           \
+       __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr");   \
+       if ((t) == I386_BUS_SPACE_IO) {                                 \
+               insl((h) + (o), (a), (c));                              \
+       } else {                                                        \



Home | Main Index | Thread Index | Old Index