OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-mips64/] [stackframe.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * This file is subject to the terms and conditions of the GNU General Public
3
 * License.  See the file "COPYING" in the main directory of this archive
4
 * for more details.
5
 *
6
 * Copyright (C) 1994, 1995, 1996, 1999 Ralf Baechle
7
 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
8
 * Copyright (C) 1999 Silicon Graphics, Inc.
9
 */
10
#ifndef _ASM_STACKFRAME_H
11
#define _ASM_STACKFRAME_H
12
 
13
#include <linux/config.h>
14
#include <linux/threads.h>
15
 
16
#include <asm/asm.h>
17
#include <asm/offset.h>
18
#include <asm/processor.h>
19
#include <asm/addrspace.h>
20
 
21
#ifdef __ASSEMBLY__
22
 
23
                .macro  SAVE_AT
24
                .set    push
25
                .set    noat
26
                sd      $1, PT_R1(sp)
27
                .set    pop
28
                .endm
29
 
30
                .macro  SAVE_TEMP
31
                mfhi    v1
32
                sd      v1, PT_HI(sp)
33
                mflo    v1
34
                sd      $10, PT_R10(sp)
35
                sd      $11, PT_R11(sp)
36
                sd      v1,  PT_LO(sp)
37
                sd      $12, PT_R12(sp)
38
                sd      $13, PT_R13(sp)
39
                sd      $14, PT_R14(sp)
40
                sd      $15, PT_R15(sp)
41
                sd      $24, PT_R24(sp)
42
                .endm
43
 
44
                .macro  SAVE_STATIC
45
                sd      $16, PT_R16(sp)
46
                sd      $17, PT_R17(sp)
47
                sd      $18, PT_R18(sp)
48
                sd      $19, PT_R19(sp)
49
                sd      $20, PT_R20(sp)
50
                sd      $21, PT_R21(sp)
51
                sd      $22, PT_R22(sp)
52
                sd      $23, PT_R23(sp)
53
                sd      $30, PT_R30(sp)
54
                .endm
55
 
56
#ifdef CONFIG_SMP
57
                .macro  get_saved_sp    /* SMP variation */
58
                dmfc0   k1, CP0_CONTEXT
59
                dsra    k1, 23
60
                lui     k0, %hi(pgd_current)
61
                daddiu  k0, %lo(pgd_current)
62
                dsubu   k1, k0
63
                lui     k0, %hi(kernelsp)
64
                daddu   k1, k0
65
                ld      k1, %lo(kernelsp)(k1)
66
                .endm
67
 
68
                .macro  set_saved_sp    stackp temp temp2
69
                lw      \temp, TASK_PROCESSOR(gp)
70
                dsll    \temp, 3
71
                lui     \temp2, %hi(kernelsp)
72
                daddu   \temp, \temp2
73
                sd      \stackp, %lo(kernelsp)(\temp)
74
                .endm
75
#else
76
                .macro  get_saved_sp    /* Uniprocessor variation */
77
                lui     k1, %hi(kernelsp)
78
                ld      k1, %lo(kernelsp)(k1)
79
                .endm
80
 
81
                .macro  set_saved_sp    stackp temp temp2
82
                sd      \stackp, kernelsp
83
                .endm
84
#endif
85
                .macro  declare_saved_sp
86
                .comm   kernelsp, NR_CPUS * 8, 8
87
                .endm
88
 
89
                .macro  SAVE_SOME
90
                .set    push
91
                .set    reorder
92
                mfc0    k0, CP0_STATUS
93
                sll     k0, 3           /* extract cu0 bit */
94
                .set    noreorder
95
                bltz    k0, 8f
96
                 move   k1, sp
97
                .set    reorder
98
                /* Called from user mode, new stack. */
99
                get_saved_sp
100
8:              move    k0, sp
101
                dsubu   sp, k1, PT_SIZE
102
                sd      k0, PT_R29(sp)
103
                sd      $3, PT_R3(sp)
104
                sd      $0, PT_R0(sp)
105
                mfc0    v1, CP0_STATUS
106
                sd      $2, PT_R2(sp)
107
                sd      v1, PT_STATUS(sp)
108
                sd      $4, PT_R4(sp)
109
                mfc0    v1, CP0_CAUSE
110
                sd      $5, PT_R5(sp)
111
                sd      v1, PT_CAUSE(sp)
112
                sd      $6, PT_R6(sp)
113
                dmfc0   v1, CP0_EPC
114
                sd      $7, PT_R7(sp)
115
                sd      $8, PT_R8(sp)
116
                sd      $9, PT_R9(sp)
117
                sd      v1, PT_EPC(sp)
118
                sd      $25, PT_R25(sp)
119
                sd      $28, PT_R28(sp)
120
                sd      $31, PT_R31(sp)
121
                ori     $28, sp, 0x3fff
122
                xori    $28, 0x3fff
123
                .set    pop
124
                .endm
125
 
126
                .macro  SAVE_ALL
127
                SAVE_SOME
128
                SAVE_AT
129
                SAVE_TEMP
130
                SAVE_STATIC
131
                .endm
132
 
133
                .macro  RESTORE_AT
134
                .set    push
135
                .set    noat
136
                ld      $1,  PT_R1(sp)
137
                .set    pop
138
                .endm
139
 
140
                .macro  RESTORE_SP
141
                ld      sp,  PT_R29(sp)
142
                .endm
143
 
144
                .macro  RESTORE_TEMP
145
                ld      $24, PT_LO(sp)
146
                mtlo    $24
147
                ld      $24, PT_HI(sp)
148
                ld      $10, PT_R10(sp)
149
                ld      $11, PT_R11(sp)
150
                mthi    $24
151
                ld      $12, PT_R12(sp)
152
                ld      $13, PT_R13(sp)
153
                ld      $14, PT_R14(sp)
154
                ld      $15, PT_R15(sp)
155
                ld      $24, PT_R24(sp)
156
                .endm
157
 
158
                .macro  RESTORE_STATIC
159
                ld      $16, PT_R16(sp)
160
                ld      $17, PT_R17(sp)
161
                ld      $18, PT_R18(sp)
162
                ld      $19, PT_R19(sp)
163
                ld      $20, PT_R20(sp)
164
                ld      $21, PT_R21(sp)
165
                ld      $22, PT_R22(sp)
166
                ld      $23, PT_R23(sp)
167
                ld      $30, PT_R30(sp)
168
                .endm
169
 
170
                .macro  RESTORE_SOME
171
                .set    push
172
                .set    reorder
173
                mfc0    t0, CP0_STATUS
174
                .set    pop
175
                ori     t0, 0x1f
176
                xori    t0, 0x1f
177
                mtc0    t0, CP0_STATUS
178
                li      v1, 0xff00
179
                and     t0, v1
180
                ld      v0, PT_STATUS(sp)
181
                nor     v1, $0, v1
182
                and     v0, v1
183
                or      v0, t0
184
                mtc0    v0, CP0_STATUS
185
                ld      v1, PT_EPC(sp)
186
                dmtc0   v1, CP0_EPC
187
                ld      $31, PT_R31(sp)
188
                ld      $28, PT_R28(sp)
189
                ld      $25, PT_R25(sp)
190
                ld      $9,  PT_R9(sp)
191
                ld      $8,  PT_R8(sp)
192
                ld      $7,  PT_R7(sp)
193
                ld      $6,  PT_R6(sp)
194
                ld      $5,  PT_R5(sp)
195
                ld      $4,  PT_R4(sp)
196
                ld      $3,  PT_R3(sp)
197
                ld      $2,  PT_R2(sp)
198
                .endm
199
 
200
                .macro  RESTORE_ALL
201
                RESTORE_SOME
202
                RESTORE_AT
203
                RESTORE_TEMP
204
                RESTORE_STATIC
205
                RESTORE_SP
206
                .endm
207
 
208
/*
209
 * Move to kernel mode and disable interrupts.
210
 * Set cp0 enable bit as sign that we're running on the kernel stack
211
 */
212
                .macro  CLI
213
                mfc0    t0, CP0_STATUS
214
                li      t1, ST0_CU0|0x1f
215
                or      t0, t1
216
                xori    t0, 0x1f
217
                mtc0    t0, CP0_STATUS
218
                .endm
219
 
220
/*
221
 * Move to kernel mode and enable interrupts.
222
 * Set cp0 enable bit as sign that we're running on the kernel stack
223
 */
224
                .macro  STI
225
                mfc0    t0, CP0_STATUS
226
                li      t1, ST0_CU0 | 0x1f
227
                or      t0, t1
228
                xori    t0, 0x1e
229
                mtc0    t0, CP0_STATUS
230
                .endm
231
 
232
/*
233
 * Just move to kernel mode and leave interrupts as they are.
234
 * Set cp0 enable bit as sign that we're running on the kernel stack
235
 */
236
                .macro  KMODE
237
                mfc0    t0, CP0_STATUS
238
                li      t1, ST0_CU0 | 0x1e
239
                or      t0, t1
240
                xori    t0, 0x1e
241
                mtc0    t0, CP0_STATUS
242
                .endm
243
 
244
#endif /* __ASSEMBLY__ */
245
 
246
#endif /* _ASM_STACKFRAME_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.