cpuid.asm 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;*****************************************************************************
  2. ;* Copyright (C) 2005-2010 x264 project
  3. ;*
  4. ;* Authors: Loren Merritt <lorenm@u.washington.edu>
  5. ;* Jason Garrett-Glaser <darkshikari@gmail.com>
  6. ;*
  7. ;* This file is part of FFmpeg.
  8. ;*
  9. ;* FFmpeg is free software; you can redistribute it and/or
  10. ;* modify it under the terms of the GNU Lesser General Public
  11. ;* License as published by the Free Software Foundation; either
  12. ;* version 2.1 of the License, or (at your option) any later version.
  13. ;*
  14. ;* FFmpeg is distributed in the hope that it will be useful,
  15. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. ;* Lesser General Public License for more details.
  18. ;*
  19. ;* You should have received a copy of the GNU Lesser General Public
  20. ;* License along with FFmpeg; if not, write to the Free Software
  21. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. ;******************************************************************************
  23. %include "x86util.asm"
  24. SECTION .text
  25. ;-----------------------------------------------------------------------------
  26. ; void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx)
  27. ;-----------------------------------------------------------------------------
  28. cglobal cpu_cpuid, 5,7
  29. push rbx
  30. push r4
  31. push r3
  32. push r2
  33. push r1
  34. mov eax, r0d
  35. xor ecx, ecx
  36. cpuid
  37. pop r4
  38. mov [r4], eax
  39. pop r4
  40. mov [r4], ebx
  41. pop r4
  42. mov [r4], ecx
  43. pop r4
  44. mov [r4], edx
  45. pop rbx
  46. RET
  47. ;-----------------------------------------------------------------------------
  48. ; void ff_cpu_xgetbv(int op, int *eax, int *edx)
  49. ;-----------------------------------------------------------------------------
  50. cglobal cpu_xgetbv, 3,7
  51. push r2
  52. push r1
  53. mov ecx, r0d
  54. xgetbv
  55. pop r4
  56. mov [r4], eax
  57. pop r4
  58. mov [r4], edx
  59. RET
  60. %if ARCH_X86_64 == 0
  61. ;-----------------------------------------------------------------------------
  62. ; int ff_cpu_cpuid_test(void)
  63. ; return 0 if unsupported
  64. ;-----------------------------------------------------------------------------
  65. cglobal cpu_cpuid_test
  66. pushfd
  67. push ebx
  68. push ebp
  69. push esi
  70. push edi
  71. pushfd
  72. pop eax
  73. mov ebx, eax
  74. xor eax, 0x200000
  75. push eax
  76. popfd
  77. pushfd
  78. pop eax
  79. xor eax, ebx
  80. pop edi
  81. pop esi
  82. pop ebp
  83. pop ebx
  84. popfd
  85. ret
  86. %endif