.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * atomic64_t for 386/486 |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright © 2010 Luca Barbieri |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/linkage.h> |
---|
13 | | -#include <asm/alternative-asm.h> |
---|
| 9 | +#include <asm/alternative.h> |
---|
14 | 10 | |
---|
15 | 11 | /* if you want SMP support, implement these with real spinlocks */ |
---|
16 | | -.macro LOCK reg |
---|
| 12 | +.macro IRQ_SAVE reg |
---|
17 | 13 | pushfl |
---|
18 | 14 | cli |
---|
19 | 15 | .endm |
---|
20 | 16 | |
---|
21 | | -.macro UNLOCK reg |
---|
| 17 | +.macro IRQ_RESTORE reg |
---|
22 | 18 | popfl |
---|
23 | 19 | .endm |
---|
24 | 20 | |
---|
25 | | -#define BEGIN(op) \ |
---|
| 21 | +#define BEGIN_IRQ_SAVE(op) \ |
---|
26 | 22 | .macro endp; \ |
---|
27 | | -ENDPROC(atomic64_##op##_386); \ |
---|
| 23 | +SYM_FUNC_END(atomic64_##op##_386); \ |
---|
28 | 24 | .purgem endp; \ |
---|
29 | 25 | .endm; \ |
---|
30 | | -ENTRY(atomic64_##op##_386); \ |
---|
31 | | - LOCK v; |
---|
| 26 | +SYM_FUNC_START(atomic64_##op##_386); \ |
---|
| 27 | + IRQ_SAVE v; |
---|
32 | 28 | |
---|
33 | 29 | #define ENDP endp |
---|
34 | 30 | |
---|
35 | | -#define RET \ |
---|
36 | | - UNLOCK v; \ |
---|
37 | | - ret |
---|
38 | | - |
---|
39 | | -#define RET_ENDP \ |
---|
40 | | - RET; \ |
---|
41 | | - ENDP |
---|
| 31 | +#define RET_IRQ_RESTORE \ |
---|
| 32 | + IRQ_RESTORE v; \ |
---|
| 33 | + RET |
---|
42 | 34 | |
---|
43 | 35 | #define v %ecx |
---|
44 | | -BEGIN(read) |
---|
| 36 | +BEGIN_IRQ_SAVE(read) |
---|
45 | 37 | movl (v), %eax |
---|
46 | 38 | movl 4(v), %edx |
---|
47 | | -RET_ENDP |
---|
| 39 | + RET_IRQ_RESTORE |
---|
| 40 | +ENDP |
---|
48 | 41 | #undef v |
---|
49 | 42 | |
---|
50 | 43 | #define v %esi |
---|
51 | | -BEGIN(set) |
---|
| 44 | +BEGIN_IRQ_SAVE(set) |
---|
52 | 45 | movl %ebx, (v) |
---|
53 | 46 | movl %ecx, 4(v) |
---|
54 | | -RET_ENDP |
---|
| 47 | + RET_IRQ_RESTORE |
---|
| 48 | +ENDP |
---|
55 | 49 | #undef v |
---|
56 | 50 | |
---|
57 | 51 | #define v %esi |
---|
58 | | -BEGIN(xchg) |
---|
| 52 | +BEGIN_IRQ_SAVE(xchg) |
---|
59 | 53 | movl (v), %eax |
---|
60 | 54 | movl 4(v), %edx |
---|
61 | 55 | movl %ebx, (v) |
---|
62 | 56 | movl %ecx, 4(v) |
---|
63 | | -RET_ENDP |
---|
| 57 | + RET_IRQ_RESTORE |
---|
| 58 | +ENDP |
---|
64 | 59 | #undef v |
---|
65 | 60 | |
---|
66 | 61 | #define v %ecx |
---|
67 | | -BEGIN(add) |
---|
| 62 | +BEGIN_IRQ_SAVE(add) |
---|
68 | 63 | addl %eax, (v) |
---|
69 | 64 | adcl %edx, 4(v) |
---|
70 | | -RET_ENDP |
---|
| 65 | + RET_IRQ_RESTORE |
---|
| 66 | +ENDP |
---|
71 | 67 | #undef v |
---|
72 | 68 | |
---|
73 | 69 | #define v %ecx |
---|
74 | | -BEGIN(add_return) |
---|
| 70 | +BEGIN_IRQ_SAVE(add_return) |
---|
75 | 71 | addl (v), %eax |
---|
76 | 72 | adcl 4(v), %edx |
---|
77 | 73 | movl %eax, (v) |
---|
78 | 74 | movl %edx, 4(v) |
---|
79 | | -RET_ENDP |
---|
| 75 | + RET_IRQ_RESTORE |
---|
| 76 | +ENDP |
---|
80 | 77 | #undef v |
---|
81 | 78 | |
---|
82 | 79 | #define v %ecx |
---|
83 | | -BEGIN(sub) |
---|
| 80 | +BEGIN_IRQ_SAVE(sub) |
---|
84 | 81 | subl %eax, (v) |
---|
85 | 82 | sbbl %edx, 4(v) |
---|
86 | | -RET_ENDP |
---|
| 83 | + RET_IRQ_RESTORE |
---|
| 84 | +ENDP |
---|
87 | 85 | #undef v |
---|
88 | 86 | |
---|
89 | 87 | #define v %ecx |
---|
90 | | -BEGIN(sub_return) |
---|
| 88 | +BEGIN_IRQ_SAVE(sub_return) |
---|
91 | 89 | negl %edx |
---|
92 | 90 | negl %eax |
---|
93 | 91 | sbbl $0, %edx |
---|
.. | .. |
---|
95 | 93 | adcl 4(v), %edx |
---|
96 | 94 | movl %eax, (v) |
---|
97 | 95 | movl %edx, 4(v) |
---|
98 | | -RET_ENDP |
---|
| 96 | + RET_IRQ_RESTORE |
---|
| 97 | +ENDP |
---|
99 | 98 | #undef v |
---|
100 | 99 | |
---|
101 | 100 | #define v %esi |
---|
102 | | -BEGIN(inc) |
---|
| 101 | +BEGIN_IRQ_SAVE(inc) |
---|
103 | 102 | addl $1, (v) |
---|
104 | 103 | adcl $0, 4(v) |
---|
105 | | -RET_ENDP |
---|
| 104 | + RET_IRQ_RESTORE |
---|
| 105 | +ENDP |
---|
106 | 106 | #undef v |
---|
107 | 107 | |
---|
108 | 108 | #define v %esi |
---|
109 | | -BEGIN(inc_return) |
---|
| 109 | +BEGIN_IRQ_SAVE(inc_return) |
---|
110 | 110 | movl (v), %eax |
---|
111 | 111 | movl 4(v), %edx |
---|
112 | 112 | addl $1, %eax |
---|
113 | 113 | adcl $0, %edx |
---|
114 | 114 | movl %eax, (v) |
---|
115 | 115 | movl %edx, 4(v) |
---|
116 | | -RET_ENDP |
---|
| 116 | + RET_IRQ_RESTORE |
---|
| 117 | +ENDP |
---|
117 | 118 | #undef v |
---|
118 | 119 | |
---|
119 | 120 | #define v %esi |
---|
120 | | -BEGIN(dec) |
---|
| 121 | +BEGIN_IRQ_SAVE(dec) |
---|
121 | 122 | subl $1, (v) |
---|
122 | 123 | sbbl $0, 4(v) |
---|
123 | | -RET_ENDP |
---|
| 124 | + RET_IRQ_RESTORE |
---|
| 125 | +ENDP |
---|
124 | 126 | #undef v |
---|
125 | 127 | |
---|
126 | 128 | #define v %esi |
---|
127 | | -BEGIN(dec_return) |
---|
| 129 | +BEGIN_IRQ_SAVE(dec_return) |
---|
128 | 130 | movl (v), %eax |
---|
129 | 131 | movl 4(v), %edx |
---|
130 | 132 | subl $1, %eax |
---|
131 | 133 | sbbl $0, %edx |
---|
132 | 134 | movl %eax, (v) |
---|
133 | 135 | movl %edx, 4(v) |
---|
134 | | -RET_ENDP |
---|
| 136 | + RET_IRQ_RESTORE |
---|
| 137 | +ENDP |
---|
135 | 138 | #undef v |
---|
136 | 139 | |
---|
137 | 140 | #define v %esi |
---|
138 | | -BEGIN(add_unless) |
---|
| 141 | +BEGIN_IRQ_SAVE(add_unless) |
---|
139 | 142 | addl %eax, %ecx |
---|
140 | 143 | adcl %edx, %edi |
---|
141 | 144 | addl (v), %eax |
---|
.. | .. |
---|
147 | 150 | movl %edx, 4(v) |
---|
148 | 151 | movl $1, %eax |
---|
149 | 152 | 2: |
---|
150 | | - RET |
---|
| 153 | + RET_IRQ_RESTORE |
---|
151 | 154 | 3: |
---|
152 | 155 | cmpl %edx, %edi |
---|
153 | 156 | jne 1b |
---|
.. | .. |
---|
157 | 160 | #undef v |
---|
158 | 161 | |
---|
159 | 162 | #define v %esi |
---|
160 | | -BEGIN(inc_not_zero) |
---|
| 163 | +BEGIN_IRQ_SAVE(inc_not_zero) |
---|
161 | 164 | movl (v), %eax |
---|
162 | 165 | movl 4(v), %edx |
---|
163 | 166 | testl %eax, %eax |
---|
.. | .. |
---|
169 | 172 | movl %edx, 4(v) |
---|
170 | 173 | movl $1, %eax |
---|
171 | 174 | 2: |
---|
172 | | - RET |
---|
| 175 | + RET_IRQ_RESTORE |
---|
173 | 176 | 3: |
---|
174 | 177 | testl %edx, %edx |
---|
175 | 178 | jne 1b |
---|
.. | .. |
---|
178 | 181 | #undef v |
---|
179 | 182 | |
---|
180 | 183 | #define v %esi |
---|
181 | | -BEGIN(dec_if_positive) |
---|
| 184 | +BEGIN_IRQ_SAVE(dec_if_positive) |
---|
182 | 185 | movl (v), %eax |
---|
183 | 186 | movl 4(v), %edx |
---|
184 | 187 | subl $1, %eax |
---|
.. | .. |
---|
187 | 190 | movl %eax, (v) |
---|
188 | 191 | movl %edx, 4(v) |
---|
189 | 192 | 1: |
---|
190 | | -RET_ENDP |
---|
| 193 | + RET_IRQ_RESTORE |
---|
| 194 | +ENDP |
---|
191 | 195 | #undef v |
---|