Module Name:    src
Committed By:   phx
Date:           Wed Feb  3 13:56:53 UTC 2010

Modified Files:
        src/sys/arch/amiga/amiga: amiga_bus_simple_4.c busfuncs.c
            simple_busfuncs.c
        src/sys/arch/amiga/include: bus.h
        src/sys/arch/amigappc/include: bus.h

Log Message:
Ensure reorder protection for amigappc in all bus space functions.
The ne(4) driver (XSurf2), which is the only bus_space device I got,
works now.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amiga/amiga/amiga_bus_simple_4.c \
    src/sys/arch/amiga/amiga/simple_busfuncs.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/amiga/busfuncs.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amiga/include/bus.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amigappc/include/bus.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/amiga/amiga_bus_simple_4.c
diff -u src/sys/arch/amiga/amiga/amiga_bus_simple_4.c:1.5 src/sys/arch/amiga/amiga/amiga_bus_simple_4.c:1.6
--- src/sys/arch/amiga/amiga/amiga_bus_simple_4.c:1.5	Mon Apr 28 20:23:12 2008
+++ src/sys/arch/amiga/amiga/amiga_bus_simple_4.c	Wed Feb  3 13:56:53 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: amiga_bus_simple_4.c,v 1.5 2008/04/28 20:23:12 martin Exp $ */
+/* $NetBSD: amiga_bus_simple_4.c,v 1.6 2010/02/03 13:56:53 phx Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: amiga_bus_simple_4.c,v 1.5 2008/04/28 20:23:12 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: amiga_bus_simple_4.c,v 1.6 2010/02/03 13:56:53 phx Exp $");
 
 #define AMIGA_SIMPLE_BUS_STRIDE 4		/* 1 byte per long */
 #define AMIGA_SIMPLE_BUS_WORD_METHODS
@@ -57,6 +57,7 @@
 
 	while (count > 0) {
 		*pointer++ = bswap16(*p);
+		amiga_bus_reorder_protect();
 		--count;
 	}
 }
@@ -71,6 +72,7 @@
 
 	while (count > 0) {
 		*p = bswap16(*pointer);
+		amiga_bus_reorder_protect();
 		++pointer;
 		--count;
 	}
Index: src/sys/arch/amiga/amiga/simple_busfuncs.c
diff -u src/sys/arch/amiga/amiga/simple_busfuncs.c:1.5 src/sys/arch/amiga/amiga/simple_busfuncs.c:1.6
--- src/sys/arch/amiga/amiga/simple_busfuncs.c:1.5	Mon Apr 28 20:23:12 2008
+++ src/sys/arch/amiga/amiga/simple_busfuncs.c	Wed Feb  3 13:56:53 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: simple_busfuncs.c,v 1.5 2008/04/28 20:23:12 martin Exp $ */
+/* $NetBSD: simple_busfuncs.c,v 1.6 2010/02/03 13:56:53 phx Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: simple_busfuncs.c,v 1.5 2008/04/28 20:23:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: simple_busfuncs.c,v 1.6 2010/02/03 13:56:53 phx Exp $");
 
 /*
  * Do NOT use this standalone.
@@ -110,9 +110,12 @@
 	bus_size_t offset;
 {
 	u_int8_t *p;
+	u_int8_t x;
 
 	p = (u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
-	return (*p);
+	x = *p;
+	amiga_bus_reorder_protect();
+	return x;
 }
 
 void
@@ -125,6 +128,7 @@
 
 	p = (u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
 	*p = (u_int8_t)value;
+	amiga_bus_reorder_protect();
 }
 
 void
@@ -140,6 +144,7 @@
 
 	while (count > 0) {
 		*pointer++ = *p;
+		amiga_bus_reorder_protect();
 		--count;
 	}
 }
@@ -157,6 +162,7 @@
 
 	while (count > 0) {
 		*p = *pointer++;
+		amiga_bus_reorder_protect();
 		--count;
 	}
 }
@@ -174,6 +180,7 @@
 
 	while (count > 0) {
 		*pointer++ = *p;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE;
 		--count;
 	}
@@ -192,6 +199,7 @@
 
 	while (count > 0) {
 		*p = *pointer++;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE;
 		--count;
 	}
@@ -210,6 +218,7 @@
 
 	while (count > 0) {
 		*p = value;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE;
 		--count;
 	}
@@ -228,6 +237,7 @@
 
 	while (count > 0) {
 		*q = *p;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE;
 		q += AMIGA_SIMPLE_BUS_STRIDE;
 		--count;
@@ -249,14 +259,17 @@
 bscr(oabs(bscr2_), u_int16_t);
 
 u_int16_t
-oabs(bsr2_) (handle, offset)
+oabs(bsr2_)(handle, offset)
 	bus_space_handle_t handle;
 	bus_size_t offset;
 {
 	u_int16_t *p;
+	u_int16_t x;
 
 	p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
-	return (*p);
+	x = *p;
+	amiga_bus_reorder_protect();
+	return x;
 }
 
 void
@@ -269,6 +282,7 @@
 
 	p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
 	*p = (u_int16_t)value;
+	amiga_bus_reorder_protect();
 }
 
 void
@@ -284,6 +298,7 @@
 
 	while (count > 0) {
 		*pointer++ = *p;
+		amiga_bus_reorder_protect();
 		--count;
 	}
 }
@@ -301,6 +316,7 @@
 
 	while (count > 0) {
 		*p = *pointer++;
+		amiga_bus_reorder_protect();
 		--count;
 	}
 }
@@ -318,6 +334,7 @@
 
 	while (count > 0) {
 		*pointer++ = *(volatile u_int16_t *)p;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
 		--count;
 	}
@@ -336,6 +353,7 @@
 
 	while (count > 0) {
 		*(volatile u_int16_t *)p = *pointer++;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
 		--count;
 	}
@@ -354,6 +372,7 @@
 
 	while (count > 0) {
 		*(volatile u_int16_t *)p = (unsigned)value;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
 		--count;
 	}
@@ -372,6 +391,7 @@
 
 	while (count > 0) {
 		*(volatile u_int16_t *)q = *(volatile u_int16_t *)p;
+		amiga_bus_reorder_protect();
 		p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
 		q += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
 		--count;

Index: src/sys/arch/amiga/amiga/busfuncs.c
diff -u src/sys/arch/amiga/amiga/busfuncs.c:1.10 src/sys/arch/amiga/amiga/busfuncs.c:1.11
--- src/sys/arch/amiga/amiga/busfuncs.c:1.10	Sat Mar 14 21:04:03 2009
+++ src/sys/arch/amiga/amiga/busfuncs.c	Wed Feb  3 13:56:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: busfuncs.c,v 1.10 2009/03/14 21:04:03 dsl Exp $	*/
+/*	$NetBSD: busfuncs.c,v 1.11 2010/02/03 13:56:53 phx Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: busfuncs.c,v 1.10 2009/03/14 21:04:03 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: busfuncs.c,v 1.11 2010/02/03 13:56:53 phx Exp $");
 
 /*
  * Amiga bus access methods for data widths > 1
@@ -118,7 +118,11 @@
 amiga_contiguous_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
 {
 	/* ARGSUSED */
-	return (* (u_int16_t *) (h + o)); /* only used if t->stride == 0 */
+	u_int16_t x;
+
+	x  = * (u_int16_t *) (h + o); /* only used if t->stride == 0 */
+	amiga_bus_reorder_protect();
+	return x;
 }
 
 void
@@ -126,6 +130,7 @@
 {
 	/* ARGSUSED */
 	* (u_int16_t *) (h + o) = v;
+	amiga_bus_reorder_protect();
 }
 
 void
@@ -136,6 +141,7 @@
 
 	while (s-- > 0) {
 		*p++ =  *q;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -147,6 +153,7 @@
 
 	while (s-- > 0) {
 		*q = *p++;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -158,6 +165,7 @@
 
 	while (s-- > 0) {
 		*p++ =  *q++;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -169,6 +177,7 @@
 
 	while (s-- > 0) {
 		*q++ = *p++;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -180,6 +189,7 @@
 
 	while (s-- > 0) {
 		*q++ = v;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -192,6 +202,7 @@
 
 	while (s-- > 0) {
 		*q++ = *p++;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -205,12 +216,14 @@
 amiga_interleaved_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
 {
 	volatile u_int8_t *q;
+	u_int16_t x;
 	int step;
 
 	step = 1 << t->stride;
 	q = (volatile u_int8_t *)(h + (o << t->stride));
-
-	return ((*q) << 8) | *(q + step);
+	x = ((*q) << 8) | *(q + step);
+	amiga_bus_reorder_protect();
+	return x;
 }
 
 void
@@ -224,6 +237,7 @@
 
 	*q = v >> 8;
 	*(q+step) = v;
+	amiga_bus_reorder_protect();
 }
 
 void
@@ -237,6 +251,7 @@
 
 	while (s-- > 0) {
 		*p++ =  ((*q)<<8) | *(q+step);
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -254,6 +269,7 @@
 		v = *p++;
 		*q 		= v>>8;
 		*(q + step)	= v;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -271,6 +287,7 @@
 		v = (*q) << 8;
 		q += step;
 		v |= *q;
+		amiga_bus_reorder_protect();
 		q += step;
 		*p++ =  v;
 	}
@@ -291,6 +308,7 @@
 		*q = v >> 8;
 		q += step;
 		*q = v;
+		amiga_bus_reorder_protect();
 		q += step;
 	}
 }
@@ -305,6 +323,7 @@
 
 	while (s-- > 0) {
 		*q = v;
+		amiga_bus_reorder_protect();
 		q += step;
 	}
 }
@@ -320,6 +339,7 @@
 
 	while (s-- > 0) {
 		*q = *p;
+		amiga_bus_reorder_protect();
 		p += step;
 		q += step;
 	}
@@ -334,7 +354,11 @@
 amiga_interleaved_wordaccess_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
 {
 	/* ARGSUSED */
-	return (* (u_int16_t *) (h + (o << t->stride)));
+	u_int16_t x;
+
+	x = * (u_int16_t *) (h + (o << t->stride));
+	amiga_bus_reorder_protect();
+	return x;
 }
 
 void
@@ -342,6 +366,7 @@
 {
 	/* ARGSUSED */
 	* (u_int16_t *) (h + (o << t->stride)) = v;
+	amiga_bus_reorder_protect();
 }
 
 void
@@ -354,6 +379,7 @@
 
 	while (s-- > 0) {
 		*p++ =  *q;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -367,6 +393,7 @@
 
 	while (s-- > 0) {
 		*q = *p++;
+		amiga_bus_reorder_protect();
 	}
 }
 
@@ -382,6 +409,7 @@
 
 	while (s-- > 0) {
 		*p++ =  *q;
+		amiga_bus_reorder_protect();
 		q += step;
 	}
 }
@@ -398,6 +426,7 @@
 
 	while (s-- > 0) {
 		*q = *p++;
+		amiga_bus_reorder_protect();
 		q += step;
 	}
 }
@@ -414,6 +443,7 @@
 
 	while (s-- > 0) {
 		*q = v;
+		amiga_bus_reorder_protect();
 		q += step;
 	}
 }
@@ -432,8 +462,8 @@
 
 	while (s-- > 0) {
 		*q = *p;
+		amiga_bus_reorder_protect();
 		q += step;
 		p += step;
 	}
 }
-

Index: src/sys/arch/amiga/include/bus.h
diff -u src/sys/arch/amiga/include/bus.h:1.22 src/sys/arch/amiga/include/bus.h:1.23
--- src/sys/arch/amiga/include/bus.h:1.22	Tue Oct 20 19:10:10 2009
+++ src/sys/arch/amiga/include/bus.h	Wed Feb  3 13:56:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.h,v 1.22 2009/10/20 19:10:10 snj Exp $	*/
+/*	$NetBSD: bus.h,v 1.23 2010/02/03 13:56:53 phx Exp $	*/
 
 /*
  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
@@ -247,6 +247,9 @@
 
 #define __BUS_SPACE_HAS_STREAM_METHODS
 
+/* Instruction for enforcing reorder protection. Nothing for 68k. */
+#define amiga_bus_reorder_protect()
+
 extern const struct amiga_bus_space_methods amiga_bus_stride_1;
 extern const struct amiga_bus_space_methods amiga_bus_stride_2;
 extern const struct amiga_bus_space_methods amiga_bus_stride_4;

Index: src/sys/arch/amigappc/include/bus.h
diff -u src/sys/arch/amigappc/include/bus.h:1.6 src/sys/arch/amigappc/include/bus.h:1.7
--- src/sys/arch/amigappc/include/bus.h:1.6	Tue Oct 20 19:10:10 2009
+++ src/sys/arch/amigappc/include/bus.h	Wed Feb  3 13:56:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.h,v 1.6 2009/10/20 19:10:10 snj Exp $	*/
+/*	$NetBSD: bus.h,v 1.7 2010/02/03 13:56:53 phx Exp $	*/
 
 /*
  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
@@ -247,6 +247,9 @@
 
 #define __BUS_SPACE_HAS_STREAM_METHODS
 
+/* Instruction for enforcing reorder protection. */
+#define amiga_bus_reorder_protect() __asm volatile ("eieio")
+
 extern const struct amiga_bus_space_methods amiga_bus_stride_1;
 extern const struct amiga_bus_space_methods amiga_bus_stride_2;
 extern const struct amiga_bus_space_methods amiga_bus_stride_4;

Reply via email to