1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*++ |
6 | |
7 | |
8 | |
9 | Module Name: |
10 | |
11 | processor.cpp |
12 | |
13 | Abstract: |
14 | |
15 | Implementation of processor related functions for the Intel x86/x64 |
16 | platforms. These functions are processor dependent. |
17 | |
18 | |
19 | |
20 | --*/ |
21 | |
22 | #include "pal/palinternal.h" |
23 | |
24 | /*++ |
25 | Function: |
26 | XmmYmmStateSupport |
27 | |
28 | Check if OS has enabled both XMM and YMM state support |
29 | |
30 | Return value: |
31 | 1 if XMM and YMM are enabled, 0 otherwise |
32 | --*/ |
33 | extern "C" unsigned int XmmYmmStateSupport() |
34 | { |
35 | unsigned int eax; |
36 | __asm(" mov $1, %%eax\n" \ |
37 | " cpuid\n" \ |
38 | " xor %%eax, %%eax\n" \ |
39 | " and $0x18000000, %%ecx\n" /* check for xsave feature set and that it is enabled by the OS */ \ |
40 | " cmp $0x18000000, %%ecx\n" \ |
41 | " jne end\n" \ |
42 | " xor %%ecx, %%ecx\n" \ |
43 | " xgetbv\n" \ |
44 | "end:\n" \ |
45 | : "=a" (eax) /* output in eax */ \ |
46 | : /* no inputs */ \ |
47 | : "ebx" , "ecx" , "edx" /* registers that are clobbered */ |
48 | ); |
49 | // Check OS has enabled both XMM and YMM state support |
50 | return ((eax & 0x06) == 0x06) ? 1 : 0; |
51 | } |
52 | |