| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <aws/common/cpuid.h> |
| 7 |
|
| 8 |
void aws_run_cpuid(uint32_t eax, uint32_t ecx, uint32_t *abcd) { |
| 9 |
uint32_t ebx = 0; |
| 10 |
uint32_t edx = 0; |
| 11 |
|
| 12 |
#if defined(__i386__) && defined(__PIC__) |
| 13 |
|
| 14 |
__asm__ __volatile__("movl %%ebx, %%edi \n\t " |
| 15 |
"cpuid \n\t " |
| 16 |
"xchgl %%ebx, %%edi" |
| 17 |
: "=D"(ebx), |
| 18 |
#else |
| 19 |
__asm__ __volatile__("cpuid" |
| 20 |
: "+b"(ebx), |
| 21 |
#endif |
| 22 |
"+a"(eax), |
| 23 |
"+c"(ecx), |
| 24 |
"=d"(edx)); |
| 25 |
abcd[0] = eax; |
| 26 |
abcd[1] = ebx; |
| 27 |
abcd[2] = ecx; |
| 28 |
abcd[3] = edx; |
| 29 |
} |
| 30 |
|
| 31 |
uint64_t aws_run_xgetbv(uint32_t xcr) { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
uint32_t xcrhigh; |
| 37 |
uint32_t xcrlow; |
| 38 |
__asm__ __volatile__("xgetbv" : "=a"(xcrlow), "=d"(xcrhigh) : "c"(xcr)); |
| 39 |
return (((uint64_t)xcrhigh) << 32) | xcrlow; |
| 40 |
} |