-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathcpuid1.h
45 lines (37 loc) · 1019 Bytes
/
cpuid1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2021 @tansy
* All rights reserved.
*
* This source code is licenced under the GPLv2 or (at your option) GPLv3.
* For additional details, refer to the LICENSE file located in the root
* directory of this source tree.
*/
#ifndef CPUID1_H
#define CPUID1_H
#ifndef __GNUC__
#define asm __asm__
#endif
#if (defined(__i386__) || defined(__x86_64__))
#include <cpuid.h>
#include <stdint.h>
enum cpuid_requests
{
CPUID_GETVENDORSTRING,
CPUID_GETFEATURES,
CPUID_GETTLB,
CPUID_GETSERIAL,
CPUID_EXTENDED = 0x80000000,
CPUID_FEATURES,
CPUID_BRANDSTRING,
CPUID_BRANDSTRINGMORE,
CPUID_BRANDSTRINGEND,
};
inline int cpuid_string(int code, uint32_t where[4])
{
//asm volatile("cpuid":"=a"(*where),"=b"(*(where+1)),
// "=c"(*(where+2)),"=d"(*(where+3)):"a"(code));
__cpuid(code, (*where), *(where+1), *(where+2), *(where+3));
return (int)where[0];
}
#endif /* #if (defined(__i386__) || defined(__x86_64__)) */
#endif /* #ifndef CPUID1_H */