]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/amd64/linux/linux_support.s
Update ACPICA to 20181003.
[FreeBSD/FreeBSD.git] / sys / amd64 / linux / linux_support.s
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2007 Konstantin Belousov
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 #include "linux_assym.h"                /* system definitions */
32 #include <machine/asmacros.h>           /* miscellaneous asm macros */
33
34 #include "assym.inc"
35
36 futex_fault:
37         movq    $0,PCB_ONFAULT(%r8)
38         movl    $-EFAULT,%eax
39         ret
40
41 ENTRY(futex_xchgl_nosmap)
42         movq    PCPU(CURPCB),%r8
43         movq    $futex_fault,PCB_ONFAULT(%r8)
44         movq    $VM_MAXUSER_ADDRESS-4,%rax
45         cmpq    %rax,%rsi
46         ja      futex_fault
47         xchgl   %edi,(%rsi)
48         movl    %edi,(%rdx)
49         xorl    %eax,%eax
50         movq    %rax,PCB_ONFAULT(%r8)
51         ret
52 END(futex_xchgl_nosmap)
53
54 ENTRY(futex_xchgl_smap)
55         movq    PCPU(CURPCB),%r8
56         movq    $futex_fault,PCB_ONFAULT(%r8)
57         movq    $VM_MAXUSER_ADDRESS-4,%rax
58         cmpq    %rax,%rsi
59         ja      futex_fault
60         stac
61         xchgl   %edi,(%rsi)
62         clac
63         movl    %edi,(%rdx)
64         xorl    %eax,%eax
65         movq    %rax,PCB_ONFAULT(%r8)
66         ret
67 END(futex_xchgl_smap)
68
69 ENTRY(futex_addl_nosmap)
70         movq    PCPU(CURPCB),%r8
71         movq    $futex_fault,PCB_ONFAULT(%r8)
72         movq    $VM_MAXUSER_ADDRESS-4,%rax
73         cmpq    %rax,%rsi
74         ja      futex_fault
75 #ifdef SMP
76         lock
77 #endif
78         xaddl   %edi,(%rsi)
79         movl    %edi,(%rdx)
80         xorl    %eax,%eax
81         movq    %rax,PCB_ONFAULT(%r8)
82         ret
83 END(futex_addl_nosmap)
84
85 ENTRY(futex_addl_smap)
86         movq    PCPU(CURPCB),%r8
87         movq    $futex_fault,PCB_ONFAULT(%r8)
88         movq    $VM_MAXUSER_ADDRESS-4,%rax
89         cmpq    %rax,%rsi
90         ja      futex_fault
91         stac
92 #ifdef SMP
93         lock
94 #endif
95         xaddl   %edi,(%rsi)
96         clac
97         movl    %edi,(%rdx)
98         xorl    %eax,%eax
99         movq    %rax,PCB_ONFAULT(%r8)
100         ret
101 END(futex_addl_smap)
102
103 ENTRY(futex_orl_nosmap)
104         movq    PCPU(CURPCB),%r8
105         movq    $futex_fault,PCB_ONFAULT(%r8)
106         movq    $VM_MAXUSER_ADDRESS-4,%rax
107         cmpq    %rax,%rsi
108         ja      futex_fault
109         movl    (%rsi),%eax
110 1:      movl    %eax,%ecx
111         orl     %edi,%ecx
112 #ifdef SMP
113         lock
114 #endif
115         cmpxchgl %ecx,(%rsi)
116         jnz     1b
117         movl    %eax,(%rdx)
118         xorl    %eax,%eax
119         movq    %rax,PCB_ONFAULT(%r8)
120         ret
121 END(futex_orl_nosmap)
122
123 ENTRY(futex_orl_smap)
124         movq    PCPU(CURPCB),%r8
125         movq    $futex_fault,PCB_ONFAULT(%r8)
126         movq    $VM_MAXUSER_ADDRESS-4,%rax
127         cmpq    %rax,%rsi
128         ja      futex_fault
129         movl    (%rsi),%eax
130 1:      movl    %eax,%ecx
131         orl     %edi,%ecx
132         stac
133 #ifdef SMP
134         lock
135 #endif
136         cmpxchgl %ecx,(%rsi)
137         clac
138         jnz     1b
139         movl    %eax,(%rdx)
140         xorl    %eax,%eax
141         movq    %rax,PCB_ONFAULT(%r8)
142         ret
143 END(futex_orl_smap)
144
145 ENTRY(futex_andl_nosmap)
146         movq    PCPU(CURPCB),%r8
147         movq    $futex_fault,PCB_ONFAULT(%r8)
148         movq    $VM_MAXUSER_ADDRESS-4,%rax
149         cmpq    %rax,%rsi
150         ja      futex_fault
151         movl    (%rsi),%eax
152 1:      movl    %eax,%ecx
153         andl    %edi,%ecx
154 #ifdef SMP
155         lock
156 #endif
157         cmpxchgl %ecx,(%rsi)
158         jnz     1b
159         movl    %eax,(%rdx)
160         xorl    %eax,%eax
161         movq    %rax,PCB_ONFAULT(%r8)
162         ret
163 END(futex_andl_nosmap)
164
165 ENTRY(futex_andl_smap)
166         movq    PCPU(CURPCB),%r8
167         movq    $futex_fault,PCB_ONFAULT(%r8)
168         movq    $VM_MAXUSER_ADDRESS-4,%rax
169         cmpq    %rax,%rsi
170         ja      futex_fault
171         movl    (%rsi),%eax
172 1:      movl    %eax,%ecx
173         andl    %edi,%ecx
174         stac
175 #ifdef SMP
176         lock
177 #endif
178         cmpxchgl %ecx,(%rsi)
179         clac
180         jnz     1b
181         movl    %eax,(%rdx)
182         xorl    %eax,%eax
183         movq    %rax,PCB_ONFAULT(%r8)
184         ret
185 END(futex_andl_smap)
186
187 ENTRY(futex_xorl_nosmap)
188         movq    PCPU(CURPCB),%r8
189         movq    $futex_fault,PCB_ONFAULT(%r8)
190         movq    $VM_MAXUSER_ADDRESS-4,%rax
191         cmpq    %rax,%rsi
192         ja      futex_fault
193         movl    (%rsi),%eax
194 1:      movl    %eax,%ecx
195         xorl    %edi,%ecx
196 #ifdef SMP
197         lock
198 #endif
199         cmpxchgl %ecx,(%rsi)
200         jnz     1b
201         movl    %eax,(%rdx)
202         xorl    %eax,%eax
203         movq    %rax,PCB_ONFAULT(%r8)
204         ret
205 END(futex_xorl_nosmap)
206
207 ENTRY(futex_xorl_smap)
208         movq    PCPU(CURPCB),%r8
209         movq    $futex_fault,PCB_ONFAULT(%r8)
210         movq    $VM_MAXUSER_ADDRESS-4,%rax
211         cmpq    %rax,%rsi
212         ja      futex_fault
213         movl    (%rsi),%eax
214 1:      movl    %eax,%ecx
215         xorl    %edi,%ecx
216         stac
217 #ifdef SMP
218         lock
219 #endif
220         cmpxchgl %ecx,(%rsi)
221         clac
222         jnz     1b
223         movl    %eax,(%rdx)
224         xorl    %eax,%eax
225         movq    %rax,PCB_ONFAULT(%r8)
226         ret
227 END(futex_xorl_smap)