Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Move some macros back to sh3/include/bus_funcs.h from



details:   https://anonhg.NetBSD.org/src/rev/9e2f1a3561c6
branches:  trunk
changeset: 767645:9e2f1a3561c6
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Mon Jul 25 21:12:23 2011 +0000

description:
Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds.  Should fix other sh3 ports.

diffstat:

 sys/arch/landisk/conf/std.landisk |    4 +-
 sys/arch/sh3/conf/files.sh3       |    5 +-
 sys/arch/sh3/include/bus_funcs.h  |   45 ++-
 sys/arch/sh3/sh3/sh3_bus_space.c  |  570 +++++++++++++++++++++++++++++++++++++
 sys/arch/sh3/sh3/sh3_machdep.c    |  578 +-------------------------------------
 5 files changed, 623 insertions(+), 579 deletions(-)

diffs (truncated from 1271 to 300 lines):

diff -r 077ce352a9f1 -r 9e2f1a3561c6 sys/arch/landisk/conf/std.landisk
--- a/sys/arch/landisk/conf/std.landisk Mon Jul 25 20:34:07 2011 +0000
+++ b/sys/arch/landisk/conf/std.landisk Mon Jul 25 21:12:23 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: std.landisk,v 1.3 2008/02/02 05:53:40 uwe Exp $
+# $NetBSD: std.landisk,v 1.4 2011/07/25 21:12:23 dyoung Exp $
 #
 # standard, required NetBSD/landisk 'options'
 
@@ -15,4 +15,6 @@
 options        IOM_RAM_BEGIN=0x0c000000
 options        IOM_RAM_SIZE=0x04000000         # 64MB
 
+options                LANDISK
+
 makeoptions    DEFTEXTADDR="0x8c001000"
diff -r 077ce352a9f1 -r 9e2f1a3561c6 sys/arch/sh3/conf/files.sh3
--- a/sys/arch/sh3/conf/files.sh3       Mon Jul 25 20:34:07 2011 +0000
+++ b/sys/arch/sh3/conf/files.sh3       Mon Jul 25 21:12:23 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sh3,v 1.44 2011/06/12 03:35:45 rmind Exp $
+#      $NetBSD: files.sh3,v 1.45 2011/07/25 21:12:23 dyoung Exp $
 #
 
 defflag        opt_cputype.h           SH3 SH4
@@ -14,6 +14,8 @@
 defflag opt_cache.h            SH4_CACHE_WB_P1
 defflag opt_cache.h            SH4_CACHE_WB_U0_P0_P3
 
+defflag opt_landisk.h          LANDISK
+
 file   arch/sh3/sh3/cache.c
 file   arch/sh3/sh3/cache_sh3.c                sh3
 file   arch/sh3/sh3/cache_sh4.c                sh4
@@ -42,6 +44,7 @@
 file   arch/sh3/sh3/process_machdep.c
 file   arch/sh3/sh3/procfs_machdep.c           procfs
 file   arch/sh3/sh3/sh3_machdep.c
+file   arch/sh3/sh3/sh3_bus_space.c            !landisk
 file   arch/sh3/sh3/sys_machdep.c
 file   arch/sh3/sh3/syscall.c
 file   arch/sh3/sh3/vm_machdep.c
diff -r 077ce352a9f1 -r 9e2f1a3561c6 sys/arch/sh3/include/bus_funcs.h
--- a/sys/arch/sh3/include/bus_funcs.h  Mon Jul 25 20:34:07 2011 +0000
+++ b/sys/arch/sh3/include/bus_funcs.h  Mon Jul 25 21:12:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_funcs.h,v 1.3 2011/07/25 16:06:58 dyoung Exp $     */
+/*     $NetBSD: bus_funcs.h,v 1.4 2011/07/25 21:12:23 dyoung Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -86,6 +86,49 @@
     bus_size_t, bus_size_t, bus_space_handle_t *);
 
 /*
+ *     int bus_space_alloc(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.
+ */
+
+#define        bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)                  \
+       sh_memio_alloc((t), (rs), (re), (s), (a), (b), (f), (ap), (hp))
+
+/*
+ *     int bus_space_free(bus_space_tag_t t,
+ *         bus_space_handle_t bsh, bus_size_t size);
+ *
+ * Free a region of bus space.
+ */
+
+#define        bus_space_free(t, h, s)                                         \
+       sh_memio_free((t), (h), (s))
+
+/*
+ *     int bus_space_unmap(bus_space_tag_t t,
+ *         bus_space_handle_t bsh, bus_size_t size);
+ *
+ * Unmap a region of bus space.
+ */
+
+#define        bus_space_unmap(t, h, s)                                        \
+       sh_memio_unmap((t), (h), (s))
+
+/*
+ *     int bus_space_subregion(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.
+ */
+
+#define        bus_space_subregion(t, h, o, s, nhp)                            \
+       sh_memio_subregion((t), (h), (o), (s), (nhp))
+
+/*
  * Bus read/write barrier methods.
  *
  *     void bus_space_barrier(bus_space_tag_t tag,
diff -r 077ce352a9f1 -r 9e2f1a3561c6 sys/arch/sh3/sh3/sh3_bus_space.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sh3/sh3/sh3_bus_space.c  Mon Jul 25 21:12:23 2011 +0000
@@ -0,0 +1,570 @@
+/*     $NetBSD: sh3_bus_space.c,v 1.1 2011/07/25 21:12:23 dyoung Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997, 1998, 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum and 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.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: sh3_bus_space.c,v 1.1 2011/07/25 21:12:23 dyoung Exp $");
+
+#include <sys/types.h>
+#include <sys/bus.h>
+
+/*
+ *     u_intN_t bus_space_read_N(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.
+ */
+
+uint8_t
+bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset)
+{
+
+       return *(volatile uint8_t *)(bsh + offset);
+}
+
+uint16_t
+bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset)
+{
+
+       return bswap16(*(volatile uint16_t *)(bsh + offset));
+}
+
+uint32_t
+bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset)
+{
+
+       return bswap32(*(volatile uint32_t *)(bsh + offset));
+}
+
+uint16_t
+bus_space_read_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset)
+{
+
+       return *(volatile uint16_t *)(bsh + offset);
+}
+
+uint32_t
+bus_space_read_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset)
+{
+
+       return *(volatile uint32_t *)(bsh + offset);
+}
+
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_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.
+ */
+void
+bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint8_t *addr, bus_size_t count)
+{
+
+       while (count--)
+               *addr++ = bus_space_read_1(tag, bsh, offset);
+}
+
+void
+bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint16_t *addr, bus_size_t count)
+{
+
+       while (count--)
+               *addr++ = bus_space_read_2(tag, bsh, offset);
+}
+
+void
+bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint32_t *addr, bus_size_t count)
+{
+
+       while (count--)
+               *addr++ = bus_space_read_4(tag, bsh, offset);
+}
+
+void
+bus_space_read_multi_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint16_t *addr, bus_size_t count)
+{
+
+       while (count--)
+               *addr++ = *(volatile uint16_t *)(bsh + offset);
+}
+
+void
+bus_space_read_multi_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint32_t *addr, bus_size_t count)
+{
+
+       while (count--)
+               *addr++ = *(volatile uint32_t *)(bsh + offset);
+}
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided.
+ */
+void
+bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint8_t *addr, bus_size_t count)
+{
+       uint8_t *p = (uint8_t *)(bsh + offset);
+
+       while (count--)
+               *addr++ = *p++;
+}
+
+void
+bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint16_t *addr, bus_size_t count)
+{
+       uint16_t *p = (uint16_t *)(bsh + offset);
+
+       while (count--)
+               *addr++ = bswap16(*p++);
+}
+
+void
+bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint32_t *addr, bus_size_t count)
+{
+       uint32_t *p = (uint32_t *)(bsh + offset);
+
+       while (count--)
+               *addr++ = bswap32(*p++);
+}
+
+/*
+ *     void bus_space_read_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided.
+ */
+void
+bus_space_read_region_stream_1(bus_space_tag_t tag, bus_space_handle_t bsh,
+    bus_size_t offset, uint8_t *addr, bus_size_t count)
+{
+       uint8_t *p = (uint8_t *)(bsh + offset);
+
+       while (count--)
+               *addr++ = *p++;



Home | Main Index | Thread Index | Old Index