Merge branch 'vendor/LIBRESSL'
[dragonfly.git] / crypto / libressl / crypto / cpuid-macosx-x86_64.S
1
2 .private_extern _OPENSSL_cpuid_setup
3 .mod_init_func
4         .p2align        3
5         .quad   _OPENSSL_cpuid_setup
6
7 .private_extern _OPENSSL_ia32cap_P
8 .comm   _OPENSSL_ia32cap_P,8,2
9
10 .text   
11
12 .globl  _OPENSSL_atomic_add
13
14 .p2align        4
15 _OPENSSL_atomic_add:
16         movl    (%rdi),%eax
17 L$spin: leaq    (%rsi,%rax,1),%r8
18 .byte   0xf0            
19         cmpxchgl        %r8d,(%rdi)
20         jne     L$spin
21         movl    %r8d,%eax
22 .byte   0x48,0x98       
23         .byte   0xf3,0xc3
24
25
26 .globl  _OPENSSL_ia32_cpuid
27
28 .p2align        4
29 _OPENSSL_ia32_cpuid:
30         movq    %rbx,%r8
31
32         xorl    %eax,%eax
33         cpuid
34         movl    %eax,%r11d
35
36         xorl    %eax,%eax
37         cmpl    $1970169159,%ebx
38         setne   %al
39         movl    %eax,%r9d
40         cmpl    $1231384169,%edx
41         setne   %al
42         orl     %eax,%r9d
43         cmpl    $1818588270,%ecx
44         setne   %al
45         orl     %eax,%r9d
46         jz      L$intel
47
48         cmpl    $1752462657,%ebx
49         setne   %al
50         movl    %eax,%r10d
51         cmpl    $1769238117,%edx
52         setne   %al
53         orl     %eax,%r10d
54         cmpl    $1145913699,%ecx
55         setne   %al
56         orl     %eax,%r10d
57         jnz     L$intel
58
59
60         movl    $2147483648,%eax
61         cpuid
62         cmpl    $2147483649,%eax
63         jb      L$intel
64         movl    %eax,%r10d
65         movl    $2147483649,%eax
66         cpuid
67         orl     %ecx,%r9d
68         andl    $2049,%r9d
69
70         cmpl    $2147483656,%r10d
71         jb      L$intel
72
73         movl    $2147483656,%eax
74         cpuid
75         movzbq  %cl,%r10
76         incq    %r10
77
78         movl    $1,%eax
79         cpuid
80         btl     $28,%edx
81         jnc     L$generic
82         shrl    $16,%ebx
83         cmpb    %r10b,%bl
84         ja      L$generic
85         andl    $4026531839,%edx
86         jmp     L$generic
87
88 L$intel:
89         cmpl    $4,%r11d
90         movl    $-1,%r10d
91         jb      L$nocacheinfo
92
93         movl    $4,%eax
94         movl    $0,%ecx
95         cpuid
96         movl    %eax,%r10d
97         shrl    $14,%r10d
98         andl    $4095,%r10d
99
100 L$nocacheinfo:
101         movl    $1,%eax
102         cpuid
103         andl    $3220176895,%edx
104         cmpl    $0,%r9d
105         jne     L$notintel
106         orl     $1073741824,%edx
107         andb    $15,%ah
108         cmpb    $15,%ah
109         jne     L$notintel
110         orl     $1048576,%edx
111 L$notintel:
112         btl     $28,%edx
113         jnc     L$generic
114         andl    $4026531839,%edx
115         cmpl    $0,%r10d
116         je      L$generic
117
118         orl     $268435456,%edx
119         shrl    $16,%ebx
120         cmpb    $1,%bl
121         ja      L$generic
122         andl    $4026531839,%edx
123 L$generic:
124         andl    $2048,%r9d
125         andl    $4294965247,%ecx
126         orl     %ecx,%r9d
127
128         movl    %edx,%r10d
129         btl     $27,%r9d
130         jnc     L$clear_avx
131         xorl    %ecx,%ecx
132 .byte   0x0f,0x01,0xd0          
133         andl    $6,%eax
134         cmpl    $6,%eax
135         je      L$done
136 L$clear_avx:
137         movl    $4026525695,%eax
138         andl    %eax,%r9d
139 L$done:
140         shlq    $32,%r9
141         movl    %r10d,%eax
142         movq    %r8,%rbx
143         orq     %r9,%rax
144         .byte   0xf3,0xc3
145
146 .globl  _OPENSSL_wipe_cpu
147
148 .p2align        4
149 _OPENSSL_wipe_cpu:
150         pxor    %xmm0,%xmm0
151         pxor    %xmm1,%xmm1
152         pxor    %xmm2,%xmm2
153         pxor    %xmm3,%xmm3
154         pxor    %xmm4,%xmm4
155         pxor    %xmm5,%xmm5
156         pxor    %xmm6,%xmm6
157         pxor    %xmm7,%xmm7
158         pxor    %xmm8,%xmm8
159         pxor    %xmm9,%xmm9
160         pxor    %xmm10,%xmm10
161         pxor    %xmm11,%xmm11
162         pxor    %xmm12,%xmm12
163         pxor    %xmm13,%xmm13
164         pxor    %xmm14,%xmm14
165         pxor    %xmm15,%xmm15
166         xorq    %rcx,%rcx
167         xorq    %rdx,%rdx
168         xorq    %rsi,%rsi
169         xorq    %rdi,%rdi
170         xorq    %r8,%r8
171         xorq    %r9,%r9
172         xorq    %r10,%r10
173         xorq    %r11,%r11
174         leaq    8(%rsp),%rax
175         .byte   0xf3,0xc3
176