code factorisation and added stride 1 functions

This commit is contained in:
aymeric 2000-01-23 21:02:17 +00:00
parent 564df9b630
commit 3a54b5a896
4 changed files with 232 additions and 189 deletions

View File

@ -0,0 +1,42 @@
/* $NetBSD: amiga_bus_simple_1word.c,v 1.1 2000/01/23 21:02:17 aymeric Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Ignatios Souvatzis.
*
* 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.
*/
#define AMIGA_SIMPLE_BUS_STRIDE 1 /* 1 byte per word */
#define AMIGA_SIMPLE_BUS_WORD_METHODS
#include "simple_busfuncs.c"

View File

@ -1,4 +1,4 @@
/* $NetBSD: amiga_bus_simple_2word.c,v 1.1 1999/12/30 20:56:44 is Exp $ */
/* $NetBSD: amiga_bus_simple_2word.c,v 1.2 2000/01/23 21:02:18 aymeric Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -36,191 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* We combine this simple_bus byte access with the word access methods
* needed for if_ne_zbus, that is, the _stream_ variants are the same
* as the non_stream ones.
*/
#define AMIGA_SIMPLE_BUS_STRIDE 2 /* 1 byte per word */
#define AMIGA_SIMPLE_BUS_NO_ARRAY
/* byte methods */
#define AMIGA_SIMPLE_BUS_WORD_METHODS
#include "simple_busfuncs.c"
/* word methods */
bsr (oabs(bsr2_), u_int16_t);
bsw (oabs(bsw2_), u_int16_t);
bsrm(oabs(bsrm2_), u_int16_t);
bswm(oabs(bswm2_), u_int16_t);
bsrm(oabs(bsrr2_), u_int16_t);
bswm(oabs(bswr2_), u_int16_t);
bssr(oabs(bssr2_), u_int16_t);
bscr(oabs(bscr2_), u_int16_t);
u_int16_t
oabs(bsr2_) (handle, offset)
bus_space_handle_t handle;
bus_size_t offset;
{
u_int16_t *p;
p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
return (*p);
}
void
oabs(bsw2_)(handle, offset, value)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
{
u_int16_t *p;
p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = (u_int16_t)value;
}
void
oabs(bsrm2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int16_t *pointer;
bus_size_t count;
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *p;
--count;
}
}
void
oabs(bswm2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int16_t *pointer;
bus_size_t count;
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*p = *pointer++;
--count;
}
}
void
oabs(bsrr2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int16_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *(volatile u_int16_t *)p;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bswr2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int16_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)p = *pointer++;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bssr2_)(handle, offset, value, count)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)p = (unsigned)value;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bscr2_)(handlefrom, from, handleto, to, count)
bus_space_handle_t handlefrom, handleto;
bus_size_t from, to;
bus_size_t count;
{
volatile u_int8_t *p, *q;
p = (volatile u_int8_t *)(handlefrom + from * AMIGA_SIMPLE_BUS_STRIDE);
q = (volatile u_int8_t *)(handleto + to * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)q = *(volatile u_int16_t *)p;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
q += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
/* method array */
const struct amiga_bus_space_methods amiga_bus_stride_2word = {
oabs(bsm_),
oabs(bsms_),
oabs(bsu_),
0,
0,
oabs(bsr1_),
oabs(bsw1_),
oabs(bsrm1_),
oabs(bswm1_),
oabs(bsrr1_),
oabs(bswr1_),
oabs(bssr1_),
oabs(bscr1_),
oabs(bsr2_),
oabs(bsw2_),
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_),
oabs(bscr2_)
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: simple_busfuncs.c,v 1.1 1999/12/30 20:56:44 is Exp $ */
/* $NetBSD: simple_busfuncs.c,v 1.2 2000/01/23 21:02:18 aymeric Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -238,6 +238,152 @@ oabs(bscr1_)(handlefrom, from, handleto, to, count)
}
}
#ifdef AMIGA_SIMPLE_BUS_WORD_METHODS
/* word methods */
bsr (oabs(bsr2_), u_int16_t);
bsw (oabs(bsw2_), u_int16_t);
bsrm(oabs(bsrm2_), u_int16_t);
bswm(oabs(bswm2_), u_int16_t);
bsrm(oabs(bsrr2_), u_int16_t);
bswm(oabs(bswr2_), u_int16_t);
bssr(oabs(bssr2_), u_int16_t);
bscr(oabs(bscr2_), u_int16_t);
u_int16_t
oabs(bsr2_) (handle, offset)
bus_space_handle_t handle;
bus_size_t offset;
{
u_int16_t *p;
p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
return (*p);
}
void
oabs(bsw2_)(handle, offset, value)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
{
u_int16_t *p;
p = (u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = (u_int16_t)value;
}
void
oabs(bsrm2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int16_t *pointer;
bus_size_t count;
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *p;
--count;
}
}
void
oabs(bswm2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int16_t *pointer;
bus_size_t count;
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*p = *pointer++;
--count;
}
}
void
oabs(bsrr2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int16_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *(volatile u_int16_t *)p;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bswr2_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int16_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)p = *pointer++;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bssr2_)(handle, offset, value, count)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)p = (unsigned)value;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
void
oabs(bscr2_)(handlefrom, from, handleto, to, count)
bus_space_handle_t handlefrom, handleto;
bus_size_t from, to;
bus_size_t count;
{
volatile u_int8_t *p, *q;
p = (volatile u_int8_t *)(handlefrom + from * AMIGA_SIMPLE_BUS_STRIDE);
q = (volatile u_int8_t *)(handleto + to * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int16_t *)q = *(volatile u_int16_t *)p;
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
q += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int16_t);
--count;
}
}
#endif /* AMIGA_SIMPLE_BUS_WORD_METHODS */
#ifndef AMIGA_SIMPLE_BUS_NO_ARRAY
/* method array */
@ -258,6 +404,23 @@ const struct amiga_bus_space_methods oabs(amiga_bus_stride_) = {
oabs(bssr1_),
oabs(bscr1_),
#ifdef AMIGA_SIMPLE_BUS_WORD_METHODS
oabs(bsr2_),
oabs(bsw2_),
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_),
oabs(bscr2_)
#else /* AMIGA_SIMPLE_BUS_WORD_METHODS */
0
#endif /* AMIGA_SIMPLE_BUS_WORD_METHODS */
};
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.12 1999/12/30 20:56:46 is Exp $ */
/* $NetBSD: bus.h,v 1.13 2000/01/23 21:02:18 aymeric Exp $ */
/*
* Copyright (c) 1996 Leo Weppelman. All rights reserved.
@ -202,6 +202,26 @@ struct amiga_bus_space_methods {
#define bus_space_set_region_2(t, h, o, v, c) dbss(bssr2, t, h, o, v, c)
#define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
/* 4: Fake 32-bit macros */
#define bus_space_read_4(t, h, o) \
panic("bus_space_read_4 not implemented");
#define bus_space_write_4(t, h, o, v) \
panic("bus_space_write_4 not implemented");
#define bus_space_read_multi_4(t, h, o, p, c) \
panic("bus_space_read_multi_4 not implemented");
#define bus_space_write_multi_4(t, h, o, p, c) \
panic("bus_space_write_multi_4 not implemented");
#define bus_space_read_multi_stream_4(t, h, o, p, c) \
panic("bus_space_read_multi_stream_4 not implemented");
#define bus_space_write_multi_stream_4(t, h, o, p, c) \
panic("bus_space_write_multi_stream_4 not implemented");
/*
* Bus read/write barrier methods.
*
@ -221,6 +241,8 @@ struct amiga_bus_space_methods {
#define __BUS_SPACE_HAS_STREAM_METHODS
const struct amiga_bus_space_methods amiga_bus_stride_2word, amiga_bus_stride_4;
const struct amiga_bus_space_methods amiga_bus_stride_1;
const struct amiga_bus_space_methods amiga_bus_stride_2;
const struct amiga_bus_space_methods amiga_bus_stride_4;
#endif /* _AMIGA_BUS_H_ */