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
359
360
361
362
363
364
365
366
|
/*
* tbictx.S
*
* Copyright (C) 2001, 2002, 2007, 2012 Imagination Technologies.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* Explicit state save and restore routines forming part of the thread binary
* interface for META processors
*/
.file "tbictx.S"
#include <asm/metag_regs.h>
#include <asm/tbx.h>
#ifdef METAC_1_0
/* Ax.4 is NOT saved in XAX3 */
#define A0_4
#else
/* Ax.4 is saved in XAX4 */
#define A0_4 A0.4,
#endif
/* Size of the TBICTX structure */
#define TBICTX_BYTES ((TBICTX_AX_REGS*8)+TBICTX_AX)
/*
* TBIRES __TBINestInts( TBIRES State, void *pExt, int NoNestMask )
*/
.text
.balign 4
.global ___TBINestInts
.type ___TBINestInts,function
___TBINestInts:
XOR D0Ar4,D0Ar4,#-1 /* D0Ar4 = ~TrigBit */
AND D0Ar4,D0Ar4,#0xFFFF /* D0Ar4 &= 0xFFFF */
MOV D0Ar6,TXMASKI /* BGNDHALT currently enabled? */
TSTT D0Ar2,#TBICTX_XDX8_BIT+TBICTX_XAXX_BIT+TBICTX_XHL2_BIT+TBICTX_XTDP_BIT+TBICTX_XCBF_BIT
AND D0Ar4,D0Ar2,D0Ar4 /* D0Ar4 = Ints to allow */
XOR D0Ar2,D0Ar2,D0Ar4 /* Less Ints in TrigMask */
BNZ ___TBINestInts2 /* Jump if ctx save required! */
TSTT D0Ar2,#TBICTX_CBUF_BIT+TBICTX_CBRP_BIT /* Is catch state dirty? */
OR D0Ar4,D0Ar4,D0Ar6 /* Or in TXMASKI BGNDHALT if set */
TSTNZ D0Ar4,D0Ar4 /* Yes: AND triggers enabled */
MOV D0Re0,D0Ar2 /* Update State argument */
MOV D1Re0,D1Ar1 /* with less Ints in TrigMask */
MOVZ TXMASKI,D0Ar4 /* Early return: Enable Ints */
MOVZ PC,D1RtP /* Early return */
.size ___TBINestInts,.-___TBINestInts
/*
* Drop thru into sub-function-
*/
.global ___TBINestInts2
.type ___TBINestInts2,function
___TBINestInts2:
MOV D0FrT,A0FrP /* Full entry sequence so we */
ADD A0FrP,A0StP,#0 /* can make sub-calls */
MSETL [A0StP],D0FrT,D0.5,D0.6 /* and preserve our result */
ORT D0Ar2,D0Ar2,#TBICTX_XCBF_BIT /* Add in XCBF save request */
MOV D0.5,D0Ar2 /* Save State in DX.5 */
MOV D1.5,D1Ar1
OR D0.6,D0Ar4,D0Ar6 /* Save TrigMask in D0.6 */
MOVT D1RtP,#HI(___TBICtxSave) /* Save catch buffer */
CALL D1RtP,#LO(___TBICtxSave)
MOV TXMASKI,D0.6 /* Allow Ints */
MOV D0Re0,D0.5 /* Return State */
MOV D1Re0,D1.5
MGETL D0FrT,D0.5,D0.6,[A0FrP] /* Full exit sequence */
SUB A0StP,A0FrP,#(8*3)
MOV A0FrP,D0FrT
MOV PC,D1RtP
.size ___TBINestInts2,.-___TBINestInts2
/*
* void *__TBICtxSave( TBIRES State, void *pExt )
*
* D0Ar2 contains TBICTX_*_BIT values that control what
* extended data is to be saved beyond the end of D1Ar1.
* These bits must be ored into the SaveMask of this structure.
*
* Virtually all possible scratch registers are used.
*
* The D1Ar1 parameter is only used as the basis for saving
* CBUF state.
*/
/*
* If TBICTX_XEXT_BIT is specified in State. then State.pCtx->Ext is
* utilised to save the base address of the context save area and
* the extended states saved. The XEXT flag then indicates that the
* original state of the A0.2 and A1.2 registers from TBICTX.Ext.AX2
* are stored as the first part of the extended state structure.
*/
.balign 4
.global ___TBICtxSave
.type ___TBICtxSave,function
___TBICtxSave:
GETD D0Re0,[D1Ar1+#TBICTX_SaveMask-2] /* Get SaveMask */
TSTT D0Ar2,#TBICTX_XDX8_BIT+TBICTX_XAXX_BIT+TBICTX_XHL2_BIT+TBICTX_XTDP_BIT+TBICTX_XEXT_BIT
/* Just XCBF to save? */
MOV A0.2,D1Ar3 /* Save pointer into A0.2 */
MOV A1.2,D1RtP /* Free off D0FrT:D1RtP pair */
BZ $LCtxSaveCBUF /* Yes: Only XCBF may be saved */
TSTT D0Ar2,#TBICTX_XEXT_BIT /* Extended base-state model? */
BZ $LCtxSaveXDX8
GETL D0Ar6,D1Ar5,[D1Ar1+#TBICTX_Ext_AX2] /* Get A0.2, A1.2 state */
MOV D0Ar4,D0Ar2 /* Extract Ctx.SaveFlags value */
ANDMT D0Ar4,D0Ar4,#TBICTX_XDX8_BIT+TBICTX_XAXX_BIT+TBICTX_XHL2_BIT+TBICTX_XTDP_BIT+TBICTX_XEXT_BIT
SETD [D1Ar1+#TBICTX_Ext_Ctx_pExt],A0.2
SETD [D1Ar1+#TBICTX_Ext_Ctx_SaveMask-2],D0Ar4
SETL [A0.2++],D0Ar6,D1Ar5 /* Save A0.2, A1.2 state */
$LCtxSaveXDX8:
TSTT D0Ar2,#TBICTX_XDX8_BIT /* Save extended DX regs? */
BZ $LCtxSaveXAXX
/*
* Save 8 extra DX registers
*/
MSETL [A0.2],D0.8,D0.9,D0.10,D0.11,D0.12,D0.13,D0.14,D0.15
$LCtxSaveXAXX:
TSTT D0Ar2,#TBICTX_XAXX_BIT /* Save extended AX regs? */
SWAP D0Re0,A0.2 /* pDst into D0Re0 */
BZ $LCtxSaveXHL2
/*
* Save 4 extra AX registers
*/
MSETL [D0Re0], A0_4 A0.5,A0.6,A0.7 /* Save 8*3 bytes */
$LCtxSaveXHL2:
TSTT D0Ar2,#TBICTX_XHL2_BIT /* Save hardware-loop regs? */
SWAP D0Re0,A0.2 /* pDst back into A0.2 */
MOV D0Ar6,TXL1START
MOV D1Ar5,TXL2START
BZ $LCtxSaveXTDP
/*
* Save hardware loop registers
*/
SETL [A0.2++],D0Ar6,D1Ar5 /* Save 8*1 bytes */
MOV D0Ar6,TXL1END
MOV D1Ar5,TXL2END
MOV D0FrT,TXL1COUNT
MOV D1RtP,TXL2COUNT
MSETL [A0.2],D0Ar6,D0FrT /* Save 8*2 bytes */
/*
* Clear loop counters to disable any current loops
*/
XOR TXL1COUNT,D0FrT,D0FrT
XOR TXL2COUNT,D1RtP,D1RtP
$LCtxSaveXTDP:
TSTT D0Ar2,#TBICTX_XTDP_BIT /* Save per-thread DSP regs? */
BZ $LCtxSaveCBUF
/*
* Save per-thread DSP registers; ACC.0, PR.0, PI.1-3 (PI.0 is zero)
*/
#ifndef CTX_NO_DSP
D SETL [A0.2++],AC0.0,AC1.0 /* Save ACx.0 lower 32-bits */
DH SETL [A0.2++],AC0.0,AC1.0 /* Save ACx.0 upper 32-bits */
D SETL [A0.2++],D0AR.0,D1AR.0 /* Save DSP RAM registers */
D SETL [A0.2++],D0AR.1,D1AR.1
D SETL [A0.2++],D0AW.0,D1AW.0
D SETL [A0.2++],D0AW.1,D1AW.1
D SETL [A0.2++],D0BR.0,D1BR.0
D SETL [A0.2++],D0BR.1,D1BR.1
D SETL [A0.2++],D0BW.0,D1BW.0
D SETL [A0.2++],D0BW.1,D1BW.1
D SETL [A0.2++],D0ARI.0,D1ARI.0
D SETL [A0.2++],D0ARI.1,D1ARI.1
D SETL [A0.2++],D0AWI.0,D1AWI.0
D SETL [A0.2++],D0AWI.1,D1AWI.1
D SETL [A0.2++],D0BRI.0,D1BRI.0
D SETL [A0.2++],D0BRI.1,D1BRI.1
D SETL [A0.2++],D0BWI.0,D1BWI.0
D SETL [A0.2++],D0BWI.1,D1BWI.1
D SETD [A0.2++],T0
D SETD
|