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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 27 unneback
##=============================================================================
2
##
3
##      context.S
4
##
5
##      SH 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):   jskov
44
## Contributors:jskov
45
## Date:        1999-05-01
46
## Purpose:     SH 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 
58
#include 
59
#include            // CYG_LABEL_DEFN
60
 
61
#------------------------------------------------------------------------------
62
# Register allocation for the Hitachi calling convention:
63
#
64
#       r0              arg return
65
#       r1..r3          scratch
66
#       r4..r7          args in
67
#       r8..r13         call saved
68
#       r14             frame pointer/call saved
69
#       r15             stack pointer
70
#       ap              arg pointer (doesn''t really exist, always eliminated)
71
#       pr              subroutine return address
72
#       t               t bit
73
#       mach            multiply/accumulate result, high part
74
#       macl            multiply/accumulate result, low part.
75
#       fpul            fp/int communication register
76
#       rap             return address pointer register
77
#       fr0             fp arg return
78
#       fr1..fr3        scratch floating point registers
79
#       fr4..fr11       fp args in
80
#       fr12..fr15      call saved floating point registers
81
#------------------------------------------------------------------------------
82
 
83
 
84
#------------------------------------------------------------------------------
85
# hal_thread_switch_context
86
# Switch thread contexts
87
# R4 = address of sp of next thread to execute
88
# R5 = address of sp save location of current thread
89
 
90
# Need to save r8-r13, r14 (fp), r15 (sp), pr, mach, macl
91
 
92
FUNC_START(hal_thread_switch_context)
93
        mov     r15, r0                 ! R0 = saved stack pointer
94
 
95
        sts.l   pr,@-r15                ! save caller in PC slot so it looks
96
                                        ! sensible when GDB examines it
97
        stc     sr,r1
98
        mov.l   r1,@-r15
99
 
100
        sts.l   pr,@-r15                ! return address
101
        sts.l   macl,@-r15              ! macl
102
        sts.l   mach,@-r15              ! mach
103
        mov.l   r0,@-r15                ! saved r15 (entry sp)
104
        mov.l   r14,@-r15               ! r14-r0
105
        mov.l   r13,@-r15
106
        mov.l   r12,@-r15
107
        mov.l   r11,@-r15
108
        mov.l   r10,@-r15
109
        mov.l   r9,@-r15
110
        mov.l   r8,@-r15
111
        mov.l   r7,@-r15
112
        mov.l   r6,@-r15
113
        mov.l   r5,@-r15
114
        mov.l   r4,@-r15
115
        mov.l   r3,@-r15
116
        mov.l   r2,@-r15
117
        mov.l   r1,@-r15
118
        mov.l   r0,@-r15
119
 
120
        mov.l   r15,@r5                 ! save SP into save location
121
 
122
        # Now load the destination thread by dropping through
123
        # to hal_thread_load_context
124
 
125
#------------------------------------------------------------------------------
126
# hal_thread_load_context
127
# Load thread context
128
# R4 = address of sp of next thread to execute
129
# Note that this function is also the second half of hal_thread_switch_context
130
# and is simply dropped into from it.
131
 
132
FUNC_START(hal_thread_load_context)
133
 
134
        mov.l   @r4,r0
135
 
136
        add     #4+4,r0                 ! skip r0 and r1
137
        !mov.l   @r0+,r0
138
        !mov.l   @r0+,r1
139
        mov.l   @r0+,r2
140
        mov.l   @r0+,r3
141
        mov.l   @r0+,r4
142
        mov.l   @r0+,r5
143
        mov.l   @r0+,r6
144
        mov.l   @r0+,r7
145
        mov.l   @r0+,r8
146
        mov.l   @r0+,r9
147
        mov.l   @r0+,r10
148
        mov.l   @r0+,r11
149
        mov.l   @r0+,r12
150
        mov.l   @r0+,r13
151
        mov.l   @r0+,r14
152
        mov.l   @r0+,r3                 ! New SP.
153
 
154
        lds.l   @r0+,mach               ! mach
155
        lds.l   @r0+,macl               ! macl
156
        lds.l   @r0+,pr                 ! pr
157
 
158
        mov     r3,r15                  ! update stack pointer
159
 
160
        mov.l   @r0+,r2                 ! SR
161
        hal_cpu_int_merge r2,r0,r1      ! restore interrupt state
162
 
163
        rts                             ! and return
164
         nop
165
 
166
#------------------------------------------------------------------------------
167
# HAL longjmp, setjmp implementations
168
# hal_setjmp saves only to callee save registers r8-r13, r14(fp), r15(sp)
169
# and pr into buffer supplied in r4[arg0]
170
 
171
FUNC_START(hal_setjmp)
172
        mov.l   r15,@(CYGARC_JMPBUF_SP,r4)
173
        sts     pr,r0
174
        mov.l   r0,@(CYGARC_JMPBUF_PR,r4)
175
        mov.l   r8,@(CYGARC_JMPBUF_R8,r4)
176
        mov.l   r9,@(CYGARC_JMPBUF_R9,r4)
177
        mov.l   r10,@(CYGARC_JMPBUF_R10,r4)
178
        mov.l   r11,@(CYGARC_JMPBUF_R11,r4)
179
        mov.l   r12,@(CYGARC_JMPBUF_R12,r4)
180
        mov.l   r13,@(CYGARC_JMPBUF_R13,r4)
181
        mov.l   r14,@(CYGARC_JMPBUF_R14,r4)
182
 
183
        mov    #0,r0            ! return 0
184
        rts
185
         nop
186
 
187
# hal_longjmp loads state from r4[arg0] and returns
188
# argument supplied in r5[arg1]
189
 
190
FUNC_START(hal_longjmp)
191
        mov.l   @(CYGARC_JMPBUF_SP,r4),r15
192
        mov.l   @(CYGARC_JMPBUF_PR,r4),r0
193
        lds     r0,pr
194
        mov.l   @(CYGARC_JMPBUF_R8,r4),r8
195
        mov.l   @(CYGARC_JMPBUF_R9,r4),r9
196
        mov.l   @(CYGARC_JMPBUF_R10,r4),r10
197
        mov.l   @(CYGARC_JMPBUF_R11,r4),r11
198
        mov.l   @(CYGARC_JMPBUF_R12,r4),r12
199
        mov.l   @(CYGARC_JMPBUF_R13,r4),r13
200
        mov.l   @(CYGARC_JMPBUF_R14,r4),r14
201
 
202
        mov     r5,r0
203
        rts
204
         nop
205
 
206
#------------------------------------------------------------------------------
207
# end of context.S

powered by: WebSVN 2.1.0

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