summaryrefslogtreecommitdiffstats
path: root/sys/libkern/alpha
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2002-02-27 17:16:18 +0000
committertmm <tmm@FreeBSD.org>2002-02-27 17:16:18 +0000
commit3ed05b7b8966710c5cffbf0ba479dd2e07c91c0a (patch)
tree46353f300fd15b6b132ccde617d8726a2e38d224 /sys/libkern/alpha
parente9d577adb2ffdd3b7300415775c1212a087ce0dc (diff)
downloadFreeBSD-src-3ed05b7b8966710c5cffbf0ba479dd2e07c91c0a.zip
FreeBSD-src-3ed05b7b8966710c5cffbf0ba479dd2e07c91c0a.tar.gz
Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using interfaces compatible to NetBSD): - bwap16() and bswap32(). These have optimized implementations on some architectures; for those that don't, there exist generic implementations. - macros to convert from a certain byte order to host byte order and vice versa, using a naming scheme like le16toh(), htole16(). These are implemented using the bswap functions. - stream bus space access functions, which do not perform a byte order conversion (while the normal access functions would if the bus endianess differs from the CPU endianess). htons(), htonl(), ntohs() and ntohl() are implemented using the new functions above for kernel usage. None of the above interfaces is currently exported to user land. Make use of the new functions in a few places where local implementations of the same functionality existed. Reviewed by: mike, bde Tested on alpha by: mike
Diffstat (limited to 'sys/libkern/alpha')
-rw-r--r--sys/libkern/alpha/bswap16.S (renamed from sys/libkern/alpha/htons.S)11
-rw-r--r--sys/libkern/alpha/bswap32.S (renamed from sys/libkern/alpha/htonl.S)13
-rw-r--r--sys/libkern/alpha/byte_swap_2.S5
-rw-r--r--sys/libkern/alpha/byte_swap_4.S5
-rw-r--r--sys/libkern/alpha/ntohl.S34
-rw-r--r--sys/libkern/alpha/ntohs.S34
6 files changed, 17 insertions, 85 deletions
diff --git a/sys/libkern/alpha/htons.S b/sys/libkern/alpha/bswap16.S
index 6b8ea16..98cf054 100644
--- a/sys/libkern/alpha/htons.S
+++ b/sys/libkern/alpha/bswap16.S
@@ -1,6 +1,3 @@
-/* $FreeBSD$ */
-/* $NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd Exp $ */
-
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
@@ -26,9 +23,13 @@
*
* 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 ALIAS htons
-#define NAME __htons
+#define NAME __bswap16
#include <libkern/alpha/byte_swap_2.S>
diff --git a/sys/libkern/alpha/htonl.S b/sys/libkern/alpha/bswap32.S
index 2604034..bc1b127 100644
--- a/sys/libkern/alpha/htonl.S
+++ b/sys/libkern/alpha/bswap32.S
@@ -1,6 +1,3 @@
-/* $FreeBSD$ */
-/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd Exp $ */
-
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
@@ -25,10 +22,14 @@
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
+ * 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 ALIAS htonl
-#define NAME __htonl
+#define NAME __bswap32
#include <libkern/alpha/byte_swap_4.S>
diff --git a/sys/libkern/alpha/byte_swap_2.S b/sys/libkern/alpha/byte_swap_2.S
index 8111918..613eef6 100644
--- a/sys/libkern/alpha/byte_swap_2.S
+++ b/sys/libkern/alpha/byte_swap_2.S
@@ -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 */
diff --git a/sys/libkern/alpha/byte_swap_4.S b/sys/libkern/alpha/byte_swap_4.S
index d31bbe8..2a66f17 100644
--- a/sys/libkern/alpha/byte_swap_4.S
+++ b/sys/libkern/alpha/byte_swap_4.S
@@ -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 */
diff --git a/sys/libkern/alpha/ntohl.S b/sys/libkern/alpha/ntohl.S
deleted file mode 100644
index 590203a..0000000
--- a/sys/libkern/alpha/ntohl.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:36:57 cgd Exp $ */
-
-/*
- * 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.
- */
-
-#define ALIAS ntohl
-#define NAME __ntohl
-
-#include <libkern/alpha/byte_swap_4.S>
diff --git a/sys/libkern/alpha/ntohs.S b/sys/libkern/alpha/ntohs.S
deleted file mode 100644
index 9306881..0000000
--- a/sys/libkern/alpha/ntohs.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:37:02 cgd Exp $ */
-
-/*
- * 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.
- */
-
-#define ALIAS ntohs
-#define NAME __ntohs
-
-#include <libkern/alpha/byte_swap_2.S>
OpenPOWER on IntegriCloud