sbin/hammer: Directly access volume in volume list
[dragonfly.git] / sys / emulation / linux / i386 / linux_support.s
blob1424e8510dcb94990afd79a71399cd764a7983ed
1 /*-
2 * Copyright (c) 2006,2007 Konstantin Belousov
3 * All rights reserved.
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 * 3. 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.
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.
29 * $FreeBSD$
32 #include "linux_assym.h" /* system definitions */
33 #include <machine/asmacros.h> /* miscellaneous asm macros */
34 #include <machine/cputypes.h>
35 #include <machine/pmap.h>
36 #include <machine/specialreg.h>
38 #include "assym.s"
41 * A stack-based on-fault routine is used for more complex PCB_ONFAULT
42 * situations (such as memcpy/bcopy/bzero). In this case the on-fault
43 * routine must be pushed on the stack.
45 stack_onfault:
46 ret
48 futex_fault_decx:
49 movl PCPU(curthread),%ecx
50 movl TD_PCB(%ecx), %ecx
51 futex_fault:
52 movl $0,PCB_ONFAULT(%ecx)
53 movl $EFAULT,%eax
54 ret
56 futex_fault_pop:
57 addl $4,%esp
58 movl $0,PCB_ONFAULT(%ecx)
59 movl $EFAULT,%eax
60 ret
62 ENTRY(futex_xchgl)
63 movl PCPU(curthread),%ecx
64 movl TD_PCB(%ecx),%ecx
65 pushl $futex_fault
66 movl $stack_onfault, PCB_ONFAULT(%ecx)
67 movl 8(%esp),%eax
68 movl 12(%esp),%edx
69 cmpl $VM_MAX_USER_ADDRESS-4,%edx
70 ja futex_fault_pop
71 xchgl %eax,(%edx)
72 movl 16(%esp),%edx
73 movl %eax,(%edx)
74 xorl %eax,%eax
75 movl %eax,PCB_ONFAULT(%ecx)
76 ret
78 ENTRY(futex_addl)
79 movl PCPU(curthread),%ecx
80 movl TD_PCB(%ecx),%ecx
81 pushl $futex_fault
82 movl $stack_onfault,PCB_ONFAULT(%ecx)
83 movl 8(%esp),%eax
84 movl 12(%esp),%edx
85 cmpl $VM_MAX_USER_ADDRESS-4,%edx
86 ja futex_fault_pop
87 lock
88 xaddl %eax,(%edx)
89 movl 16(%esp),%edx
90 movl %eax,(%edx)
91 xorl %eax,%eax
92 movl %eax,PCB_ONFAULT(%ecx)
93 ret
95 ENTRY(futex_orl)
96 movl PCPU(curthread),%ecx
97 movl TD_PCB(%ecx),%ecx
98 pushl $futex_fault_decx
99 movl $stack_onfault,PCB_ONFAULT(%ecx)
100 movl 12(%esp),%edx
101 cmpl $VM_MAX_USER_ADDRESS-4,%edx
102 ja futex_fault_pop
103 movl (%edx),%eax
104 1: movl %eax,%ecx
105 orl 8(%esp),%ecx
106 lock
107 cmpxchgl %ecx,(%edx)
108 jnz 1b
109 futex_tail:
110 movl 16(%esp),%edx
111 movl %eax,(%edx)
112 xorl %eax,%eax
113 movl PCPU(curthread),%ecx
114 movl TD_PCB(%ecx),%ecx
115 movl %eax,PCB_ONFAULT(%ecx)
118 ENTRY(futex_andl)
119 movl PCPU(curthread),%ecx
120 movl TD_PCB(%ecx),%ecx
121 pushl $futex_fault_decx
122 movl $stack_onfault,PCB_ONFAULT(%ecx)
123 movl 12(%esp),%edx
124 cmpl $VM_MAX_USER_ADDRESS-4,%edx
125 ja futex_fault_pop
126 movl (%edx),%eax
127 1: movl %eax,%ecx
128 andl 8(%esp),%ecx
129 lock
130 cmpxchgl %ecx,(%edx)
131 jnz 1b
132 jmp futex_tail
134 ENTRY(futex_xorl)
135 movl PCPU(curthread),%ecx
136 movl TD_PCB(%ecx),%ecx
137 pushl $futex_fault_decx
138 movl $stack_onfault,PCB_ONFAULT(%ecx)
139 movl 12(%esp),%edx
140 cmpl $VM_MAX_USER_ADDRESS-4,%edx
141 ja futex_fault_pop
142 movl (%edx),%eax
143 1: movl %eax,%ecx
144 xorl 8(%esp),%ecx
145 lock
146 cmpxchgl %ecx,(%edx)
147 jnz 1b
148 jmp futex_tail