summaryrefslogtreecommitdiff
path: root/post/lib_ppc/asm.S
blob: f6b329aa4df2592f0f52466a2f5ac1fc738a6a63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*
 *  Copyright (C) 2002 Wolfgang Denk <wd@denx.de>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <config.h>

#include <post.h>
#include <ppc_asm.tmpl>
#include <ppc_defs.h>
#include <asm/cache.h>

#if CONFIG_POST & CONFIG_SYS_POST_CPU

/* void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2); */
	.global	cpu_post_exec_02
cpu_post_exec_02:
	isync
	mflr	r0
	stwu	r0, -4(r1)

	subi	r1, r1, 104
	stmw	r6, 0(r1)

	mtlr	r3
	mr	r3, r4
	mr	r4, r5
	blrl

	lmw	r6, 0(r1)
	addi	r1, r1, 104

	lwz	r0, 0(r1)
	addi	r1, r1, 4
	mtlr	r0
	blr

/* void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, ulong op4); */
	.global	cpu_post_exec_04
cpu_post_exec_04:
	isync
	mflr	r0
	stwu	r0, -4(r1)

	subi	r1, r1, 96
	stmw	r8, 0(r1)

	mtlr	r3
	mr	r3, r4
	mr	r4, r5
	mr	r5, r6
	mtxer	r7
	blrl

	lmw	r8, 0(r1)
	addi	r1, r1, 96

	lwz	r0, 0(r1)
	addi	r1, r1, 4
	mtlr	r0
	blr

/* void cpu_post_exec_12 (ulong *code, ulong *res, ulong op1, ulong op2); */
	.global	cpu_post_exec_12
cpu_post_exec_12:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)

	mtlr	r3
	mr	r3, r5
	mr	r4, r6
	blrl

	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 4(r1)
	addi	r1, r1, 8
	mtlr	r0
	blr

/* void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); */
	.global	cpu_post_exec_11
cpu_post_exec_11:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)

	mtlr	r3
	mr	r3, r5
	blrl

	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 4(r1)
	addi	r1, r1, 8
	mtlr	r0
	blr

/* void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op1); */
	.global	cpu_post_exec_21
cpu_post_exec_21:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r5, -4(r1)

	li	r0, 0
	mtxer	r0
	lwz	r0, 0(r4)
	mtcr	r0

	mtlr	r3
	mr	r3, r6
	blrl

	mfcr	r0
	lwz	r4, 4(r1)
	stw	r0, 0(r4)
	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 8(r1)
	addi	r1, r1, 12
	mtlr	r0
	blr

/* void cpu_post_exec_22 (ulong *code, ulong *cr, ulong *res, ulong op1,
    ulong op2); */
	.global	cpu_post_exec_22
cpu_post_exec_22:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r5, -4(r1)

	li	r0, 0
	mtxer	r0
	lwz	r0, 0(r4)
	mtcr	r0

	mtlr	r3
	mr	r3, r6
	mr	r4, r7
	blrl

	mfcr	r0
	lwz	r4, 4(r1)
	stw	r0, 0(r4)
	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 8(r1)
	addi	r1, r1, 12
	mtlr	r0
	blr

/* void cpu_post_exec_12w (ulong *code, ulong *op1, ulong op2, ulong op3); */
	.global	cpu_post_exec_12w
cpu_post_exec_12w:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)

	mtlr	r3
	lwz	r3, 0(r4)
	mr	r4, r5
	mr	r5, r6
	blrl

	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 4(r1)
	addi	r1, r1, 8
	mtlr	r0
	blr

/* void cpu_post_exec_11w (ulong *code, ulong *op1, ulong op2); */
	.global	cpu_post_exec_11w
cpu_post_exec_11w:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)

	mtlr	r3
	lwz	r3, 0(r4)
	mr	r4, r5
	blrl

	lwz	r4, 0(r1)
	stw	r3, 0(r4)

	lwz	r0, 4(r1)
	addi	r1, r1, 8
	mtlr	r0
	blr

/* void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3); */
	.global	cpu_post_exec_22w
cpu_post_exec_22w:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r6, -4(r1)

	mtlr	r3
	lwz	r3, 0(r4)
	mr	r4, r5
	blrl

	lwz	r4, 4(r1)
	stw	r3, 0(r4)
	lwz	r4, 0(r1)
	stw	r5, 0(r4)

	lwz	r0, 8(r1)
	addi	r1, r1, 12
	mtlr	r0
	blr

/* void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2); */
	.global	cpu_post_exec_21w
cpu_post_exec_21w:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r5, -4(r1)

	mtlr	r3
	lwz	r3, 0(r4)
	blrl

	lwz	r5, 4(r1)
	stw	r3, 0(r5)
	lwz	r5, 0(r1)
	stw	r4, 0(r5)

	lwz	r0, 8(r1)
	addi	r1, r1, 12
	mtlr	r0
	blr

/* void cpu_post_exec_21x (ulong *code, ulong *op1, ulong *op2, ulong op3); */
	.global	cpu_post_exec_21x
cpu_post_exec_21x:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r5, -4(r1)

	mtlr	r3
	mr	r3, r6
	blrl

	lwz	r5, 4(r1)
	stw	r3, 0(r5)
	lwz	r5, 0(r1)
	stw	r4, 0(r5)

	lwz	r0, 8(r1)
	addi	r1, r1, 12
	mtlr	r0
	blr

/* void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump,
    ulong cr); */
	.global	cpu_post_exec_31
cpu_post_exec_31:
	isync
	mflr	r0
	stwu	r0, -4(r1)
	stwu	r4, -4(r1)
	stwu	r5, -4(r1)
	stwu	r6, -4(r1)

	mtlr	r3
	lwz	r3, 0(r4)
	lwz	r4, 0(r5)
	mr	r6, r7

	mfcr	r7
	blrl
	mtcr	r7

	lwz	r7, 8(r1)
	stw	r3, 0(r7)
	lwz	r7, 4(r1)
	stw	r4, 0(r7)
	lwz	r7, 0(r1)
	stw	r5, 0(r7)

	lwz	r0, 12(r1)
	addi	r1, r1, 16
	mtlr	r0
	blr

/* int cpu_post_complex_1_asm (int a1, int a2, int a3, int a4, int n); */
	.global	cpu_post_complex_1_asm
cpu_post_complex_1_asm:
	li	r9,0
	cmpw	r9,r7
	bge	cpu_post_complex_1_done
	mtctr	r7
cpu_post_complex_1_loop:
	mullw	r0,r3,r4
	subf	r0,r5,r0
	divw	r0,r0,r6
	add	r9,r9,r0
	bdnz	cpu_post_complex_1_loop
cpu_post_complex_1_done:
	mr	r3,r9
	blr

/* int cpu_post_complex_2_asm (int x, int n); */
	.global	cpu_post_complex_2_asm
cpu_post_complex_2_asm:
	mr.	r0,r4
	mtctr	r0
	mr	r0,r3
	li	r3,1
	li	r4,1
	blelr
cpu_post_complex_2_loop:
	mullw	r3,r3,r0
	add	r3,r3,r4
	bdnz	cpu_post_complex_2_loop
blr

#endif