mirror of
https://github.com/xcat2/xNBA.git
synced 2025-08-24 04:00:29 +00:00
Currently the only supported platform for x86_64 is EFI. Building an EFI64 gPXE requires a version of gcc that supports __attribute__((ms_abi)). This currently means a development build of gcc; the feature should be present when gcc 4.4 is released. In the meantime; you can grab a suitable gcc tree from git://git.etherboot.org/scm/people/mcb30/gcc/.git
42 lines
872 B
C
42 lines
872 B
C
#ifndef ETHERBOOT_BITS_BYTESWAP_H
|
|
#define ETHERBOOT_BITS_BYTESWAP_H
|
|
|
|
static inline __attribute__ ((always_inline, const)) uint16_t
|
|
__bswap_variable_16(uint16_t x)
|
|
{
|
|
__asm__("xchgb %b0,%h0\n\t"
|
|
: "=q" (x)
|
|
: "0" (x));
|
|
return x;
|
|
}
|
|
|
|
static inline __attribute__ ((always_inline, const)) uint32_t
|
|
__bswap_variable_32(uint32_t x)
|
|
{
|
|
__asm__("xchgb %b0,%h0\n\t"
|
|
"rorl $16,%0\n\t"
|
|
"xchgb %b0,%h0"
|
|
: "=q" (x)
|
|
: "0" (x));
|
|
return x;
|
|
}
|
|
|
|
static inline __attribute__ ((always_inline, const)) uint64_t
|
|
__bswap_variable_64(uint64_t x)
|
|
{
|
|
union {
|
|
uint64_t qword;
|
|
uint32_t dword[2];
|
|
} u;
|
|
|
|
u.qword = x;
|
|
u.dword[0] = __bswap_variable_32(u.dword[0]);
|
|
u.dword[1] = __bswap_variable_32(u.dword[1]);
|
|
__asm__("xchgl %0,%1"
|
|
: "=r" ( u.dword[0] ), "=r" ( u.dword[1] )
|
|
: "0" ( u.dword[0] ), "1" ( u.dword[1] ) );
|
|
return u.qword;
|
|
}
|
|
|
|
#endif /* ETHERBOOT_BITS_BYTESWAP_H */
|