7 #include "../../util/header.h"
10 cpuid(unsigned int op
, unsigned int *a
, unsigned int *b
, unsigned int *c
,
13 __asm__
__volatile__ (".byte 0x53\n\tcpuid\n\t"
14 "movl %%ebx, %%esi\n\t.byte 0x5b"
23 get_cpuid(char *buffer
, size_t sz
)
25 unsigned int a
, b
, c
, d
, lvl
;
26 int family
= -1, model
= -1, step
= -1;
30 cpuid(0, &lvl
, &b
, &c
, &d
);
31 strncpy(&vendor
[0], (char *)(&b
), 4);
32 strncpy(&vendor
[4], (char *)(&d
), 4);
33 strncpy(&vendor
[8], (char *)(&c
), 4);
37 cpuid(1, &a
, &b
, &c
, &d
);
39 family
= (a
>> 8) & 0xf; /* bits 11 - 8 */
40 model
= (a
>> 4) & 0xf; /* Bits 7 - 4 */
45 family
+= (a
>> 20) & 0xff;
49 model
+= ((a
>> 16) & 0xf) << 4;
51 nb
= scnprintf(buffer
, sz
, "%s,%u,%u,%u$", vendor
, family
, model
, step
);
53 /* look for end marker to ensure the entire data fit */
54 if (strchr(buffer
, '$')) {