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.
This commit is contained in:
phx 2010-02-03 13:56:53 +00:00
parent 07f775da9b
commit 37e984601c
5 changed files with 74 additions and 16 deletions

View File

@ -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 @@ oabs(bsrm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
while (count > 0) {
*pointer++ = bswap16(*p);
amiga_bus_reorder_protect();
--count;
}
}
@ -71,6 +72,7 @@ oabs(bswm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
while (count > 0) {
*p = bswap16(*pointer);
amiga_bus_reorder_protect();
++pointer;
--count;
}

View File

@ -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 @@ u_int16_t
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 @@ amiga_contiguous_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
{
/* ARGSUSED */
* (u_int16_t *) (h + o) = v;
amiga_bus_reorder_protect();
}
void
@ -136,6 +141,7 @@ amiga_contiguous_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_
while (s-- > 0) {
*p++ = *q;
amiga_bus_reorder_protect();
}
}
@ -147,6 +153,7 @@ amiga_contiguous_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size
while (s-- > 0) {
*q = *p++;
amiga_bus_reorder_protect();
}
}
@ -158,6 +165,7 @@ amiga_contiguous_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size
while (s-- > 0) {
*p++ = *q++;
amiga_bus_reorder_protect();
}
}
@ -169,6 +177,7 @@ amiga_contiguous_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_siz
while (s-- > 0) {
*q++ = *p++;
amiga_bus_reorder_protect();
}
}
@ -180,6 +189,7 @@ amiga_contiguous_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_
while (s-- > 0) {
*q++ = v;
amiga_bus_reorder_protect();
}
}
@ -192,6 +202,7 @@ amiga_contiguous_copy_region_2(bus_space_tag_t t, bus_space_handle_t srch, bus_s
while (s-- > 0) {
*q++ = *p++;
amiga_bus_reorder_protect();
}
}
@ -205,12 +216,14 @@ u_int16_t
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 @@ amiga_interleaved_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
*q = v >> 8;
*(q+step) = v;
amiga_bus_reorder_protect();
}
void
@ -237,6 +251,7 @@ amiga_interleaved_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size
while (s-- > 0) {
*p++ = ((*q)<<8) | *(q+step);
amiga_bus_reorder_protect();
}
}
@ -254,6 +269,7 @@ amiga_interleaved_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_siz
v = *p++;
*q = v>>8;
*(q + step) = v;
amiga_bus_reorder_protect();
}
}
@ -271,6 +287,7 @@ amiga_interleaved_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_siz
v = (*q) << 8;
q += step;
v |= *q;
amiga_bus_reorder_protect();
q += step;
*p++ = v;
}
@ -291,6 +308,7 @@ amiga_interleaved_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_si
*q = v >> 8;
q += step;
*q = v;
amiga_bus_reorder_protect();
q += step;
}
}
@ -305,6 +323,7 @@ amiga_interleaved_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size
while (s-- > 0) {
*q = v;
amiga_bus_reorder_protect();
q += step;
}
}
@ -320,6 +339,7 @@ amiga_interleaved_copy_region_2(bus_space_tag_t t, bus_space_handle_t srch, bus_
while (s-- > 0) {
*q = *p;
amiga_bus_reorder_protect();
p += step;
q += step;
}
@ -334,7 +354,11 @@ u_int16_t
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 @@ amiga_interleaved_wordaccess_write_2(bus_space_tag_t t, bus_space_handle_t h, bu
{
/* ARGSUSED */
* (u_int16_t *) (h + (o << t->stride)) = v;
amiga_bus_reorder_protect();
}
void
@ -354,6 +379,7 @@ amiga_interleaved_wordaccess_read_multi_2(bus_space_tag_t t, bus_space_handle_t
while (s-- > 0) {
*p++ = *q;
amiga_bus_reorder_protect();
}
}
@ -367,6 +393,7 @@ amiga_interleaved_wordaccess_write_multi_2(bus_space_tag_t t, bus_space_handle_t
while (s-- > 0) {
*q = *p++;
amiga_bus_reorder_protect();
}
}
@ -382,6 +409,7 @@ amiga_interleaved_wordaccess_read_region_2(bus_space_tag_t t, bus_space_handle_t
while (s-- > 0) {
*p++ = *q;
amiga_bus_reorder_protect();
q += step;
}
}
@ -398,6 +426,7 @@ amiga_interleaved_wordaccess_write_region_2(bus_space_tag_t t, bus_space_handle_
while (s-- > 0) {
*q = *p++;
amiga_bus_reorder_protect();
q += step;
}
}
@ -414,6 +443,7 @@ amiga_interleaved_wordaccess_set_region_2(bus_space_tag_t t, bus_space_handle_t
while (s-- > 0) {
*q = v;
amiga_bus_reorder_protect();
q += step;
}
}
@ -432,8 +462,8 @@ amiga_interleaved_wordaccess_copy_region_2(bus_space_tag_t t, bus_space_handle_t
while (s-- > 0) {
*q = *p;
amiga_bus_reorder_protect();
q += step;
p += step;
}
}

View File

@ -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 @@ oabs(bsr1_) (handle, offset)
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 @@ oabs(bsw1_)(handle, offset, value)
p = (u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = (u_int8_t)value;
amiga_bus_reorder_protect();
}
void
@ -140,6 +144,7 @@ oabs(bsrm1_)(handle, offset, pointer, count)
while (count > 0) {
*pointer++ = *p;
amiga_bus_reorder_protect();
--count;
}
}
@ -157,6 +162,7 @@ oabs(bswm1_)(handle, offset, pointer, count)
while (count > 0) {
*p = *pointer++;
amiga_bus_reorder_protect();
--count;
}
}
@ -174,6 +180,7 @@ oabs(bsrr1_)(handle, offset, pointer, count)
while (count > 0) {
*pointer++ = *p;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE;
--count;
}
@ -192,6 +199,7 @@ oabs(bswr1_)(handle, offset, pointer, count)
while (count > 0) {
*p = *pointer++;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE;
--count;
}
@ -210,6 +218,7 @@ oabs(bssr1_)(handle, offset, value, count)
while (count > 0) {
*p = value;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE;
--count;
}
@ -228,6 +237,7 @@ oabs(bscr1_)(handlefrom, from, handleto, to, count)
while (count > 0) {
*q = *p;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE;
q += AMIGA_SIMPLE_BUS_STRIDE;
--count;
@ -249,14 +259,17 @@ bssr(oabs(bssr2_), u_int16_t);
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 @@ oabs(bsw2_)(handle, offset, value)
p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = (u_int16_t)value;
amiga_bus_reorder_protect();
}
void
@ -284,6 +298,7 @@ oabs(bsrm2_)(handle, offset, pointer, count)
while (count > 0) {
*pointer++ = *p;
amiga_bus_reorder_protect();
--count;
}
}
@ -301,6 +316,7 @@ oabs(bswm2_)(handle, offset, pointer, count)
while (count > 0) {
*p = *pointer++;
amiga_bus_reorder_protect();
--count;
}
}
@ -318,6 +334,7 @@ oabs(bsrr2_)(handle, offset, pointer, count)
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 @@ oabs(bswr2_)(handle, offset, pointer, count)
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 @@ oabs(bssr2_)(handle, offset, value, count)
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 @@ oabs(bscr2_)(handlefrom, from, handleto, to, count)
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;

View File

@ -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 @@ struct amiga_bus_space_methods {
#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;

View File

@ -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 @@ struct amiga_bus_space_methods {
#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;