]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/i386/linux/linux_support.s
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / i386 / linux / linux_support.s
1 /*-
2  * Copyright (c) 2006,2007 Konstantin Belousov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31
32 #include "linux_assym.h"                /* system definitions */
33 #include <machine/asmacros.h>           /* miscellaneous asm macros */
34
35 #include "assym.s"
36
37 futex_fault_decx:
38         movl    PCPU(CURPCB),%ecx
39 futex_fault:
40         movl    $0,PCB_ONFAULT(%ecx)
41         movl    $-EFAULT,%eax
42         ret
43
44 ENTRY(futex_xchgl)
45         movl    PCPU(CURPCB),%ecx
46         movl    $futex_fault,PCB_ONFAULT(%ecx)
47         movl    4(%esp),%eax
48         movl    8(%esp),%edx
49         cmpl    $VM_MAXUSER_ADDRESS-4,%edx
50         ja      futex_fault
51         xchgl   %eax,(%edx)
52         movl    12(%esp),%edx
53         movl    %eax,(%edx)
54         xorl    %eax,%eax
55         movl    %eax,PCB_ONFAULT(%ecx)
56         ret
57
58 ENTRY(futex_addl)
59         movl    PCPU(CURPCB),%ecx
60         movl    $futex_fault,PCB_ONFAULT(%ecx)
61         movl    4(%esp),%eax
62         movl    8(%esp),%edx
63         cmpl    $VM_MAXUSER_ADDRESS-4,%edx
64         ja      futex_fault
65 #ifdef SMP
66         lock
67 #endif
68         xaddl   %eax,(%edx)
69         movl    12(%esp),%edx
70         movl    %eax,(%edx)
71         xorl    %eax,%eax
72         movl    %eax,PCB_ONFAULT(%ecx)
73         ret
74
75 ENTRY(futex_orl)
76         movl    PCPU(CURPCB),%ecx
77         movl    $futex_fault_decx,PCB_ONFAULT(%ecx)
78         movl    8(%esp),%edx
79         cmpl    $VM_MAXUSER_ADDRESS-4,%edx
80         ja      futex_fault
81         movl    (%edx),%eax
82 1:      movl    %eax,%ecx
83         orl     4(%esp),%ecx
84 #ifdef SMP
85         lock
86 #endif
87         cmpxchgl %ecx,(%edx)
88         jnz     1b
89 futex_tail:     
90         movl    12(%esp),%edx
91         movl    %eax,(%edx)
92         xorl    %eax,%eax
93         movl    PCPU(CURPCB),%ecx
94         movl    %eax,PCB_ONFAULT(%ecx)
95         ret
96
97 ENTRY(futex_andl)
98         movl    PCPU(CURPCB),%ecx
99         movl    $futex_fault_decx,PCB_ONFAULT(%ecx)
100         movl    8(%esp),%edx
101         cmpl    $VM_MAXUSER_ADDRESS-4,%edx
102         ja      futex_fault
103         movl    (%edx),%eax
104 1:      movl    %eax,%ecx
105         andl    4(%esp),%ecx
106 #ifdef SMP
107         lock
108 #endif
109         cmpxchgl %ecx,(%edx)
110         jnz     1b
111         jmp     futex_tail
112
113 ENTRY(futex_xorl)
114         movl    PCPU(CURPCB),%ecx
115         movl    $futex_fault_decx,PCB_ONFAULT(%ecx)
116         movl    8(%esp),%edx
117         cmpl    $VM_MAXUSER_ADDRESS-4,%edx
118         ja      futex_fault
119         movl    (%edx),%eax
120 1:      movl    %eax,%ecx
121         xorl    4(%esp),%ecx
122 #ifdef SMP
123         lock
124 #endif
125         cmpxchgl %ecx,(%edx)
126         jnz     1b
127         jmp     futex_tail