diff options
author | fishsoupisgood <github@madingley.org> | 2019-04-29 01:17:54 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2019-05-27 03:43:43 +0100 |
commit | 3f2546b2ef55b661fd8dd69682b38992225e86f6 (patch) | |
tree | 65ca85f13617aee1dce474596800950f266a456c /roms/ipxe/src/arch/x86_64/include/bits | |
download | qemu-master.tar.gz qemu-master.tar.bz2 qemu-master.zip |
Diffstat (limited to 'roms/ipxe/src/arch/x86_64/include/bits')
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/byteswap.h | 47 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/compiler.h | 14 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/endian.h | 6 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/entropy.h | 12 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/linux_api.h | 6 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/nap.h | 12 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/profile.h | 29 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/reboot.h | 12 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/sanboot.h | 12 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/smbios.h | 10 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/stdint.h | 21 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/strings.h | 42 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/time.h | 12 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/timer.h | 10 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/uaccess.h | 10 | ||||
-rw-r--r-- | roms/ipxe/src/arch/x86_64/include/bits/umalloc.h | 10 |
16 files changed, 265 insertions, 0 deletions
diff --git a/roms/ipxe/src/arch/x86_64/include/bits/byteswap.h b/roms/ipxe/src/arch/x86_64/include/bits/byteswap.h new file mode 100644 index 00000000..2e472d98 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/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 ); + +static inline __attribute__ (( always_inline, const )) uint16_t +__bswap_variable_16 ( uint16_t x ) { + __asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_16s ( uint16_t *x ) { + __asm__ ( "rorw $8, %0" : "+m" ( *x ) ); +} + +static inline __attribute__ (( always_inline, const )) uint32_t +__bswap_variable_32 ( uint32_t x ) { + __asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_32s ( uint32_t *x ) { + __asm__ ( "bswapl %k0" : "=r" ( *x ) : "0" ( *x ) ); +} + +static inline __attribute__ (( always_inline, const )) uint64_t +__bswap_variable_64 ( uint64_t x ) { + __asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) ); + return x; +} + +static inline __attribute__ (( always_inline )) void +__bswap_64s ( uint64_t *x ) { + __asm__ ( "bswapq %q0" : "=r" ( *x ) : "0" ( *x ) ); +} + +#endif /* _BITS_BYTESWAP_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/compiler.h b/roms/ipxe/src/arch/x86_64/include/bits/compiler.h new file mode 100644 index 00000000..51a7eaae --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/compiler.h @@ -0,0 +1,14 @@ +#ifndef _BITS_COMPILER_H +#define _BITS_COMPILER_H + +#ifndef ASSEMBLY + +/** Declare a function with standard calling conventions */ +#define __asmcall __attribute__ (( regparm(0) )) + +/** Declare a function with libgcc implicit linkage */ +#define __libgcc + +#endif /* ASSEMBLY */ + +#endif /* _BITS_COMPILER_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/endian.h b/roms/ipxe/src/arch/x86_64/include/bits/endian.h new file mode 100644 index 00000000..413e702d --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/endian.h @@ -0,0 +1,6 @@ +#ifndef ETHERBOOT_BITS_ENDIAN_H +#define ETHERBOOT_BITS_ENDIAN_H + +#define __BYTE_ORDER __LITTLE_ENDIAN + +#endif /* ETHERBOOT_BITS_ENDIAN_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/entropy.h b/roms/ipxe/src/arch/x86_64/include/bits/entropy.h new file mode 100644 index 00000000..9c64c833 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/entropy.h @@ -0,0 +1,12 @@ +#ifndef _BITS_ENTROPY_H +#define _BITS_ENTROPY_H + +/** @file + * + * x86_64-specific entropy API implementations + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#endif /* _BITS_ENTROPY_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/linux_api.h b/roms/ipxe/src/arch/x86_64/include/bits/linux_api.h new file mode 100644 index 00000000..589fb580 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/linux_api.h @@ -0,0 +1,6 @@ +#ifndef _X86_64_LINUX_API_H +#define _X86_64_LINUX_API_H + +#define __SYSCALL_mmap __NR_mmap + +#endif /* _X86_64_LINUX_API_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/nap.h b/roms/ipxe/src/arch/x86_64/include/bits/nap.h new file mode 100644 index 00000000..8b42c0a4 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/nap.h @@ -0,0 +1,12 @@ +#ifndef _BITS_NAP_H +#define _BITS_NAP_H + +/** @file + * + * x86_64-specific CPU sleeping API implementations + * + */ + +#include <ipxe/efi/efix86_nap.h> + +#endif /* _BITS_MAP_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/profile.h b/roms/ipxe/src/arch/x86_64/include/bits/profile.h new file mode 100644 index 00000000..6fc16d84 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/profile.h @@ -0,0 +1,29 @@ +#ifndef _BITS_PROFILE_H +#define _BITS_PROFILE_H + +/** @file + * + * Profiling + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <stdint.h> + +/** + * Get profiling timestamp + * + * @ret timestamp Timestamp + */ +static inline __attribute__ (( always_inline )) uint64_t +profile_timestamp ( void ) { + uint32_t eax; + uint32_t edx; + + /* Read timestamp counter */ + __asm__ __volatile__ ( "rdtsc" : "=a" ( eax ), "=d" ( edx ) ); + return ( ( ( ( uint64_t ) edx ) << 32 ) | eax ); +} + +#endif /* _BITS_PROFILE_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/reboot.h b/roms/ipxe/src/arch/x86_64/include/bits/reboot.h new file mode 100644 index 00000000..f1bce054 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/reboot.h @@ -0,0 +1,12 @@ +#ifndef _BITS_REBOOT_H +#define _BITS_REBOOT_H + +/** @file + * + * x86_64-specific reboot API implementations + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#endif /* _BITS_REBOOT_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/sanboot.h b/roms/ipxe/src/arch/x86_64/include/bits/sanboot.h new file mode 100644 index 00000000..d33d03cb --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/sanboot.h @@ -0,0 +1,12 @@ +#ifndef _BITS_SANBOOT_H +#define _BITS_SANBOOT_H + +/** @file + * + * x86_64-specific sanboot API implementations + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#endif /* _BITS_SANBOOT_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/smbios.h b/roms/ipxe/src/arch/x86_64/include/bits/smbios.h new file mode 100644 index 00000000..2f0118d0 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/smbios.h @@ -0,0 +1,10 @@ +#ifndef _BITS_SMBIOS_H +#define _BITS_SMBIOS_H + +/** @file + * + * i386-specific SMBIOS API implementations + * + */ + +#endif /* _BITS_SMBIOS_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/stdint.h b/roms/ipxe/src/arch/x86_64/include/bits/stdint.h new file mode 100644 index 00000000..9eb72e9c --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/stdint.h @@ -0,0 +1,21 @@ +#ifndef _BITS_STDINT_H +#define _BITS_STDINT_H + +typedef __SIZE_TYPE__ size_t; +typedef signed long ssize_t; +typedef signed long off_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; + +typedef unsigned long physaddr_t; +typedef unsigned long intptr_t; + +#endif /* _BITS_STDINT_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/strings.h b/roms/ipxe/src/arch/x86_64/include/bits/strings.h new file mode 100644 index 00000000..6ee99a50 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/strings.h @@ -0,0 +1,42 @@ +#ifndef _BITS_STRINGS_H +#define _BITS_STRINGS_H + +FILE_LICENCE ( GPL2_OR_LATER ); + +/** + * Find last (i.e. most significant) set bit + * + * @v value Value + * @ret msb Most significant bit set in value (LSB=1), or zero + */ +static inline __attribute__ (( always_inline )) int __flsll ( long long value ){ + long long msb_minus_one; + + /* If the input value is zero, the BSR instruction returns + * ZF=1 and leaves an undefined value in the output register. + * Perform this check in C rather than asm so that it can be + * omitted in cases where the compiler is able to prove that + * the input is non-zero. + */ + if ( value ) { + __asm__ ( "bsrq %1, %0" + : "=r" ( msb_minus_one ) + : "rm" ( value ) ); + return ( msb_minus_one + 1 ); + } else { + return 0; + } +} + +/** + * Find last (i.e. most significant) set bit + * + * @v value Value + * @ret msb Most significant bit set in value (LSB=1), or zero + */ +static inline __attribute__ (( always_inline )) int __flsl ( long value ) { + + return __flsll ( value ); +} + +#endif /* _BITS_STRINGS_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/time.h b/roms/ipxe/src/arch/x86_64/include/bits/time.h new file mode 100644 index 00000000..59b35535 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/time.h @@ -0,0 +1,12 @@ +#ifndef _BITS_TIME_H +#define _BITS_TIME_H + +/** @file + * + * x86_64-specific time API implementations + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#endif /* _BITS_TIME_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/timer.h b/roms/ipxe/src/arch/x86_64/include/bits/timer.h new file mode 100644 index 00000000..dfa6c270 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/timer.h @@ -0,0 +1,10 @@ +#ifndef _BITS_TIMER_H +#define _BITS_TIMER_H + +/** @file + * + * x86_64-specific timer API implementations + * + */ + +#endif /* _BITS_TIMER_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/uaccess.h b/roms/ipxe/src/arch/x86_64/include/bits/uaccess.h new file mode 100644 index 00000000..45582924 --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/uaccess.h @@ -0,0 +1,10 @@ +#ifndef _BITS_UACCESS_H +#define _BITS_UACCESS_H + +/** @file + * + * x86_64-specific user access API implementations + * + */ + +#endif /* _BITS_UACCESS_H */ diff --git a/roms/ipxe/src/arch/x86_64/include/bits/umalloc.h b/roms/ipxe/src/arch/x86_64/include/bits/umalloc.h new file mode 100644 index 00000000..12bf949d --- /dev/null +++ b/roms/ipxe/src/arch/x86_64/include/bits/umalloc.h @@ -0,0 +1,10 @@ +#ifndef _BITS_UMALLOC_H +#define _BITS_UMALLOC_H + +/** @file + * + * x86_64-specific user memory allocation API implementations + * + */ + +#endif /* _BITS_UMALLOC_H */ |