From owner-freebsd-arch Thu Feb 21 19:35:41 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by hub.freebsd.org (Postfix) with SMTP id 5F89C37B400 for ; Thu, 21 Feb 2002 19:34:59 -0800 (PST) Received: (qmail 30681 invoked by uid 0); 22 Feb 2002 03:34:55 -0000 Received: from pd9e16b60.dip.t-dialin.net (HELO forge.local) (217.225.107.96) by mail.gmx.net (mp009-rz3) with SMTP; 22 Feb 2002 03:34:55 -0000 Received: from tmm by forge.local with local (Exim 3.34 #1) id 16e6U4-0001xA-00 for ; Fri, 22 Feb 2002 04:34:56 +0100 Date: Fri, 22 Feb 2002 04:34:55 +0100 From: Thomas Moestl To: freebsd-arch@FreeBSD.org Subject: Re: adding more endian conversion and bus space functions Message-ID: <20020222033455.GA289@crow.dom2ip.de> Mail-Followup-To: freebsd-arch@FreeBSD.org References: <20020111005207.GA7246@crow.dom2ip.de> <20020220031842.GF282@crow.dom2ip.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020220031842.GF282@crow.dom2ip.de> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 2002/02/20 at 04:18:42 +0100, Thomas Moestl wrote: > 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've attached an updated version of the patch, which implements some helpful suggestions by Mike Barcroft to reduce name space pollution when the new functions will be exposed to userland, as well as some cleanups. This is tested on i386, alpha (buildworld, I hope to get the results of a GENERIC kernel build tomorrow) and sparc64. I'd like to commit it soon if I can get somebody to test it on ia64, hopefully during the weekend. - thomas ==== //depot/projects/sparc64/lib/libstand/Makefile#2 - /home/tmm/p4/sparc64/lib/libstand/Makefile ==== --- /tmp/tmp.8072.0 Thu Feb 21 19:06:07 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.8072.1 Thu Feb 21 19:06:08 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.8072.2 Thu Feb 21 19:06:08 2002 +++ /home/tmm/p4/sparc64/sys/alpha/include/endian.h Thu Feb 21 02:03:21 2002 @@ -56,6 +56,18 @@ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER LITTLE_ENDIAN + +#ifdef _KERNEL +#ifndef _BSWAP16_DEFINED +#define _BSWAP16_DEFINED +__uint16_t __bswap16(__uint16_t); +#endif +#ifndef _BSWAP32_DEFINED +#define _BSWAP32_DEFINED +__uint32_t __bswap32(__uint32_t); +#endif +#endif /* _KERNEL */ + #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.8072.3 Thu Feb 21 19:06:08 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.8072.4 Thu Feb 21 19:06:08 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.8072.5 Thu Feb 21 19:06:09 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.8072.6 Thu Feb 21 19:06:09 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.8072.7 Thu Feb 21 19:06:09 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.8072.8 Thu Feb 21 19:06:10 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.8072.9 Thu Feb 21 19:06:10 2002 +++ /home/tmm/p4/sparc64/sys/i386/include/bus.h Wed Feb 20 01:36:38 2002 @@ -43,4 +43,68 @@ #endif #include +/* + * 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.8072.10 Thu Feb 21 19:06:10 2002 +++ /home/tmm/p4/sparc64/sys/i386/include/endian.h Thu Feb 21 01:53:24 2002 @@ -58,12 +58,13 @@ #define BYTE_ORDER LITTLE_ENDIAN #endif /* ! _POSIX_SOURCE */ +#ifdef _KERNEL #ifdef __GNUC__ -__BEGIN_DECLS - +#ifndef _BSWAP32_DEFINED +#define _BSWAP32_DEFINED 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)); @@ -75,30 +76,20 @@ #endif return __x; } +#endif +#ifndef _BSWAP16_DEFINED +#define _BSWAP16_DEFINED static __inline __uint16_t -__htons(__uint16_t __x) +__bswap16(__uint16_t __x) { __asm ("xchgb %h0, %b0" : "+q" (__x)); return __x; } +#endif -static __inline __uint32_t -__ntohl(__uint32_t __x) -{ - - return (__htonl(__x)); -} - -static __inline __uint16_t -__ntohs(__uint16_t __x) -{ - - return (__htons(__x)); -} - -__END_DECLS +#endif /* _KERNEL */ #endif /* __GNUC__ */ ==== //depot/projects/sparc64/sys/ia64/include/bus.h#1 - /home/tmm/p4/sparc64/sys/ia64/include/bus.h ==== --- /tmp/tmp.8072.11 Thu Feb 21 19:06:10 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.8072.12 Thu Feb 21 19:06:10 2002 +++ /home/tmm/p4/sparc64/sys/ia64/include/endian.h Thu Feb 21 02:14:18 2002 @@ -59,49 +59,54 @@ #define BYTE_ORDER LITTLE_ENDIAN #endif /* !_POSIX_SOURCE */ +#ifdef _KERNEL #ifdef __GNUC__ -__BEGIN_DECLS - +#ifndef _BSWAP64_DEFINED +#define _BSWAP64_DEFINED static __inline __uint64_t -__uint8_swap_uint64(__uint64_t __x) +__bswap64(__uint64_t __x) { __uint64_t __r; __asm __volatile("mux1 %0=%1,@rev" : "=r" (__r) : "r"(__x)); return __r; } +#endif +#ifndef _BSWAP32_DEFINED +#define _BSWAP32_DEFINED 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); + return (__bswap64(__x) >> 32); } +#endif +#ifndef _BSWAP16_DEFINED +#define _BSWAP16_DEFINED static __inline __uint16_t -__ntohs(__uint16_t __x) +__bswap16(__uint16_t __x) { - return (__uint8_swap_uint64(__x) >> 48); + return (__bswap64(__x) >> 48); } -__END_DECLS +#endif +#else /* !__GNUC__ */ +/* XXX: use the libkern versions for now; these might go away soon. */ +#ifndef _BSWAP16_DEFINED +#define _BSWAP16_DEFINED +__uint16_t __bswap16(__uint16_t); +#endif +#ifndef _BSWAP32_DEFINED +#define _BSWAP32_DEFINED +__uint32_t __bswap32(__uint32_t); +#endif #endif /* __GNUC__ */ + +#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.8072.14 Thu Feb 21 19:06:11 2002 +++ /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_2.S Tue Feb 19 20:06:20 2002 @@ -30,8 +30,8 @@ #include -#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.8072.15 Thu Feb 21 19:06:11 2002 +++ /home/tmm/p4/sparc64/sys/libkern/alpha/byte_swap_4.S Tue Feb 19 20:06:52 2002 @@ -30,8 +30,8 @@ #include -#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.8072.16 Thu Feb 21 19:06:11 2002 +++ /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_2.S Tue Feb 19 20:04:55 2002 @@ -30,8 +30,8 @@ #include -#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.8072.17 Thu Feb 21 19:06:11 2002 +++ /home/tmm/p4/sparc64/sys/libkern/ia64/byte_swap_4.S Tue Feb 19 20:05:25 2002 @@ -30,8 +30,8 @@ #include -#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.8072.18 Thu Feb 21 19:06:11 2002 +++ /home/tmm/p4/sparc64/sys/powerpc/include/endian.h Tue Feb 19 21:18:12 2002 @@ -60,18 +60,6 @@ #ifndef _KERNEL #include - -__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.8072.19 Thu Feb 21 19:06:12 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.8072.20 Thu Feb 21 19:06:12 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.8072.21 Thu Feb 21 19:06:12 2002 +++ /home/tmm/p4/sparc64/sys/sys/mchain.h Tue Feb 19 22:22:06 2002 @@ -36,6 +36,28 @@ #include +#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.8072.22 Thu Feb 21 19:06:12 2002 +++ /home/tmm/p4/sparc64/sys/sys/param.h Thu Feb 21 18:58:34 2002 @@ -188,28 +188,92 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) #endif +#ifdef _KERNEL /* - * Kernel exposed versions of byteorder(3) functions. - * - * XXX this section should only be defined in the kernel, but some userland - * software utilizes it. + * 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 _BYTEORDER_FUNC_DEFINED -#define _BYTEORDER_FUNC_DEFINED -#define htonl(x) __htonl(x) -#define htons(x) __htons(x) -#define ntohl(x) __ntohl(x) -#define ntohs(x) __ntohs(x) +#ifndef _BSWAP16_DEFINED +#define _BSWAP16_DEFINED +static __inline __uint16_t +__bswap16(__uint16_t x) +{ + return ((x >> 8) | ((x << 8) & 0xff00U)); +} #endif +#ifndef _BSWAP32_DEFINED +#define _BSWAP32_DEFINED +static __inline __uint32_t +__bswap32(__uint32_t x) +{ + return ((x >> 24) | ((x >> 8) & 0xff00U) | ((x << 8) & 0xff0000U) | + ((x << 24) & 0xff000000U)); +} +#endif + +#ifndef _BSWAP64_DEFINED +#define _BSWAP64_DEFINED +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))); +} +#endif + +#define bswap16(x) __bswap16(x) +#define bswap32(x) __bswap32(x) +#define bswap64(x) __bswap64(x) + +#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 != LITTLE_ENDIAN */ +#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 /* _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 Thu Feb 21 17:45:56 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 --- /dev/null Thu Feb 21 17:45:56 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 --- /dev/null Thu Feb 21 17:45:56 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 --- /dev/null Thu Feb 21 17:45:56 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 --- /home/tmm/p4/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