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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [frv/] [arch/] [v2_0/] [src/] [context.S] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
// #===========================================================================
2
// #
3
// #    context.S
4
// #
5
// #    FUJITSU context switch code
6
// #
7
// #===========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
// #===========================================================================
41
// ######DESCRIPTIONBEGIN####
42
// #
43
// # Author(s):    nickg, gthomas
44
// # Contributors: nickg, gthomas
45
// # Date:         1998-09-15
46
// # Purpose:      FUJITSU context switch code
47
// # Description:  This file contains implementations of the thread context
48
// #               switch routines. It also contains the longjmp() and setjmp()
49
// #               routines.
50
// #
51
// #####DESCRIPTIONEND####
52
// #
53
// #===========================================================================
54
 
55
#include 
56
 
57
#include "frv.inc"
58
 
59
        .text
60
 
61
// ----------------------------------------------------------------------------
62
//  hal_thread_switch_context(new, old)
63
//  Switch thread contexts
64
//  new = address of context of next thread to execute
65
//  old = address of context save location of current thread
66
//  thread state is saved on the current stack
67
 
68
        .globl  hal_thread_switch_context
69
hal_thread_switch_context:
70
        subi    sp,_TS_size,sp          // Space for saved frame
71
        sti     gr2,@(sp,_TS_GPR2)       // Save registers
72
        sti     gr3,@(sp,_TS_GPR3)
73
        sti     gr4,@(sp,_TS_GPR4)
74
        sti     gr5,@(sp,_TS_GPR5)
75
        sti     gr6,@(sp,_TS_GPR6)
76
        sti     gr7,@(sp,_TS_GPR7)
77
        sti     gr8,@(sp,_TS_GPR8)
78
        sti     gr9,@(sp,_TS_GPR9)
79
        sti     gr10,@(sp,_TS_GPR10)
80
        sti     gr11,@(sp,_TS_GPR11)
81
        sti     gr12,@(sp,_TS_GPR12)
82
        sti     gr13,@(sp,_TS_GPR13)
83
        sti     gr14,@(sp,_TS_GPR14)
84
        sti     gr15,@(sp,_TS_GPR15)
85
        sti     gr16,@(sp,_TS_GPR16)
86
        sti     gr17,@(sp,_TS_GPR17)
87
        sti     gr18,@(sp,_TS_GPR18)
88
        sti     gr19,@(sp,_TS_GPR19)
89
        sti     gr20,@(sp,_TS_GPR20)
90
        sti     gr21,@(sp,_TS_GPR21)
91
        sti     gr22,@(sp,_TS_GPR22)
92
        sti     gr23,@(sp,_TS_GPR23)
93
        sti     gr24,@(sp,_TS_GPR24)
94
        sti     gr25,@(sp,_TS_GPR25)
95
        sti     gr26,@(sp,_TS_GPR26)
96
        sti     gr27,@(sp,_TS_GPR27)
97
        sti     gr28,@(sp,_TS_GPR28)
98
        sti     gr29,@(sp,_TS_GPR29)
99
        sti     gr30,@(sp,_TS_GPR30)
100
        sti     gr31,@(sp,_TS_GPR31)
101
#if _NGPR != 32
102
        sti     gr32,@(sp,_TS_GPR32)
103
        sti     gr33,@(sp,_TS_GPR33)
104
        sti     gr34,@(sp,_TS_GPR34)
105
        sti     gr35,@(sp,_TS_GPR35)
106
        sti     gr36,@(sp,_TS_GPR36)
107
        sti     gr37,@(sp,_TS_GPR37)
108
        sti     gr38,@(sp,_TS_GPR38)
109
        sti     gr39,@(sp,_TS_GPR39)
110
        sti     gr40,@(sp,_TS_GPR40)
111
        sti     gr41,@(sp,_TS_GPR41)
112
        sti     gr42,@(sp,_TS_GPR42)
113
        sti     gr43,@(sp,_TS_GPR43)
114
        sti     gr44,@(sp,_TS_GPR44)
115
        sti     gr45,@(sp,_TS_GPR45)
116
        sti     gr46,@(sp,_TS_GPR46)
117
        sti     gr47,@(sp,_TS_GPR47)
118
        sti     gr48,@(sp,_TS_GPR48)
119
        sti     gr49,@(sp,_TS_GPR49)
120
        sti     gr50,@(sp,_TS_GPR50)
121
        sti     gr51,@(sp,_TS_GPR51)
122
        sti     gr52,@(sp,_TS_GPR52)
123
        sti     gr53,@(sp,_TS_GPR53)
124
        sti     gr54,@(sp,_TS_GPR54)
125
        sti     gr55,@(sp,_TS_GPR55)
126
        sti     gr56,@(sp,_TS_GPR56)
127
        sti     gr57,@(sp,_TS_GPR57)
128
        sti     gr58,@(sp,_TS_GPR58)
129
        sti     gr59,@(sp,_TS_GPR59)
130
        sti     gr60,@(sp,_TS_GPR60)
131
        sti     gr61,@(sp,_TS_GPR61)
132
        sti     gr62,@(sp,_TS_GPR62)
133
        sti     gr63,@(sp,_TS_GPR63)
134
#endif
135
        movsg   psr,gr4
136
        sti     gr4,@(sp,_TS_PSR)
137
        movsg   lr,gr4
138
        sti     gr4,@(sp,_TS_PC)
139
        movsg   ccr,gr4
140
        sti     gr4,@(sp,_TS_CCR)
141
        movsg   lcr,gr4
142
        sti     gr4,@(sp,_TS_LCR)
143
        movsg   cccr,gr4
144
        sti     gr4,@(sp,_TS_CCCR)
145
        addi    sp,_TS_size,gr4
146
        sti     gr4,@(sp,_TS_SP)
147
        sti     sp,@(gr9,0)             // Pointer to saved context
148
 
149
        # Now load the destination thread by dropping through
150
        # to hal_thread_load_context
151
 
152
// ----------------------------------------------------------------------------
153
//  hal_thread_load_context(new)
154
//  Load thread context
155
//  new = address of context of next thread to execute
156
//  Note that this function is also the second half of
157
//  hal_thread_switch_context and is simply dropped into from it.
158
 
159
        .globl  hal_thread_load_context
160
hal_thread_load_context:
161
        ldi     @(gr8,0),sp             // Saved context
162
        ldi     @(sp,_TS_PSR),gr8
163
        setlos  #~_PSR_ET,gr9           // Turn off exceptions
164
        and     gr8,gr9,gr8
165
        setlos  #_PSR_PS|_PSR_S,gr9     // Stay in supervisor mode
166
        or      gr8,gr9,gr8
167
        movgs   gr8,psr
168
        ldi     @(sp,_TS_PC),gr8
169
        movgs   gr8,pcsr
170
        ldi     @(sp,_TS_CCR),gr8
171
        movgs   gr8,ccr
172
        ldi     @(sp,_TS_LCR),gr8
173
        movgs   gr8,lcr
174
        ldi     @(sp,_TS_CCCR),gr8
175
        movgs   gr8,cccr
176
        ldi     @(sp,_TS_GPR2),gr2       // Restore registers
177
        ldi     @(sp,_TS_GPR3),gr3
178
        ldi     @(sp,_TS_GPR4),gr4
179
        ldi     @(sp,_TS_GPR5),gr5
180
        ldi     @(sp,_TS_GPR6),gr6
181
        ldi     @(sp,_TS_GPR7),gr7
182
        ldi     @(sp,_TS_GPR8),gr8
183
        ldi     @(sp,_TS_GPR9),gr9
184
        ldi     @(sp,_TS_GPR10),gr10
185
        ldi     @(sp,_TS_GPR11),gr11
186
        ldi     @(sp,_TS_GPR12),gr12
187
        ldi     @(sp,_TS_GPR13),gr13
188
        ldi     @(sp,_TS_GPR14),gr14
189
        ldi     @(sp,_TS_GPR15),gr15
190
        ldi     @(sp,_TS_GPR16),gr16
191
        ldi     @(sp,_TS_GPR17),gr17
192
        ldi     @(sp,_TS_GPR18),gr18
193
        ldi     @(sp,_TS_GPR19),gr19
194
        ldi     @(sp,_TS_GPR20),gr20
195
        ldi     @(sp,_TS_GPR21),gr21
196
        ldi     @(sp,_TS_GPR22),gr22
197
        ldi     @(sp,_TS_GPR23),gr23
198
        ldi     @(sp,_TS_GPR24),gr24
199
        ldi     @(sp,_TS_GPR25),gr25
200
        ldi     @(sp,_TS_GPR26),gr26
201
        ldi     @(sp,_TS_GPR27),gr27
202
        ldi     @(sp,_TS_GPR28),gr28
203
        ldi     @(sp,_TS_GPR29),gr29
204
        ldi     @(sp,_TS_GPR30),gr30
205
        ldi     @(sp,_TS_GPR31),gr31
206
#if _NGPR != 32
207
        ldi     @(sp,_TS_GPR32),gr32
208
        ldi     @(sp,_TS_GPR33),gr33
209
        ldi     @(sp,_TS_GPR34),gr34
210
        ldi     @(sp,_TS_GPR35),gr35
211
        ldi     @(sp,_TS_GPR36),gr36
212
        ldi     @(sp,_TS_GPR37),gr37
213
        ldi     @(sp,_TS_GPR38),gr38
214
        ldi     @(sp,_TS_GPR39),gr39
215
        ldi     @(sp,_TS_GPR40),gr40
216
        ldi     @(sp,_TS_GPR41),gr41
217
        ldi     @(sp,_TS_GPR42),gr42
218
        ldi     @(sp,_TS_GPR43),gr43
219
        ldi     @(sp,_TS_GPR44),gr44
220
        ldi     @(sp,_TS_GPR45),gr45
221
        ldi     @(sp,_TS_GPR46),gr46
222
        ldi     @(sp,_TS_GPR47),gr47
223
        ldi     @(sp,_TS_GPR48),gr48
224
        ldi     @(sp,_TS_GPR49),gr49
225
        ldi     @(sp,_TS_GPR50),gr50
226
        ldi     @(sp,_TS_GPR51),gr51
227
        ldi     @(sp,_TS_GPR52),gr52
228
        ldi     @(sp,_TS_GPR53),gr53
229
        ldi     @(sp,_TS_GPR54),gr54
230
        ldi     @(sp,_TS_GPR55),gr55
231
        ldi     @(sp,_TS_GPR56),gr56
232
        ldi     @(sp,_TS_GPR57),gr57
233
        ldi     @(sp,_TS_GPR58),gr58
234
        ldi     @(sp,_TS_GPR59),gr59
235
        ldi     @(sp,_TS_GPR60),gr60
236
        ldi     @(sp,_TS_GPR61),gr61
237
        ldi     @(sp,_TS_GPR62),gr62
238
        ldi     @(sp,_TS_GPR63),gr63
239
#endif
240
        ldi     @(sp,_TS_SP),sp
241
        rett    #0
242
 
243
// ----------------------------------------------------------------------------
244
//  HAL longjmp, setjmp implementations - based on newlib
245
//    Register      jmpbuf offset
246
//    R16-R31       0x0-0x03c
247
//    R48-R63       0x40-0x7c
248
//    FR16-FR31     0x80-0xbc
249
//    FR48-FR63     0xc0-0xfc
250
//    LR            0x100
251
//    SP            0x104
252
//    FP            0x108
253
//
254
// R8 contains the pointer to jmpbuf
255
 
256
        .text
257
        .global hal_setjmp
258
        .type   hal_setjmp,@function
259
hal_setjmp:
260
        stdi    gr16, @(gr8,0)
261
        stdi    gr18, @(gr8,8)
262
        stdi    gr20, @(gr8,16)
263
        stdi    gr22, @(gr8,24)
264
        stdi    gr24, @(gr8,32)
265
        stdi    gr26, @(gr8,40)
266
        stdi    gr28, @(gr8,48)
267
        stdi    gr30, @(gr8,56)
268
#if _NGPR != 32
269
        stdi    gr48, @(gr8,64)
270
        stdi    gr50, @(gr8,72)
271
        stdi    gr52, @(gr8,80)
272
        stdi    gr54, @(gr8,88)
273
        stdi    gr56, @(gr8,96)
274
        stdi    gr58, @(gr8,104)
275
        stdi    gr60, @(gr8,112)
276
        stdi    gr62, @(gr8,120)
277
#endif
278
 
279
#if _NFPR != 0
280
        stdfi   fr16, @(gr8,128)
281
        stdfi   fr18, @(gr8,136)
282
        stdfi   fr20, @(gr8,144)
283
        stdfi   fr22, @(gr8,152)
284
        stdfi   fr24, @(gr8,160)
285
        stdfi   fr26, @(gr8,168)
286
        stdfi   fr28, @(gr8,176)
287
        stdfi   fr30, @(gr8,184)
288
#if _NFPR != 32
289
        stdfi   fr48, @(gr8,192)
290
        stdfi   fr50, @(gr8,200)
291
        stdfi   fr52, @(gr8,208)
292
        stdfi   fr54, @(gr8,216)
293
        stdfi   fr56, @(gr8,224)
294
        stdfi   fr58, @(gr8,232)
295
        stdfi   fr60, @(gr8,240)
296
        stdfi   fr62, @(gr8,248)
297
#endif
298
#endif
299
 
300
        movsg   lr, gr4
301
        sti     gr4, @(gr8,256)
302
        sti     sp, @(gr8,260)
303
        sti     fp, @(gr8,264)
304
 
305
        mov     gr0,gr8
306
        ret
307
.Lend1:
308
        .size   hal_setjmp,.Lend1-hal_setjmp
309
 
310
        .global hal_longjmp
311
        .type   hal_longjmp,@function
312
hallongjmp:
313
        lddi    @(gr8,0), gr16
314
        lddi    @(gr8,8), gr18
315
        lddi    @(gr8,16), gr20
316
        lddi    @(gr8,24), gr22
317
        lddi    @(gr8,32), gr24
318
        lddi    @(gr8,40), gr26
319
        lddi    @(gr8,48), gr28
320
        lddi    @(gr8,56), gr30
321
#if _NGPR != 32
322
        lddi    @(gr8,64), gr48
323
        lddi    @(gr8,72), gr50
324
        lddi    @(gr8,80), gr52
325
        lddi    @(gr8,88), gr54
326
        lddi    @(gr8,96), gr56
327
        lddi    @(gr8,104), gr58
328
        lddi    @(gr8,112), gr60
329
        lddi    @(gr8,120), gr62
330
#endif
331
 
332
#if _NFPR != 0
333
        lddfi   @(gr8,128), fr16
334
        lddfi   @(gr8,136), fr18
335
        lddfi   @(gr8,144), fr20
336
        lddfi   @(gr8,152), fr22
337
        lddfi   @(gr8,160), fr24
338
        lddfi   @(gr8,168), fr26
339
        lddfi   @(gr8,176), fr28
340
        lddfi   @(gr8,184), fr30
341
#if _NFPR != 32
342
        lddfi   @(gr8,192), fr48
343
        lddfi   @(gr8,200), fr50
344
        lddfi   @(gr8,208), fr52
345
        lddfi   @(gr8,216), fr54
346
        lddfi   @(gr8,224), fr56
347
        lddfi   @(gr8,232), fr58
348
        lddfi   @(gr8,240), fr60
349
        lddfi   @(gr8,248), fr62
350
#endif
351
#endif
352
 
353
        ldi     @(gr8,256), gr4
354
        movgs   gr4,lr
355
 
356
        ldi     @(gr8,260), sp
357
        ldi     @(gr8,264), fp
358
 
359
# Value to return is in r9.  If zero, return 1
360
        cmp     gr9, gr0, icc0
361
        setlos  #1, gr8
362
        ckne    icc0, cc4
363
        cmov    gr9, gr8, cc4, 1
364
        ret
365
.Lend2:
366
        .size   hal_longjmp,.Lend2-hal_longjmp2
367
 
368
// ----------------------------------------------------------------------------
369
//  end of context.S

powered by: WebSVN 2.1.0

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