Commit | Line | Data |
---|---|---|
4d157a3d | 1 | /* C API for x86 cpuid insn. |
b811d2c2 | 2 | Copyright (C) 2007-2020 Free Software Foundation, Inc. |
4d157a3d MF |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This file is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 3, or (at your option) any | |
9 | later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
18 | ||
1a5c2598 TT |
19 | #ifndef NAT_X86_CPUID_H |
20 | #define NAT_X86_CPUID_H | |
4d157a3d MF |
21 | |
22 | /* Always include the header for the cpu bit defines. */ | |
df7e5265 | 23 | #include "x86-gcc-cpuid.h" |
4d157a3d MF |
24 | |
25 | #if defined(__i386__) || defined(__x86_64__) | |
26 | ||
27 | /* Return cpuid data for requested cpuid level, as found in returned | |
28 | eax, ebx, ecx and edx registers. The function checks if cpuid is | |
29 | supported and returns 1 for valid cpuid information or 0 for | |
30 | unsupported cpuid level. Pointers may be non-null. */ | |
31 | ||
32 | static __inline int | |
df7e5265 | 33 | x86_cpuid (unsigned int __level, |
4d157a3d MF |
34 | unsigned int *__eax, unsigned int *__ebx, |
35 | unsigned int *__ecx, unsigned int *__edx) | |
36 | { | |
37 | unsigned int __scratch; | |
38 | ||
39 | if (!__eax) | |
40 | __eax = &__scratch; | |
41 | if (!__ebx) | |
42 | __ebx = &__scratch; | |
43 | if (!__ecx) | |
44 | __ecx = &__scratch; | |
45 | if (!__edx) | |
46 | __edx = &__scratch; | |
47 | ||
48 | return __get_cpuid (__level, __eax, __ebx, __ecx, __edx); | |
49 | } | |
50 | ||
51 | #else | |
52 | ||
53 | static __inline int | |
df7e5265 | 54 | x86_cpuid (unsigned int __level, |
4d157a3d MF |
55 | unsigned int *__eax, unsigned int *__ebx, |
56 | unsigned int *__ecx, unsigned int *__edx) | |
57 | { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | #endif /* i386 && x86_64 */ | |
62 | ||
1a5c2598 | 63 | #endif /* NAT_X86_CPUID_H */ |