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

Subversion Repositories openrisc_me

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

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
##      MN10300 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
44
## Contributors:        nickg
45
## Date:        1998-04-27
46
## Purpose:     MN10300 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
 
59
#------------------------------------------------------------------------------
60
# hal_thread_switch_context
61
# Switch thread contexts
62
# D0 = address of sp of next thread to execute
63
# D1 = address of sp save location of current thread
64
 
65
        .global _hal_thread_switch_context
66
_hal_thread_switch_context:
67
        add     -8,sp           # space for SP and PSW
68
        mov     d2,a0           # move d2->a0 since PSW can only be
69
                                # saved to a data register
70
        hal_cpu_get_psw d2      # save PSW to d2
71
        mov     d2,(4,sp)       # store in stack loc
72
        mov     a0,d2           # retrieve old d2 value
73
        hal_cpu_save_all        # save entire register set
74
        mov     d1,a2           # move save loc addr to A2
75
        mov     sp,(0,a2)       # store SP in save location
76
 
77
        # Now load the destination thread by dropping through
78
        # to hal_thread_load_context
79
 
80
#------------------------------------------------------------------------------
81
# hal_thread_load_context
82
# Load thread context
83
# D0 = address of sp of next thread to execute
84
# Note that this function is also the second half of hal_thread_switch_context
85
# and is simply dropped into from it.
86
 
87
        .global _hal_thread_load_context
88
_hal_thread_load_context:
89
 
90
        mov     d0,a2           # move next sp loc to a2
91
        mov     (0,a2),sp       # load SP with new value
92
        hal_cpu_load_all        # load whole register set
93
        mov     (4,sp),d1       # retrieve saved PSW
94
        hal_cpu_set_psw d1      # and restore it
95
        add     8,sp            # skip saved SP and PSW
96
        ret     [],0            # and return
97
 
98
##-----------------------------------------------------------------------------
99
## HAL longjmp(), setjmp() implementations
100
## These implementations omit the usual movm [d2,d3,a2,a3],(sp)
101
## Which is the first instruction of all C compiled functions.
102
## Note: These definitions are repeated in hal_arch.h. If changes are required
103
## remember to update both sets.
104
 
105
#define CYGARC_JMP_BUF_SP        0
106
#define CYGARC_JMP_BUF_D2        1
107
#define CYGARC_JMP_BUF_D3        2
108
#define CYGARC_JMP_BUF_A2        3
109
#define CYGARC_JMP_BUF_A3        4
110
#define CYGARC_JMP_BUF_LR        5
111
 
112
#define CYGARC_JMP_BUF_SIZE      6
113
 
114
 
115
        # This just preserves the callee save registers
116
        # namely a2,a3,d2,d3
117
        # setjmp cannot use movm to do this as we need to keep
118
        # the sp underneath all live data at all times.
119
        .globl _hal_setjmp
120
_hal_setjmp:                    # d0=env
121
        mov     d0,a0           # env
122
        mov     d2,(CYGARC_JMP_BUF_D2*4,a0)
123
        mov     d3,(CYGARC_JMP_BUF_D3*4,a0)
124
        mov     a2,(CYGARC_JMP_BUF_A2*4,a0)
125
        mov     a3,(CYGARC_JMP_BUF_A3*4,a0)
126
        mov     mdr,d1          # link saved by call (also in (0,sp))
127
        mov     d1,(CYGARC_JMP_BUF_LR*4,a0)
128
        mov     sp,a1
129
        mov     a1,(CYGARC_JMP_BUF_SP*4,a0) # a1==(caller''s sp)
130
        clr     d0              # return 0
131
        ret     [],0
132
 
133
        # longjmp returns to caller of setjmp
134
        # after restoring callee save registers
135
        .globl _hal_longjmp
136
_hal_longjmp:
137
        mov     d0,a0
138
        mov     (CYGARC_JMP_BUF_D2*4,a0),d2
139
        mov     (CYGARC_JMP_BUF_D3*4,a0),d3
140
        mov     (CYGARC_JMP_BUF_A2*4,a0),a2
141
        mov     (CYGARC_JMP_BUF_A3*4,a0),a3
142
        mov     (CYGARC_JMP_BUF_LR*4,a0),d0
143
##      mov     d0,mdr
144
        mov     (CYGARC_JMP_BUF_SP*4,a0),a1 # stashed (caller''s sp)
145
        mov     a1,sp
146
        mov     d0,(0,sp)       # put link on stack
147
        mov     d1,d0           # return arg1
148
        ret     [],0            # this ignores (0,sp) and does pc=mdr
149
 
150
 
151
#------------------------------------------------------------------------------
152
# end of context.S
153
 
154
 

powered by: WebSVN 2.1.0

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