Module Name: src Committed By: matt Date: Sun Jul 15 19:59:48 UTC 2012
Modified Files: src/sys/arch/arm/include: byte_swap.h Log Message: Add BSWAP16 and BSWAP32 macros for use in assembly. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/byte_swap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/include/byte_swap.h diff -u src/sys/arch/arm/include/byte_swap.h:1.9 src/sys/arch/arm/include/byte_swap.h:1.10 --- src/sys/arch/arm/include/byte_swap.h:1.9 Thu Jul 12 17:23:02 2012 +++ src/sys/arch/arm/include/byte_swap.h Sun Jul 15 19:59:48 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: byte_swap.h,v 1.9 2012/07/12 17:23:02 matt Exp $ */ +/* $NetBSD: byte_swap.h,v 1.10 2012/07/15 19:59:48 matt Exp $ */ /*- * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc. @@ -32,6 +32,33 @@ #ifndef _ARM_BYTE_SWAP_H_ #define _ARM_BYTE_SWAP_H_ +#ifdef _LOCORE + +#if (ARM_ARCH_6 + ARM_ARCH_7) > 0 + +#define BSWAP16(_src, _dst, _tmp) \ + rev16 _dst, _src +#define BSWAP32(_src, _dst, _tmp) \ + rev _dst, _src + +#else + +#define BSWAP16(_src, _dst, _tmp) \ + mov _tmp, _src, ror #8 ;\ + orr _tmp, _tmp, _tmp, lsr #16 ;\ + bic _dst, _tmp, _tmp, lsl #16 + +#define BSWAP32(_src, _dst, _tmp) \ + eor _tmp, _src, _src, ror #16 ;\ + bic _tmp, _tmp, #0x00FF0000 ;\ + mov _dst, _src, ror #8 ;\ + eor _dst, _dst, _tmp, lsr #8 + +#endif + + +#else + #ifdef __GNUC__ #include <sys/types.h> __BEGIN_DECLS @@ -87,5 +114,6 @@ __byte_swap_u16_variable(uint16_t v) __END_DECLS #endif +#endif /* _LOCORE */ #endif /* _ARM_BYTE_SWAP_H_ */