| 1 | ;***************************************************************************** |
| 2 | ;* Copyright (C) 2005-2010 x264 project |
| 3 | ;* |
| 4 | ;* Authors: Loren Merritt <lorenm@u.washington.edu> |
| 5 | ;* Fiona Glaser <fiona@x264.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 | |
| 24 | %include "x86util.asm" |
| 25 | |
| 26 | SECTION .text |
| 27 | |
| 28 | ;----------------------------------------------------------------------------- |
| 29 | ; void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx) |
| 30 | ;----------------------------------------------------------------------------- |
| 31 | cglobal cpu_cpuid, 5,7 |
| 32 | push rbx |
| 33 | push r4 |
| 34 | push r3 |
| 35 | push r2 |
| 36 | push r1 |
| 37 | mov eax, r0d |
| 38 | xor ecx, ecx |
| 39 | cpuid |
| 40 | pop r4 |
| 41 | mov [r4], eax |
| 42 | pop r4 |
| 43 | mov [r4], ebx |
| 44 | pop r4 |
| 45 | mov [r4], ecx |
| 46 | pop r4 |
| 47 | mov [r4], edx |
| 48 | pop rbx |
| 49 | RET |
| 50 | |
| 51 | ;----------------------------------------------------------------------------- |
| 52 | ; void ff_cpu_xgetbv(int op, int *eax, int *edx) |
| 53 | ;----------------------------------------------------------------------------- |
| 54 | cglobal cpu_xgetbv, 3,7 |
| 55 | push r2 |
| 56 | push r1 |
| 57 | mov ecx, r0d |
| 58 | xgetbv |
| 59 | pop r4 |
| 60 | mov [r4], eax |
| 61 | pop r4 |
| 62 | mov [r4], edx |
| 63 | RET |
| 64 | |
| 65 | %if ARCH_X86_64 == 0 |
| 66 | ;----------------------------------------------------------------------------- |
| 67 | ; int ff_cpu_cpuid_test(void) |
| 68 | ; return 0 if unsupported |
| 69 | ;----------------------------------------------------------------------------- |
| 70 | cglobal cpu_cpuid_test |
| 71 | pushfd |
| 72 | push ebx |
| 73 | push ebp |
| 74 | push esi |
| 75 | push edi |
| 76 | pushfd |
| 77 | pop eax |
| 78 | mov ebx, eax |
| 79 | xor eax, 0x200000 |
| 80 | push eax |
| 81 | popfd |
| 82 | pushfd |
| 83 | pop eax |
| 84 | xor eax, ebx |
| 85 | pop edi |
| 86 | pop esi |
| 87 | pop ebp |
| 88 | pop ebx |
| 89 | popfd |
| 90 | ret |
| 91 | %endif |