1/*
2 * tbidspram.S
3 *
4 * Copyright (C) 2009, 2012 Imagination Technologies.
5 *
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation.
9 *
10 * Explicit state save and restore routines forming part of the thread binary
11 * interface for META processors
12 */
13
14	.file	"tbidspram.S"
15
16/* These aren't generally useful to a user so for now, they arent publically available */
17#define _TBIECH_DSPRAM_DUA_S    8
18#define _TBIECH_DSPRAM_DUA_BITS 0x7f00
19#define _TBIECH_DSPRAM_DUB_S    0
20#define _TBIECH_DSPRAM_DUB_BITS 0x007f
21
22/*
23 * void *__TBIDspramSaveA( short DspramSizes, void *pExt )
24 */
25	.text
26	.balign	4
27	.global	___TBIDspramSaveA
28	.type	___TBIDspramSaveA,function
29___TBIDspramSaveA:
30
31	SETL	[A0StP++], D0.5, D1.5
32	MOV	A0.3, D0Ar2
33
34	/* D1Ar1 - Dspram Sizes
35	 * A0.4  - Pointer to buffer
36	 */
37
38	/* Save the specified amount of dspram DUA */
39DL	MOV	D0AR.0, #0
40	LSR	D1Ar1, D1Ar1, #_TBIECH_DSPRAM_DUA_S
41	AND	D1Ar1, D1Ar1, #(_TBIECH_DSPRAM_DUA_BITS >> _TBIECH_DSPRAM_DUA_S)
42	SUB	TXRPT, D1Ar1, #1
43$L1:
44DL	MOV	D0Re0, [D0AR.0++]
45DL	MOV	D0Ar6, [D0AR.0++]
46DL	MOV	D0Ar4, [D0AR.0++]
47DL	MOV	D0.5,  [D0AR.0++]
48	MSETL	[A0.3++], D0Re0, D0Ar6, D0Ar4, D0.5
49
50	BR	$L1
51
52	GETL	D0.5, D1.5, [--A0StP]
53	MOV	PC, D1RtP
54
55	.size	___TBIDspramSaveA,.-___TBIDspramSaveA
56
57/*
58 * void *__TBIDspramSaveB( short DspramSizes, void *pExt )
59 */
60	.balign	4
61	.global	___TBIDspramSaveB
62	.type	___TBIDspramSaveB,function
63___TBIDspramSaveB:
64
65	SETL	[A0StP++], D0.5, D1.5
66	MOV	A0.3, D0Ar2
67
68	/* D1Ar1 - Dspram Sizes
69	 * A0.3  - Pointer to buffer
70	 */
71
72	/* Save the specified amount of dspram DUA */
73DL	MOV	D0BR.0, #0
74	LSR	D1Ar1, D1Ar1, #_TBIECH_DSPRAM_DUB_S
75	AND	D1Ar1, D1Ar1, #(_TBIECH_DSPRAM_DUB_BITS >> _TBIECH_DSPRAM_DUB_S)
76	SUB	TXRPT, D1Ar1, #1
77$L2:
78DL	MOV	D0Re0, [D0BR.0++]
79DL	MOV	D0Ar6, [D0BR.0++]
80DL	MOV	D0Ar4, [D0BR.0++]
81DL	MOV	D0.5,  [D0BR.0++]
82	MSETL	[A0.3++], D0Re0, D0Ar6, D0Ar4, D0.5
83
84	BR	$L2
85
86	GETL	D0.5, D1.5, [--A0StP]
87	MOV	PC, D1RtP
88
89	.size	___TBIDspramSaveB,.-___TBIDspramSaveB
90
91/*
92 * void *__TBIDspramRestoreA( short DspramSizes, void *pExt )
93 */
94	.balign	4
95	.global	___TBIDspramRestoreA
96	.type	___TBIDspramRestoreA,function
97___TBIDspramRestoreA:
98
99	SETL	[A0StP++], D0.5, D1.5
100	MOV	A0.3, D0Ar2
101
102	/* D1Ar1 - Dspram Sizes
103	 * A0.3 - Pointer to buffer
104	 */
105
106	/* Restore the specified amount of dspram DUA */
107DL	MOV	D0AW.0, #0
108	LSR	D1Ar1, D1Ar1, #_TBIECH_DSPRAM_DUA_S
109	AND	D1Ar1, D1Ar1, #(_TBIECH_DSPRAM_DUA_BITS >> _TBIECH_DSPRAM_DUA_S)
110	SUB	TXRPT, D1Ar1, #1
111$L3:
112	MGETL	D0Re0, D0Ar6, D0Ar4, D0.5, [A0.3++]
113DL	MOV	[D0AW.0++], D0Re0
114DL	MOV	[D0AW.0++], D0Ar6
115DL	MOV	[D0AW.0++], D0Ar4
116DL	MOV	[D0AW.0++], D0.5
117
118	BR	$L3
119
120	GETL	D0.5, D1.5, [--A0StP]
121	MOV	PC, D1RtP
122
123	.size	___TBIDspramRestoreA,.-___TBIDspramRestoreA
124
125/*
126 * void *__TBIDspramRestoreB( short DspramSizes, void *pExt )
127 */
128	.balign	4
129	.global	___TBIDspramRestoreB
130	.type	___TBIDspramRestoreB,function
131___TBIDspramRestoreB:
132
133	SETL	[A0StP++], D0.5, D1.5
134	MOV	A0.3, D0Ar2
135
136	/* D1Ar1 - Dspram Sizes
137	 * A0.3 - Pointer to buffer
138	 */
139
140	/* Restore the specified amount of dspram DUA */
141DL	MOV	D0BW.0, #0
142	LSR	D1Ar1, D1Ar1, #_TBIECH_DSPRAM_DUB_S
143	AND	D1Ar1, D1Ar1, #(_TBIECH_DSPRAM_DUB_BITS >> _TBIECH_DSPRAM_DUB_S)
144	SUB	TXRPT, D1Ar1, #1
145$L4:
146	MGETL	D0Re0, D0Ar6, D0Ar4, D0.5, [A0.3++]
147DL	MOV	[D0BW.0++], D0Re0
148DL	MOV	[D0BW.0++], D0Ar6
149DL	MOV	[D0BW.0++], D0Ar4
150DL	MOV	[D0BW.0++], D0.5
151
152	BR	$L4
153
154	GETL	D0.5, D1.5, [--A0StP]
155	MOV	PC, D1RtP
156
157	.size	___TBIDspramRestoreB,.-___TBIDspramRestoreB
158
159/*
160 * End of tbidspram.S
161 */
162