]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/nat/x86-cpuid.h
40a76bd2d45bcff3997e530c4fb17cff1f6649a5
[thirdparty/binutils-gdb.git] / gdb / nat / x86-cpuid.h
1 /* C API for x86 cpuid insn.
2 Copyright (C) 2007-2020 Free Software Foundation, Inc.
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
19 #ifndef NAT_X86_CPUID_H
20 #define NAT_X86_CPUID_H
21
22 /* Always include the header for the cpu bit defines. */
23 #include "x86-gcc-cpuid.h"
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
33 x86_cpuid (unsigned int __level,
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
54 x86_cpuid (unsigned int __level,
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
63 #endif /* NAT_X86_CPUID_H */