Date: Wed, 20 Feb 2002 04:18:42 +0100 From: Thomas Moestl <tmoestl@gmx.net> To: freebsd-arch@FreeBSD.org Subject: Re: adding more endian conversion and bus space functions Message-ID: <20020220031842.GF282@crow.dom2ip.de> In-Reply-To: <20020111005207.GA7246@crow.dom2ip.de> References: <20020111005207.GA7246@crow.dom2ip.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2002/01/11 at 01:52:07 +0100, Thomas Moestl wrote:
> I'd like to propose some additions to the kernel endian conversion and
> bus space functions to aid the sparc64 port, taken from NetBSD:
I have attached a diff that implements these new functions, with minor
deviations from the original proposal (I have not created a
sys/endian.h, but have put the code that was meant to go there into
sys/param.h for now).
The new functions/macros are not exported to userland right now.
Libstand will now include htonl and friend for all architectures;
previously, consumers of libstand would use the inline functions
defined in machine/endian.h, except for alpha (ia64 had these
functions in libstand previously too, but they were not used as far as
I can tell). These inline functions have changed names and are not
exposed to userland any more.
The following files will be cvs rm'ed when this patch will be
committed:
sys/libkern/alpha/htonl.S
sys/libkern/alpha/htons.S
sys/libkern/alpha/ntohl.S
sys/libkern/alpha/ntohs.S
sys/libkern/ia64/htonl.S
sys/libkern/ia64/htons.S
sys/libkern/ia64/ntohl.S
sys/libkern/ia64/ntohs.S
This is tested on i386 and sparc64. If there are no objections, I will
try to find testers for the other architectures soon.
Please review and comment!
Thanks,
- thomas
==== //depot/projects/sparc64/lib/libstand/Makefile#2 - /home/tmm/p4/sparc64/lib/libstand/Makefile ====
--- /tmp/tmp.13288.0 Wed Feb 20 01:53:46 2002
+++ /home/tmm/p4/sparc64/lib/libstand/Makefile Tue Feb 19 23:48:33 2002
@@ -33,6 +33,10 @@
# private (pruned) versions of libc string functions
SRCS+= strcasecmp.c
+# byte order functions from libc
+.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/net
+SRCS+= htons.S ntohs.S htonl.S ntohl.S
+
# string functions from libc
.PATH: ${.CURDIR}/../libc/string
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
@@ -50,9 +54,6 @@
strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
strspn.c strstr.c strtok.c swab.c
-.PATH: ${.CURDIR}/../libc/alpha/net
-SRCS+= htons.S ntohs.S htonl.S ntohl.S
-
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
SRCS+= __remqu.S __remq.S __remlu.S __reml.S
@@ -99,9 +100,6 @@
strcmp.c strcpy.c strcspn.c strlen.c \
strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
strspn.c strstr.c strtok.c swab.c
-
-.PATH: ${.CURDIR}/../libc/ia64/net
-SRCS+= htons.S ntohs.S htonl.S ntohl.S
.PATH: ${.CURDIR}/../libc/ia64/gen
SRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
==== //depot/projects/sparc64/sys/alpha/include/bus.h#1 - /home/tmm/p4/sparc64/sys/alpha/include/bus.h ====
--- /tmp/tmp.13288.1 Wed Feb 20 01:53:47 2002
+++ /home/tmm/p4/sparc64/sys/alpha/include/bus.h Wed Feb 20 01:37:00 2002
@@ -366,6 +366,70 @@
(t)->ab_ops->abo_barrier(t, (h)+(o), l, f)
/*
+ * Stream accesses are the same as normal accesses on alpha; there are no
+ * supported bus systems with an endianess different from the host one.
+ */
+#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
+#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
+#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
+
+#define bus_space_read_multi_stream_1(t, h, o, a, c) \
+ bus_space_read_multi_1((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_2(t, h, o, a, c) \
+ bus_space_read_multi_2((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_4(t, h, o, a, c) \
+ bus_space_read_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_stream_1(t, h, o, v) \
+ bus_space_write_1((t), (h), (o), (v))
+#define bus_space_write_stream_2(t, h, o, v) \
+ bus_space_write_2((t), (h), (o), (v))
+#define bus_space_write_stream_4(t, h, o, v) \
+ bus_space_write_4((t), (h), (o), (v))
+
+#define bus_space_write_multi_stream_1(t, h, o, a, c) \
+ bus_space_write_multi_1((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_2(t, h, o, a, c) \
+ bus_space_write_multi_2((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_4(t, h, o, a, c) \
+ bus_space_write_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_multi_stream_1(t, h, o, v, c) \
+ bus_space_set_multi_1((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_2(t, h, o, v, c) \
+ bus_space_set_multi_2((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_4(t, h, o, v, c) \
+ bus_space_set_multi_4((t), (h), (o), (v), (c))
+
+#define bus_space_read_region_stream_1(t, h, o, a, c) \
+ bus_space_read_region_1((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_2(t, h, o, a, c) \
+ bus_space_read_region_2((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_4(t, h, o, a, c) \
+ bus_space_read_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_region_stream_1(t, h, o, a, c) \
+ bus_space_write_region_1((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_2(t, h, o, a, c) \
+ bus_space_write_region_2((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_4(t, h, o, a, c) \
+ bus_space_write_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_region_stream_1(t, h, o, v, c) \
+ bus_space_set_region_1((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_2(t, h, o, v, c) \
+ bus_space_set_region_2((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_4(t, h, o, v, c) \
+ bus_space_set_region_4((t), (h), (o), (v), (c))
+
+#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
+
+/*
* Flags used in various bus DMA methods.
*/
#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
==== //depot/projects/sparc64/sys/alpha/include/endian.h#3 - /home/tmm/p4/sparc64/sys/alpha/include/endian.h ====
--- /tmp/tmp.13288.2 Wed Feb 20 01:53:47 2002
+++ /home/tmm/p4/sparc64/sys/alpha/include/endian.h Tue Feb 19 22:12:46 2002
@@ -56,6 +56,15 @@
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
#define BYTE_ORDER LITTLE_ENDIAN
+
+#ifdef _KERNEL
+__uint16_t __bswap16(__uint16_t);
+__uint32_t __bswap32(__uint32_t);
+
+#define bswap16(x) __bswap16(x)
+#define bswap32(x) __bswap32(x)
+#endif
+
#endif /* !_POSIX_SOURCE */
#endif /* !_MACHINE_ENDIAN_H_ */
==== //depot/projects/sparc64/sys/conf/files.alpha#8 - /home/tmm/p4/sparc64/sys/conf/files.alpha ====
--- /tmp/tmp.13288.3 Wed Feb 20 01:53:47 2002
+++ /home/tmm/p4/sparc64/sys/conf/files.alpha Tue Feb 19 20:13:51 2002
@@ -215,9 +215,7 @@
isa/syscons_isa.c optional sc
isa/vga_isa.c optional vga
kern/subr_diskmbr.c standard
-libkern/alpha/htonl.S standard
-libkern/alpha/htons.S standard
-libkern/alpha/ntohl.S standard
-libkern/alpha/ntohs.S standard
+libkern/alpha/bswap16.S standard
+libkern/alpha/bswap32.S standard
libkern/bcmp.c standard
libkern/ffs.c standard
==== //depot/projects/sparc64/sys/conf/files.ia64#9 - /home/tmm/p4/sparc64/sys/conf/files.ia64 ====
--- /tmp/tmp.13288.4 Wed Feb 20 01:53:47 2002
+++ /home/tmm/p4/sparc64/sys/conf/files.ia64 Tue Feb 19 20:14:56 2002
@@ -99,10 +99,8 @@
isa/syscons_isa.c optional sc
isa/vga_isa.c optional vga
kern/subr_diskmbr.c standard
-libkern/ia64/htonl.S standard
-libkern/ia64/htons.S standard
-libkern/ia64/ntohl.S standard
-libkern/ia64/ntohs.S standard
+libkern/ia64/bswap16.S standard
+libkern/ia64/bswap32.S standard
libkern/ia64/__divsi3.S standard
libkern/ia64/__modsi3.S standard
libkern/ia64/__udivsi3.S standard
==== //depot/projects/sparc64/sys/dev/iir/iir.h#1 - /home/tmm/p4/sparc64/sys/dev/iir/iir.h ====
--- /tmp/tmp.13288.5 Wed Feb 20 01:53:48 2002
+++ /home/tmm/p4/sparc64/sys/dev/iir/iir.h Wed Feb 20 01:16:50 2002
@@ -372,10 +372,8 @@
#define GDT_SCRATCH_SZ 3072 /* 3KB scratch buffer */
/* macros */
-#define htole32(v) (v)
-#define htole16(v) (v)
-#define letoh32(v) (v)
-#define letoh16(v) (v)
+#define letoh32(v) le32toh(v)
+#define letoh16(v) le16toh(v)
/* Map minor numbers to device identity */
#define LUN_MASK 0x0007
==== //depot/projects/sparc64/sys/dev/usb/ohci.c#7 - /home/tmm/p4/sparc64/sys/dev/usb/ohci.c ====
--- /tmp/tmp.13288.6 Wed Feb 20 01:53:48 2002
+++ /home/tmm/p4/sparc64/sys/dev/usb/ohci.c Wed Feb 20 00:40:01 2002
@@ -96,20 +96,6 @@
#define DPRINTFN(n,x)
#endif
-/*
- * The OHCI controller is little endian, so on big endian machines
- * the data strored in memory needs to be swapped.
- */
-#if defined(__FreeBSD__)
-#if BYTE_ORDER == BIG_ENDIAN
-#define htole32(x) (bswap32(x))
-#define le32toh(x) (bswap32(x))
-#else
-#define htole32(x) (x)
-#define le32toh(x) (x)
-#endif
-#endif
-
struct ohci_pipe;
Static ohci_soft_ed_t *ohci_alloc_sed(ohci_softc_t *);
==== //depot/projects/sparc64/sys/dev/usb/uhci.c#9 - /home/tmm/p4/sparc64/sys/dev/usb/uhci.c ====
--- /tmp/tmp.13288.7 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/dev/usb/uhci.c Wed Feb 20 00:39:54 2002
@@ -112,7 +112,7 @@
* The UHCI controller is little endian, so on big endian machines
* the data strored in memory needs to be swapped.
*/
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__OpenBSD__)
#if BYTE_ORDER == BIG_ENDIAN
#define htole32(x) (bswap32(x))
#define le32toh(x) (bswap32(x))
==== //depot/projects/sparc64/sys/dev/usb/usb_port.h#4 - /home/tmm/p4/sparc64/sys/dev/usb/usb_port.h ====
==== //depot/projects/sparc64/sys/dev/wi/if_wi.c#13 - /home/tmm/p4/sparc64/sys/dev/wi/if_wi.c ====
--- /tmp/tmp.13288.8 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/dev/wi/if_wi.c Wed Feb 20 00:34:30 2002
@@ -125,11 +125,9 @@
#endif
/*
- * The following is for compatibility with NetBSD, but should really be
- * brought in from NetBSD en toto.
+ * The following is for compatibility with NetBSD.
*/
-#define le16toh(a) (a)
-#define LE16TOH(a)
+#define LE16TOH(a) ((a) = le16toh((a)))
static void wi_intr __P((void *));
static void wi_reset __P((struct wi_softc *));
==== //depot/projects/sparc64/sys/i386/include/bus.h#2 - /home/tmm/p4/sparc64/sys/i386/include/bus.h ====
--- /tmp/tmp.13288.9 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/i386/include/bus.h Wed Feb 20 01:36:38 2002
@@ -43,4 +43,68 @@
#endif
#include <machine/bus_dma.h>
+/*
+ * Stream accesses are the same as normal accesses on i386/pc98; there are no
+ * supported bus systems with an endianess different from the host one.
+ */
+#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
+#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
+#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
+
+#define bus_space_read_multi_stream_1(t, h, o, a, c) \
+ bus_space_read_multi_1((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_2(t, h, o, a, c) \
+ bus_space_read_multi_2((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_4(t, h, o, a, c) \
+ bus_space_read_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_stream_1(t, h, o, v) \
+ bus_space_write_1((t), (h), (o), (v))
+#define bus_space_write_stream_2(t, h, o, v) \
+ bus_space_write_2((t), (h), (o), (v))
+#define bus_space_write_stream_4(t, h, o, v) \
+ bus_space_write_4((t), (h), (o), (v))
+
+#define bus_space_write_multi_stream_1(t, h, o, a, c) \
+ bus_space_write_multi_1((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_2(t, h, o, a, c) \
+ bus_space_write_multi_2((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_4(t, h, o, a, c) \
+ bus_space_write_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_multi_stream_1(t, h, o, v, c) \
+ bus_space_set_multi_1((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_2(t, h, o, v, c) \
+ bus_space_set_multi_2((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_4(t, h, o, v, c) \
+ bus_space_set_multi_4((t), (h), (o), (v), (c))
+
+#define bus_space_read_region_stream_1(t, h, o, a, c) \
+ bus_space_read_region_1((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_2(t, h, o, a, c) \
+ bus_space_read_region_2((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_4(t, h, o, a, c) \
+ bus_space_read_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_region_stream_1(t, h, o, a, c) \
+ bus_space_write_region_1((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_2(t, h, o, a, c) \
+ bus_space_write_region_2((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_4(t, h, o, a, c) \
+ bus_space_write_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_region_stream_1(t, h, o, v, c) \
+ bus_space_set_region_1((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_2(t, h, o, v, c) \
+ bus_space_set_region_2((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_4(t, h, o, v, c) \
+ bus_space_set_region_4((t), (h), (o), (v), (c))
+
+#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
+
#endif /* _I386_BUS_H_ */
==== //depot/projects/sparc64/sys/i386/include/endian.h#6 - /home/tmm/p4/sparc64/sys/i386/include/endian.h ====
--- /tmp/tmp.13288.10 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/i386/include/endian.h Tue Feb 19 22:13:17 2002
@@ -58,12 +58,11 @@
#define BYTE_ORDER LITTLE_ENDIAN
#endif /* ! _POSIX_SOURCE */
+#ifdef _KERNEL
#ifdef __GNUC__
-__BEGIN_DECLS
-
static __inline __uint32_t
-__htonl(__uint32_t __x)
+__bswap32(__uint32_t __x)
{
#if defined(_KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU)
__asm ("bswap %0" : "+r" (__x));
@@ -77,28 +76,16 @@
}
static __inline __uint16_t
-__htons(__uint16_t __x)
+__bswap16(__uint16_t __x)
{
__asm ("xchgb %h0, %b0" : "+q" (__x));
return __x;
}
-static __inline __uint32_t
-__ntohl(__uint32_t __x)
-{
-
- return (__htonl(__x));
-}
-
-static __inline __uint16_t
-__ntohs(__uint16_t __x)
-{
-
- return (__htons(__x));
-}
-
-__END_DECLS
+#define bswap16(x) __bswap16(x)
+#define bswap32(x) __bswap32(x)
+#endif /* _KERNEL */
#endif /* __GNUC__ */
==== //depot/projects/sparc64/sys/ia64/include/bus.h#1 - /home/tmm/p4/sparc64/sys/ia64/include/bus.h ====
--- /tmp/tmp.13288.11 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/ia64/include/bus.h Wed Feb 20 01:42:54 2002
@@ -1000,6 +1000,70 @@
#endif
}
+/*
+ * Stream accesses are the same as normal accesses on ia64; there are no
+ * supported bus systems with an endianess different from the host one.
+ */
+#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
+#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
+#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
+
+#define bus_space_read_multi_stream_1(t, h, o, a, c) \
+ bus_space_read_multi_1((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_2(t, h, o, a, c) \
+ bus_space_read_multi_2((t), (h), (o), (a), (c))
+#define bus_space_read_multi_stream_4(t, h, o, a, c) \
+ bus_space_read_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_stream_1(t, h, o, v) \
+ bus_space_write_1((t), (h), (o), (v))
+#define bus_space_write_stream_2(t, h, o, v) \
+ bus_space_write_2((t), (h), (o), (v))
+#define bus_space_write_stream_4(t, h, o, v) \
+ bus_space_write_4((t), (h), (o), (v))
+
+#define bus_space_write_multi_stream_1(t, h, o, a, c) \
+ bus_space_write_multi_1((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_2(t, h, o, a, c) \
+ bus_space_write_multi_2((t), (h), (o), (a), (c))
+#define bus_space_write_multi_stream_4(t, h, o, a, c) \
+ bus_space_write_multi_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_multi_stream_1(t, h, o, v, c) \
+ bus_space_set_multi_1((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_2(t, h, o, v, c) \
+ bus_space_set_multi_2((t), (h), (o), (v), (c))
+#define bus_space_set_multi_stream_4(t, h, o, v, c) \
+ bus_space_set_multi_4((t), (h), (o), (v), (c))
+
+#define bus_space_read_region_stream_1(t, h, o, a, c) \
+ bus_space_read_region_1((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_2(t, h, o, a, c) \
+ bus_space_read_region_2((t), (h), (o), (a), (c))
+#define bus_space_read_region_stream_4(t, h, o, a, c) \
+ bus_space_read_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_write_region_stream_1(t, h, o, a, c) \
+ bus_space_write_region_1((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_2(t, h, o, a, c) \
+ bus_space_write_region_2((t), (h), (o), (a), (c))
+#define bus_space_write_region_stream_4(t, h, o, a, c) \
+ bus_space_write_region_4((t), (h), (o), (a), (c))
+
+#define bus_space_set_region_stream_1(t, h, o, v, c) \
+ bus_space_set_region_1((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_2(t, h, o, v, c) \
+ bus_space_set_region_2((t), (h), (o), (v), (c))
+#define bus_space_set_region_stream_4(t, h, o, v, c) \
+ bus_space_set_region_4((t), (h), (o), (v), (c))
+
+#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
+#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
+ bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
+
#endif /* defined(_MACHINE_BUS_PIO_H_) || defined(_MACHINE_BUS_MEMIO_H_) */
#if 0 /* Cause a link error for bus_space_copy_8 */
==== //depot/projects/sparc64/sys/ia64/include/endian.h#5 - /home/tmm/p4/sparc64/sys/ia64/include/endian.h ====
--- /tmp/tmp.13288.12 Wed Feb 20 01:53:49 2002
+++ /home/tmm/p4/sparc64/sys/ia64/include/endian.h Tue Feb 19 22:12:11 2002
@@ -59,10 +59,9 @@
#define BYTE_ORDER LITTLE_ENDIAN
#endif /* !_POSIX_SOURCE */
+#ifdef _KERNEL
#ifdef __GNUC__
-__BEGIN_DECLS
-
static __inline __uint64_t
__uint8_swap_uint64(__uint64_t __x)
{
@@ -73,35 +72,29 @@
}
static __inline __uint32_t
-__htonl(__uint32_t __x)
-{
-
- return (__uint8_swap_uint64(__x) >> 32);
-}
-
-static __inline __uint16_t
-__htons(__uint16_t __x)
-{
-
- return (__uint8_swap_uint64(__x) >> 48);
-}
-
-static __inline __uint32_t
-__ntohl(__uint32_t __x)
+__bswap32(__uint32_t __x)
{
return (__uint8_swap_uint64(__x) >> 32);
}
static __inline __uint16_t
-__ntohs(__uint16_t __x)
+__bswap16(__uint16_t __x)
{
return (__uint8_swap_uint64(__x) >> 48);
}
-__END_DECLS
+#define bswap64(x) __uint8_swap_uint64(x)
+#endif
+#else /* __GNUC__ */
+__uint16_t __bswap16(__uint16_t);
+__uint32_t __bswap32(__uint32_t);
#endif /* __GNUC__ */
+
+#define bswap16(x) __bswap16(x)
+#define bswap32(x) __bswap32(x)
+#endif /* _KERNEL */
#endif /* !_MACHINE_ENDIAN_H_ */
==== //depot/projects/sparc64/sys/libkern/alpha/byte_swap_2.S#2 - /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_2.S ====
--- /tmp/tmp.13288.14 Wed Feb 20 01:53:50 2002
+++ /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_2.S Tue Feb 19 20:06:20 2002
@@ -30,8 +30,8 @@
#include <machine/asm.h>
-#if !defined(ALIAS) || !defined(NAME)
-#error ALIAS or NAME not defined
+#ifndef NAME
+#error NAME not defined
#endif
/*
@@ -39,7 +39,6 @@
*
* Argument is an unsigned 2-byte integer (u_int16_t).
*/
-XLEAF(ALIAS, 1)
LEAF(NAME, 1) /* a0 contains 0x0123 */
extbl a0, 0, t0 /* t0 = 0x 23 */
extbl a0, 1, t1 /* t1 = 0x 01 */
==== //depot/projects/sparc64/sys/libkern/alpha/byte_swap_4.S#2 - /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_4.S ====
--- /tmp/tmp.13288.15 Wed Feb 20 01:53:50 2002
+++ /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_4.S Tue Feb 19 20:06:52 2002
@@ -30,8 +30,8 @@
#include <machine/asm.h>
-#if !defined(ALIAS) || !defined(NAME)
-#error ALIAS or NAME not defined
+#ifndef NAME
+#error NAME not defined
#endif
/*
@@ -39,7 +39,6 @@
*
* Argument is an unsigned 4-byte integer (u_int32_t).
*/
-XLEAF(ALIAS, 1)
LEAF(NAME, 1) /* a0 contains 0x01234567 */
extbl a0, 0, t0 /* t0 = 0x 67 */
extbl a0, 1, t1 /* t1 = 0x 45 */
==== //depot/projects/sparc64/sys/libkern/ia64/byte_swap_2.S#3 - /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_2.S ====
--- /tmp/tmp.13288.16 Wed Feb 20 01:53:50 2002
+++ /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_2.S Tue Feb 19 20:04:55 2002
@@ -30,8 +30,8 @@
#include <machine/asm.h>
-#if !defined(ALIAS) || !defined(NAME)
-#error ALIAS or NAME not defined
+#ifndef NAME
+#error NAME not defined
#endif
/*
@@ -39,7 +39,6 @@
*
* Argument is an unsigned 2-byte integer (u_int16_t).
*/
-WEAK_ALIAS(ALIAS, NAME)
ENTRY(NAME, 1)
mux1 r16=in0,@rev
;;
==== //depot/projects/sparc64/sys/libkern/ia64/byte_swap_4.S#3 - /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_4.S ====
--- /tmp/tmp.13288.17 Wed Feb 20 01:53:50 2002
+++ /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_4.S Tue Feb 19 20:05:25 2002
@@ -30,8 +30,8 @@
#include <machine/asm.h>
-#if !defined(ALIAS) || !defined(NAME)
-#error ALIAS or NAME not defined
+#ifndef NAME
+#error NAME not defined
#endif
/*
@@ -39,7 +39,6 @@
*
* Argument is an unsigned 4-byte integer (u_int32_t).
*/
-WEAK_ALIAS(ALIAS, NAME)
ENTRY(NAME, 1)
mux1 r16=in0,@rev
;;
==== //depot/projects/sparc64/sys/powerpc/include/endian.h#3 - /home/tmm/p4/sparc64/sys/powerpc/include/endian.h ====
--- /tmp/tmp.13288.18 Wed Feb 20 01:53:51 2002
+++ /home/tmm/p4/sparc64/sys/powerpc/include/endian.h Tue Feb 19 21:18:12 2002
@@ -60,18 +60,6 @@
#ifndef _KERNEL
#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-__uint32_t __htonl __P((__uint32_t));
-__uint16_t __htons __P((__uint16_t));
-__uint32_t __ntohl __P((__uint32_t));
-__uint16_t __ntohs __P((__uint16_t));
-__END_DECLS
#endif /* _KERNEL */
-
-#define __htonl(x) (x)
-#define __htons(x) (x)
-#define __ntohl(x) (x)
-#define __ntohs(x) (x)
#endif /* !_MACHINE_ENDIAN_H_ */
==== //depot/projects/sparc64/sys/sparc64/include/endian.h#8 - /home/tmm/p4/sparc64/sys/sparc64/include/endian.h ====
--- /tmp/tmp.13288.19 Wed Feb 20 01:53:51 2002
+++ /home/tmm/p4/sparc64/sys/sparc64/include/endian.h Tue Feb 19 20:38:23 2002
@@ -57,59 +57,4 @@
#define BYTE_ORDER BIG_ENDIAN
#endif /* !_POSIX_SOURCE */
-#define __htonl(x) (x)
-#define __htons(x) (x)
-#define __ntohl(x) (x)
-#define __ntohs(x) (x)
-
-__BEGIN_DECLS
-__uint16_t bswap16 __P((__uint16_t));
-__uint32_t bswap32 __P((__uint32_t));
-__uint64_t bswap64 __P((__uint64_t));
-__END_DECLS
-
-#ifdef _KERNEL
-/* XXX: these three macros should be moved! */
-static __inline __uint16_t
-__swap16(__uint16_t x)
-{
- return ((x >> 8) | ((x << 8) & 0xff00U));
-}
-
-static __inline __uint32_t
-__swap32(__uint32_t x)
-{
- return ((x >> 24) | ((x >> 8) & 0xff00U) | ((x << 8) & 0xff0000U) |
- ((x << 24) & 0xff000000U));
-}
-
-static __inline __uint64_t
-__swap64(__uint64_t x)
-{
- return ((x >> 56) | ((x >> 40) & 0xff00UL) | ((x >> 24) & 0xff0000UL) |
- ((x >> 8) & 0xff000000UL) | ((x << 8) & 0xff00000000UL) |
- ((x << 24) & 0xff0000000000UL) | ((x << 40) & 0xff000000000000UL) |
- ((x << 56)));
-}
-
-#define htobe16(x) (x)
-#define htobe32(x) (x)
-#define htobe64(x) (x)
-#define htole16(x) __swap16((x))
-#define htole32(x) __swap32((x))
-#define htole64(x) __swap64((x))
-
-#define be16toh(x) (x)
-#define be32toh(x) (x)
-#define be64toh(x) (x)
-#define le16toh(x) __swap16((x))
-#define le32toh(x) __swap32((x))
-#define le64toh(x) __swap64((x))
-
-#define bswap16(x) __swap16((x))
-#define bswap32(x) __swap32((x))
-#define bswap64(x) __swap64((x))
-
-#endif
-
#endif /* !_MACHINE_ENDIAN_H_ */
==== //depot/projects/sparc64/sys/sys/imgact_aout.h#3 - /home/tmm/p4/sparc64/sys/sys/imgact_aout.h ====
--- /tmp/tmp.13288.20 Wed Feb 20 01:53:51 2002
+++ /home/tmm/p4/sparc64/sys/sys/imgact_aout.h Wed Feb 20 00:51:10 2002
@@ -50,13 +50,13 @@
((mag) & 0xffff) )
#define N_GETMAGIC_NET(ex) \
- (__ntohl((ex).a_midmag) & 0xffff)
+ (ntohl((ex).a_midmag) & 0xffff)
#define N_GETMID_NET(ex) \
- ((__ntohl((ex).a_midmag) >> 16) & 0x03ff)
+ ((ntohl((ex).a_midmag) >> 16) & 0x03ff)
#define N_GETFLAG_NET(ex) \
- ((__ntohl((ex).a_midmag) >> 26) & 0x3f)
+ ((ntohl((ex).a_midmag) >> 26) & 0x3f)
#define N_SETMAGIC_NET(ex,mag,mid,flag) \
- ( (ex).a_midmag = __htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \
+ ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \
| (((mag)&0xffff)) ) )
#define N_ALIGN(ex,x) \
==== //depot/projects/sparc64/sys/sys/mchain.h#2 - /home/tmm/p4/sparc64/sys/sys/mchain.h ====
--- /tmp/tmp.13288.21 Wed Feb 20 01:53:51 2002
+++ /home/tmm/p4/sparc64/sys/sys/mchain.h Tue Feb 19 22:22:06 2002
@@ -36,6 +36,28 @@
#include <machine/endian.h>
+#ifdef _KERNEL
+
+/*
+ * XXX: remove these defines and change the function calls in the code. Use
+ * it unconditionally if (when) the extended byte order functions become
+ * available in user space.
+ */
+#define htoles(x) htole16((x))
+#define letohs(x) le16toh((x))
+#define htolel(x) htole32((x))
+#define letohl(x) le32toh((x))
+#define htoleq(x) htole64((int64_t)(x))
+#define letohq(x) le64toh((int64_t)(x))
+
+#define htobes(x) htobe16((x))
+#define betohs(x) be16toh((x))
+#define htobel(x) htobe32((x))
+#define betohl(x) be32toh((x))
+#define htobeq(x) htobe64((int64_t)(x))
+#define betohq(x) be64toh((int64_t)(x))
+
+#else
/*
* This macros probably belongs to the endian.h
*/
@@ -78,6 +100,7 @@
#define letohl(x) ((u_int32_t)(x))
*/
#endif /* (BYTE_ORDER == LITTLE_ENDIAN) */
+#endif /* _KERNEL */
#ifdef _KERNEL
==== //depot/projects/sparc64/sys/sys/param.h#10 - /home/tmm/p4/sparc64/sys/sys/param.h ====
--- /tmp/tmp.13288.22 Wed Feb 20 01:53:51 2002
+++ /home/tmm/p4/sparc64/sys/sys/param.h Wed Feb 20 01:20:02 2002
@@ -188,28 +188,110 @@
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
+#ifdef _KERNEL
+/*
+ * Extended byte order support functions, for kernel use only currently.
+ * First, generic implementation of the byte swapping functions for those
+ * architectures that do not have optimized variants of each.
+ */
+
+#ifndef bswap16
+static __inline __uint16_t
+__bswap16(__uint16_t x)
+{
+ return ((x >> 8) | ((x << 8) & 0xff00U));
+}
+#define bswap16(x) __bswap16(x)
+#endif
+
+#ifndef bswap32
+static __inline __uint32_t
+__bswap32(__uint32_t x)
+{
+ return ((x >> 24) | ((x >> 8) & 0xff00U) | ((x << 8) & 0xff0000U) |
+ ((x << 24) & 0xff000000U));
+}
+#define bswap32(x) __bswap32(x)
+#endif
+
+#ifndef bswap64
+static __inline __uint64_t
+__bswap64(__uint64_t x)
+{
+ return ((x >> 56) | ((x >> 40) & 0xff00UL) | ((x >> 24) & 0xff0000UL) |
+ ((x >> 8) & 0xff000000UL) | ((x << 8) & 0xff00000000UL) |
+ ((x << 24) & 0xff0000000000UL) | ((x << 40) & 0xff000000000000UL) |
+ ((x << 56)));
+}
+#define bswap64(x) __bswap64(x)
+#endif
+
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define _BYTEORDER_FUNC_DEFINED
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define htobe16(x) bswap16((x))
+#define htobe32(x) bswap32((x))
+#define htobe64(x) bswap64((x))
+#define htole16(x) ((__uint16_t)(x))
+#define htole32(x) ((__uint32_t)(x))
+#define htole64(x) ((__uint64_t)(x))
+
+#define be16toh(x) bswap16((x))
+#define be32toh(x) bswap32((x))
+#define be64toh(x) bswap64((x))
+#define le16toh(x) ((__uint16_t)(x))
+#define le32toh(x) ((__uint32_t)(x))
+#define le64toh(x) ((__uint64_t)(x))
+#else /* BYTE_ORDER */
+#define htobe16(x) ((__uint16_t)(x))
+#define htobe32(x) ((__uint32_t)(x))
+#define htobe64(x) ((__uint64_t)(x))
+#define htole16(x) bswap16((x))
+#define htole32(x) bswap32((x))
+#define htole64(x) bswap64((x))
+
+#define be16toh(x) ((__uint16_t)(x))
+#define be32toh(x) ((__uint32_t)(x))
+#define be64toh(x) ((__uint64_t)(x))
+#define le16toh(x) bswap16((x))
+#define le32toh(x) bswap32((x))
+#define le64toh(x) bswap64((x))
+#endif /* BYTE_ORDER */
+
+#define htonl(x) htobe32((x))
+#define htons(x) htobe16((x))
+#define ntohl(x) be32toh((x))
+#define ntohs(x) be16toh((x))
+#endif /* _BYTEORDER_FUNC_DEFINED */
+
+#else /* _KERNEL */
/*
- * Kernel exposed versions of byteorder(3) functions.
- *
* XXX this section should only be defined in the kernel, but some userland
* software utilizes it.
*/
#ifndef _BYTEORDER_FUNC_DEFINED
#define _BYTEORDER_FUNC_DEFINED
+__BEGIN_DECLS
+__uint32_t __htonl __P((__uint32_t));
+__uint16_t __htons __P((__uint16_t));
+__uint32_t __ntohl __P((__uint32_t));
+__uint16_t __ntohs __P((__uint16_t));
+__END_DECLS
#define htonl(x) __htonl(x)
#define htons(x) __htons(x)
#define ntohl(x) __ntohl(x)
#define ntohs(x) __ntohs(x)
-#endif
+#endif /* BYTEORDER_FUNC_DEFINED */
+#endif /* _KERNEL */
/*
* XXX deprecated uppercase variants for byteorder(3) functions.
*/
#ifndef _POSIX_SOURCE
-#define NTOHL(x) ((x) = __ntohl(x))
-#define NTOHS(x) ((x) = __ntohs(x))
-#define HTONL(x) ((x) = __htonl(x))
-#define HTONS(x) ((x) = __htons(x))
+#define NTOHL(x) ((x) = ntohl(x))
+#define NTOHS(x) ((x) = ntohs(x))
+#define HTONL(x) ((x) = htonl(x))
+#define HTONS(x) ((x) = htons(x))
#endif /* _POSIX_SOURCE */
/*
--- /dev/null Wed Feb 20 01:47:07 2002
+++ /home/tmm/p4/sparc64/sys/libkern/alpha/bswap16.S Tue Feb 19 20:08:13 2002
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * from: NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd
+ * from: src/sys/libkern/alpha/htons.S,v 1.3 2002/02/18 20:35:21
+ *
+ * $FreeBSD$
+ */
+
+#define NAME __bswap16
+
+#include <libkern/alpha/byte_swap_2.S>
--- /dev/null Wed Feb 20 01:47:07 2002
+++ /home/tmm/p4/sparc64/sys/libkern/alpha/bswap32.S Tue Feb 19 20:09:52 2002
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
+ * from: src/sys/libkern/alpha/htonl.S,v 1.3 2002/02/18 20:35:21
+ *
+ * $FreeBSD$
+ */
+
+#define NAME __bswap32
+
+#include <libkern/alpha/byte_swap_4.S>
--- /dev/null Wed Feb 20 01:47:07 2002
+++ /home/tmm/p4/sparc64/sys/libkern/ia64/bswap16.S Tue Feb 19 20:11:47 2002
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * from: NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd
+ * from: src/sys/libkern/ia64/htons.S,v 1.2 2002/02/18 20:35:21
+ *
+ * $FreeBSD$
+ */
+
+#define NAME __bswap16
+
+#include <libkern/ia64/byte_swap_2.S>
--- /dev/null Wed Feb 20 01:47:07 2002
+++ /home/tmm/p4/sparc64/sys/libkern/ia64/bswap32.S Tue Feb 19 20:13:03 2002
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
+ * from: src/sys/libkern/ia64/htonl.S,v 1.2 2002/02/18 20:35:21
+ *
+ * $FreeBSD$
+ */
+
+#define NAME __bswap32
+
+#include <libkern/ia64/byte_swap_4.S>
--- freebsd/sys/dev/usb/usb_port.h Fri Feb 8 01:54:08 2002
+++ /home/tmm/p4/sparc64/sys/dev/usb/usb_port.h Wed Feb 20 00:43:17 2002
@@ -305,7 +305,6 @@
/* XXX Change this when FreeBSD has memset */
#define memcpy(d, s, l) bcopy((s),(d),(l))
#define memset(d, v, l) bzero((d),(l))
-#define bswap32(x) swap32(x)
#define kthread_create1(f, s, p, a0, a1) \
kthread_create((f), (s), (p), RFHIGHPID, (a0), (a1))
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020220031842.GF282>
