Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/mips Introduce CHIP_ACCESSTYPE which (if defin...
details: https://anonhg.NetBSD.org/src/rev/0e3e4be62bf4
branches: trunk
changeset: 532312:0e3e4be62bf4
user: simonb <simonb%NetBSD.org@localhost>
date: Wed Jun 05 06:27:10 2002 +0000
description:
Introduce CHIP_ACCESSTYPE which (if defined) is used as the type for
performing the accesses, regardless of the size of the data type
requested. Useful for chips which require fixed-width accesses to all
registers.
Cast arguments printed using %lx to u_long all the time, not just
sometimes.
Include a few extra files here so they don't need to be included by the
files that include this one.
diffstat:
sys/arch/mips/mips/bus_space_alignstride_chipdep.c | 86 ++++++++++++++++-----
1 files changed, 66 insertions(+), 20 deletions(-)
diffs (205 lines):
diff -r 84b02225974c -r 0e3e4be62bf4 sys/arch/mips/mips/bus_space_alignstride_chipdep.c
--- a/sys/arch/mips/mips/bus_space_alignstride_chipdep.c Wed Jun 05 06:27:09 2002 +0000
+++ b/sys/arch/mips/mips/bus_space_alignstride_chipdep.c Wed Jun 05 06:27:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.2 2002/03/23 14:20:41 simonb Exp $ */
+/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.3 2002/06/05 06:27:10 simonb Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -81,7 +81,14 @@
* for the memory or I/O memory space extent.
*/
+#ifdef CHIP_EXTENT
#include <sys/extent.h>
+#endif
+#include <sys/malloc.h>
+
+#include <machine/locore.h>
+
+#include <uvm/uvm_extern.h>
#define __C(A,B) __CONCAT(A,B)
#define __S(S) __STRING(S)
@@ -334,14 +341,14 @@
if (CHIP_W2_BUS_START(v) != CHIP_W1_BUS_START(v)) {
#ifdef EXTENT_DEBUG
printf("xxx: freeing from 0x%lx to 0x%lx\n",
- CHIP_W2_BUS_START(v), CHIP_W2_BUS_END(v));
+ (u_long)CHIP_W2_BUS_START(v), (u_long)CHIP_W2_BUS_END(v));
#endif
extent_free(ex, CHIP_W2_BUS_START(v),
CHIP_W2_BUS_END(v) - CHIP_W2_BUS_START(v) + 1, EX_NOWAIT);
} else {
#ifdef EXTENT_DEBUG
printf("xxx: window 2 (0x%lx to 0x%lx) overlaps window 1\n",
- CHIP_W2_BUS_START(v), CHIP_W2_BUS_END(v));
+ (u_long)CHIP_W2_BUS_START(v), (u_long)CHIP_W2_BUS_END(v));
#endif
}
#endif
@@ -350,14 +357,14 @@
CHIP_W3_BUS_START(v) != CHIP_W2_BUS_START(v)) {
#ifdef EXTENT_DEBUG
printf("xxx: freeing from 0x%lx to 0x%lx\n",
- CHIP_W3_BUS_START(v), CHIP_W3_BUS_END(v));
+ (u_long)CHIP_W3_BUS_START(v), (u_long)CHIP_W3_BUS_END(v));
#endif
extent_free(ex, CHIP_W3_BUS_START(v),
CHIP_W3_BUS_END(v) - CHIP_W3_BUS_START(v) + 1, EX_NOWAIT);
} else {
#ifdef EXTENT_DEBUG
printf("xxx: window 2 (0x%lx to 0x%lx) overlaps window 1\n",
- CHIP_W2_BUS_START(v), CHIP_W2_BUS_END(v));
+ (u_long)CHIP_W2_BUS_START(v), (u_long)CHIP_W2_BUS_END(v));
#endif
}
#endif
@@ -402,19 +409,16 @@
#ifdef EXTENT_DEBUG
printf("\n");
#ifdef CHIP_W1_BUS_START
- printf("%s: window[1]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W1_BUS_START(v),
- CHIP_W1_BUS_END(v));
+ printf("%s: window[1]=0x%lx-0x%lx\n", __S(__BS(map)),
+ (u_long)CHIP_W1_BUS_START(v), (u_long)CHIP_W1_BUS_END(v));
#endif
#ifdef CHIP_W2_BUS_START
- printf("%s: window[2]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W2_BUS_START(v),
- CHIP_W2_BUS_END(v));
+ printf("%s: window[2]=0x%lx-0x%lx\n", __S(__BS(map)),
+ (u_long)CHIP_W2_BUS_START(v), (u_long)CHIP_W2_BUS_END(v));
#endif
#ifdef CHIP_W3_BUS_START
- printf("%s: window[3]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W3_BUS_START(v),
- CHIP_W3_BUS_END(v));
+ printf("%s: window[3]=0x%lx-0x%lx\n", __S(__BS(map)),
+ (u_long)CHIP_W3_BUS_START(v), (u_long)CHIP_W3_BUS_END(v));
#endif
#endif /* EXTENT_DEBUG */
/* No translation. */
@@ -548,18 +552,18 @@
printf("\n");
#ifdef CHIP_W1_BUS_START
printf("%s: sys window[1]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W1_SYS_START(v),
- CHIP_W1_SYS_END(v));
+ __S(__BS(map)), (u_long)CHIP_W1_SYS_START(v),
+ (u_long)CHIP_W1_SYS_END(v));
#endif
#ifdef CHIP_W2_BUS_START
printf("%s: sys window[2]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W2_SYS_START(v),
- CHIP_W2_SYS_END(v));
+ __S(__BS(map)), (u_long)CHIP_W2_SYS_START(v),
+ (u_long)CHIP_W2_SYS_END(v));
#endif
#ifdef CHIP_W3_BUS_START
printf("%s: sys window[3]=0x%lx-0x%lx\n",
- __S(__BS(map)), CHIP_W3_SYS_START(v),
- CHIP_W3_SYS_END(v));
+ __S(__BS(map)), (u_long)CHIP_W3_SYS_START(v),
+ (u_long)CHIP_W3_SYS_END(v));
#endif
panic("%s: don't know how to unmap %lx", __S(__BS(unmap)), h);
}
@@ -709,14 +713,33 @@
inline uint8_t
__BS(read_1)(void *v, bus_space_handle_t h, bus_size_t off)
{
+#ifdef CHIP_ACCESSTYPE
+ CHIP_ACCESSTYPE *ptr = (void *)(h + (off << CHIP_ALIGN_STRIDE));
+ CHIP_ACCESSTYPE rval;
+
+ rval = *ptr;
+ return (rval & 0xff); /* XXX BigEndian safe? */
+#else /* !CHIP_ACCESSTYPE */
uint8_t *ptr = (void *)(h + (off << CHIP_ALIGN_STRIDE));
return (*ptr);
+#endif /* !CHIP_ACCESSTYPE */
}
inline uint16_t
__BS(read_2)(void *v, bus_space_handle_t h, bus_size_t off)
{
+#ifdef CHIP_ACCESSTYPE
+#if CHIP_ALIGN_STRIDE >= 1
+ CHIP_ACCESSTYPE *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 1)));
+#else
+ CHIP_ACCESSTYPE *ptr = (void *)(h + off);
+#endif
+ CHIP_ACCESSTYPE rval;
+
+ rval = *ptr;
+ return (rval & 0xffff); /* XXX BigEndian safe? */
+#else /* !CHIP_ACCESSTYPE */
#if CHIP_ALIGN_STRIDE >= 1
uint16_t *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 1)));
#else
@@ -724,11 +747,13 @@
#endif
return (*ptr);
+#endif /* !CHIP_ACCESSTYPE */
}
inline uint32_t
__BS(read_4)(void *v, bus_space_handle_t h, bus_size_t off)
{
+ /* XXX XXX XXX should use CHIP_ACCESSTYPE if it's > 32bits */
#if CHIP_ALIGN_STRIDE >= 2
uint32_t *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 2)));
#else
@@ -782,14 +807,33 @@
inline void
__BS(write_1)(void *v, bus_space_handle_t h, bus_size_t off, uint8_t val)
{
+#ifdef CHIP_ACCESSTYPE
+ CHIP_ACCESSTYPE *ptr = (void *)(h + (off << CHIP_ALIGN_STRIDE));
+ CHIP_ACCESSTYPE wval;
+
+ wval = val & 0xff; /* XXX BigEndian safe? */
+ *ptr = wval;
+#else /* !CHIP_ACCESSTYPE */
uint8_t *ptr = (void *)(h + (off << CHIP_ALIGN_STRIDE));
*ptr = val;
+#endif /* !CHIP_ACCESSTYPE */
}
inline void
__BS(write_2)(void *v, bus_space_handle_t h, bus_size_t off, uint16_t val)
{
+#ifdef CHIP_ACCESSTYPE
+#if CHIP_ALIGN_STRIDE >= 1
+ CHIP_ACCESSTYPE *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 1)));
+#else
+ CHIP_ACCESSTYPE *ptr = (void *)(h + off);
+#endif
+ CHIP_ACCESSTYPE wval;
+
+ wval = val & 0xffff; /* XXX BigEndian safe? */
+ *ptr = wval;
+#else /* !CHIP_ACCESSTYPE */
#if CHIP_ALIGN_STRIDE >= 1
uint16_t *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 1)));
#else
@@ -797,11 +841,13 @@
#endif
*ptr = val;
+#endif /* !CHIP_ACCESSTYPE */
}
inline void
__BS(write_4)(void *v, bus_space_handle_t h, bus_size_t off, uint32_t val)
{
+ /* XXX XXX XXX should use CHIP_ACCESSTYPE if it's > 32bits */
#if CHIP_ALIGN_STRIDE >= 2
uint32_t *ptr = (void *)(h + (off << (CHIP_ALIGN_STRIDE - 2)));
#else
Home |
Main Index |
Thread Index |
Old Index