diff options
| author | Michael Brown | 2016-05-08 01:20:20 +0200 |
|---|---|---|
| committer | Michael Brown | 2016-05-08 01:20:20 +0200 |
| commit | 17c6f322eef5e0a2250a89b140486cf07598d2fa (patch) | |
| tree | c67442d1e56245b42f9e7b98f9fa0e7b9cc24b1d /src/arch/arm64/include/bits/byteswap.h | |
| parent | [arm] Split out 32-bit-specific code to arch/arm32 (diff) | |
| download | ipxe-17c6f322eef5e0a2250a89b140486cf07598d2fa.tar.gz ipxe-17c6f322eef5e0a2250a89b140486cf07598d2fa.tar.xz ipxe-17c6f322eef5e0a2250a89b140486cf07598d2fa.zip | |
[arm] Add support for 64-bit ARM (Aarch64)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/arm64/include/bits/byteswap.h')
| -rw-r--r-- | src/arch/arm64/include/bits/byteswap.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/arch/arm64/include/bits/byteswap.h b/src/arch/arm64/include/bits/byteswap.h new file mode 100644 index 000000000..169d6c20e --- /dev/null +++ b/src/arch/arm64/include/bits/byteswap.h @@ -0,0 +1,47 @@ +#ifndef _BITS_BYTESWAP_H +#define _BITS_BYTESWAP_H + +/** @file + * + * Byte-order swapping functions + * + */ + +#include <stdint.h> + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +static inline __attribute__ (( always_inline, const )) uint16_t +__bswap_variable_16 ( uint16_t x ) { + __asm__ ( "rev16 %0, %1" : "=r" ( x ) : "r" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_16s ( uint16_t *x ) { + *x = __bswap_variable_16 ( *x ); +} + +static inline __attribute__ (( always_inline, const )) uint32_t +__bswap_variable_32 ( uint32_t x ) { + __asm__ ( "rev32 %0, %1" : "=r" ( x ) : "r" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_32s ( uint32_t *x ) { + *x = __bswap_variable_32 ( *x ); +} + +static inline __attribute__ (( always_inline, const )) uint64_t +__bswap_variable_64 ( uint64_t x ) { + __asm__ ( "rev %0, %1" : "=r" ( x ) : "r" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_64s ( uint64_t *x ) { + *x = __bswap_variable_64 ( *x ); +} + +#endif |
