summaryrefslogtreecommitdiffstats
path: root/sys/dev
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/dev
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/dev')
-rw-r--r--sys/dev/iir/iir.h6
-rw-r--r--sys/dev/usb/ohci.c14
-rw-r--r--sys/dev/usb/uhci.c2
-rw-r--r--sys/dev/usb/usb_port.h1
-rw-r--r--sys/dev/wi/if_wi.c6
5 files changed, 5 insertions, 24 deletions
diff --git a/sys/dev/iir/iir.h b/sys/dev/iir/iir.h
index b165c84..3b325cb 100644
--- a/sys/dev/iir/iir.h
+++ b/sys/dev/iir/iir.h
@@ -372,10 +372,8 @@ extern int ser_printf(const char *fmt, ...);
#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
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 369f246..70675c0 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -96,20 +96,6 @@ int ohcidebug = 1;
#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 *);
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index de4e64f..d01c131 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -112,7 +112,7 @@ int uhcinoloop = 0;
* 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))
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index 642b439..1f4b191 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -314,7 +314,6 @@ typedef struct thread *usb_proc_ptr;
/* 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))
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index 1620593..317a4bc 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -125,11 +125,9 @@ static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 };
#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 *));
OpenPOWER on IntegriCloud