x86-cpuid.h 1.8 KB

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