comparison packages/hal/mn10300/arch/current/src/context.S @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 ##=============================================================================
2 ##
3 ## context.S
4 ##
5 ## MN10300 context switch code
6 ##
7 ##=============================================================================
8 #####COPYRIGHTBEGIN####
9 #
10 # -------------------------------------------
11 # The contents of this file are subject to the Cygnus eCos Public License
12 # Version 1.0 (the "License"); you may not use this file except in
13 # compliance with the License. You may obtain a copy of the License at
14 # http://sourceware.cygnus.com/ecos
15 #
16 # Software distributed under the License is distributed on an "AS IS"
17 # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 # License for the specific language governing rights and limitations under
19 # the License.
20 #
21 # The Original Code is eCos - Embedded Cygnus Operating System, released
22 # September 30, 1998.
23 #
24 # The Initial Developer of the Original Code is Cygnus. Portions created
25 # by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
26 # -------------------------------------------
27 #
28 #####COPYRIGHTEND####
29 ##=============================================================================
30 #######DESCRIPTIONBEGIN####
31 ##
32 ## Author(s): nickg
33 ## Contributors: nickg
34 ## Date: 1998-04-27
35 ## Purpose: MN10300 context switch code
36 ## Description: This file contains implementations of the thread context
37 ## switch routines. It also contains the longjmp() and setjmp()
38 ## routines.
39 ##
40 ######DESCRIPTIONEND####
41 ##
42 ##=============================================================================
43
44 #include <pkgconf/hal.h>
45
46 #------------------------------------------------------------------------------
47 # Configure to use either a minimal or maximal thread state
48
49 #ifdef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
50
51 #define SAVE_REGS [d2,d3,a2,a3,other]
52
53 #else
54
55 #define SAVE_REGS [d2,d3,a2,a3,other]
56
57 #endif
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 movm SAVE_REGS,(sp) # dump all registers onto stack
69 mov psw,d2 # put PSW into saved state
70 mov d2,(52,sp)
71 mov d1,a2 # move save loc addr to A2
72 mov sp,(0,a2) # store SP in save location
73
74 # Now load the destination thread by dropping through
75 # to hal_thread_load_context
76
77 #------------------------------------------------------------------------------
78 # hal_thread_load_context
79 # Load thread context
80 # D0 = address of sp of next thread to execute
81 # Note that this function is also the second half of hal_thread_switch_context
82 # and is simply dropped into from it.
83
84 .global _hal_thread_load_context
85 _hal_thread_load_context:
86
87 mov d0,a2 # move next sp loc to a2
88 mov (0,a2),sp # load SP with new value
89 movm (sp),SAVE_REGS # load all registers
90 add 8,sp # skip SP & PSW, we never restore them.
91 ret [],0
92
93 ##-----------------------------------------------------------------------------
94 ## HAL longjmp(), setjmp() implementations
95 ## These implementations omit the usual movm [d2,d3,a2,a3],(sp)
96 ## Which is the first instruction of all C compiled functions.
97
98 # This just preserves the callee save registers
99 # namely a2,a3,d2,d3
100 # setjmp cannot use movm to do this as we need to keep
101 # the sp underneath all live data at all times.
102 .globl _hal_setjmp
103 _hal_setjmp: # d0=env
104 mov d0,a0 # env
105 mov d2,(4,a0)
106 mov d3,(8,a0)
107 mov a2,(12,a0)
108 mov a3,(16,a0)
109 mov mdr,d1 # link saved by call (also in (0,sp))
110 mov d1,(20,a0)
111 mov sp,a1
112 mov a1,(0,a0) # a1==(caller''s sp)
113 clr d0 # return 0
114 ret [],0
115
116 # longjmp returns to caller of setjmp
117 # after restoring callee save registers
118 .globl _hal_longjmp
119 _hal_longjmp:
120 mov d0,a0
121 mov (4,a0),d2
122 mov (8,a0),d3
123 mov (12,a0),a2
124 mov (16,a0),a3
125 mov (20,a0),d0
126 ## mov d0,mdr
127 mov (0,a0),a1 # stashed (caller''s sp)
128 mov a1,sp
129 mov d0,(0,sp) # put link on stack
130 mov d1,d0 # return arg1
131 ret [],0 # this ignores (0,sp) and does pc=mdr
132
133
134 #------------------------------------------------------------------------------
135 # end of context.S
136
137