brintos

brintos / linux-shallow public Read only

0
0
Text · 833 B · 0a3ae0a Raw
35 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef PERF_CPUID_H3#define PERF_CPUID_H 14 5 6static inline void7cpuid(unsigned int op, unsigned int op2, unsigned int *a, unsigned int *b,8	unsigned int *c, unsigned int *d)9{10	/*11	 * Preserve %ebx/%rbx register by either placing it in %rdi or saving it12	 * on the stack - x86-64 needs to avoid the stack red zone. In PIC13	 * compilations %ebx contains the address of the global offset14	 * table. %rbx is occasionally used to address stack variables in15	 * presence of dynamic allocas.16	 */17	asm(18#if defined(__x86_64__)19		"mov %%rbx, %%rdi\n"20		"cpuid\n"21		"xchg %%rdi, %%rbx\n"22#else23		"pushl %%ebx\n"24		"cpuid\n"25		"movl %%ebx, %%edi\n"26		"popl %%ebx\n"27#endif28		: "=a"(*a), "=D"(*b), "=c"(*c), "=d"(*d)29		: "a"(op), "2"(op2));30}31 32void get_cpuid_0(char *vendor, unsigned int *lvl);33 34#endif35