annotate packages/hal/mn10300/arch/current/src/context.S @ 3292:7f8e529b4d82 default tip

Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
author vae
date Wed, 29 Apr 2015 23:31:48 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 ##=============================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3 ## context.S
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 ## MN10300 context switch code
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 ##=============================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
8 ## ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
9 ## -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
10 ## This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
11 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
12 ##
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
13 ## eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
14 ## the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
15 ## Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
16 ## version.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
17 ##
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
18 ## eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
19 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
20 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
21 ## for more details.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
22 ##
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
23 ## You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
24 ## along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
25 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
26 ##
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
27 ## As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
28 ## macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
29 ## and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
30 ## this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
31 ## the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
32 ## must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
33 ## General Public License v2.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
34 ##
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
35 ## This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
36 ## on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
37 ## -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
38 ## ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 ##=============================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 #######DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 ## Author(s): nickg
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 ## Contributors: nickg
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44 ## Date: 1998-04-27
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
45 ## Purpose: MN10300 context switch code
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
46 ## Description: This file contains implementations of the thread context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
47 ## switch routines. It also contains the longjmp() and setjmp()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 ## routines.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 ######DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 ##
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 ##=============================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54 #include <pkgconf/hal.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55
30
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
56 #include <cyg/hal/arch.inc>
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #------------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 # hal_thread_switch_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60 # Switch thread contexts
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61 # D0 = address of sp of next thread to execute
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 # D1 = address of sp save location of current thread
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 .global _hal_thread_switch_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 _hal_thread_switch_context:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 add -8,sp # space for SP and PSW
30
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
67 mov d2,a0 # move d2->a0 since PSW can only be
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
68 # saved to a data register
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
69 hal_cpu_get_psw d2 # save PSW to d2
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
70 mov d2,(4,sp) # store in stack loc
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
71 mov a0,d2 # retrieve old d2 value
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
72 hal_cpu_save_all # save entire register set
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 mov d1,a2 # move save loc addr to A2
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74 mov sp,(0,a2) # store SP in save location
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 # Now load the destination thread by dropping through
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 # to hal_thread_load_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 #------------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 # hal_thread_load_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 # Load thread context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 # D0 = address of sp of next thread to execute
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 # Note that this function is also the second half of hal_thread_switch_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 # and is simply dropped into from it.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 .global _hal_thread_load_context
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87 _hal_thread_load_context:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 mov d0,a2 # move next sp loc to a2
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 mov (0,a2),sp # load SP with new value
30
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
91 hal_cpu_load_all # load whole register set
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
92 mov (4,sp),d1 # retrieve saved PSW
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
93 hal_cpu_set_psw d1 # and restore it
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
94 add 8,sp # skip saved SP and PSW
641b639be825 Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents: 2
diff changeset
95 ret [],0 # and return
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 ##-----------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 ## HAL longjmp(), setjmp() implementations
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 ## These implementations omit the usual movm [d2,d3,a2,a3],(sp)
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 ## Which is the first instruction of all C compiled functions.
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
101 ## Note: These definitions are repeated in hal_arch.h. If changes are required
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
102 ## remember to update both sets.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
104 #define CYGARC_JMP_BUF_SP 0
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
105 #define CYGARC_JMP_BUF_D2 1
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
106 #define CYGARC_JMP_BUF_D3 2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
107 #define CYGARC_JMP_BUF_A2 3
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
108 #define CYGARC_JMP_BUF_A3 4
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
109 #define CYGARC_JMP_BUF_LR 5
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
110
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
111 #define CYGARC_JMP_BUF_SIZE 6
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
112
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
113
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 # This just preserves the callee save registers
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 # namely a2,a3,d2,d3
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 # setjmp cannot use movm to do this as we need to keep
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117 # the sp underneath all live data at all times.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 .globl _hal_setjmp
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 _hal_setjmp: # d0=env
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 mov d0,a0 # env
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
121 mov d2,(CYGARC_JMP_BUF_D2*4,a0)
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
122 mov d3,(CYGARC_JMP_BUF_D3*4,a0)
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
123 mov a2,(CYGARC_JMP_BUF_A2*4,a0)
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
124 mov a3,(CYGARC_JMP_BUF_A3*4,a0)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 mov mdr,d1 # link saved by call (also in (0,sp))
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
126 mov d1,(CYGARC_JMP_BUF_LR*4,a0)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 mov sp,a1
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
128 mov a1,(CYGARC_JMP_BUF_SP*4,a0) # a1==(caller''s sp)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129 clr d0 # return 0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 ret [],0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 # longjmp returns to caller of setjmp
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 # after restoring callee save registers
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 .globl _hal_longjmp
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 _hal_longjmp:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136 mov d0,a0
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
137 mov (CYGARC_JMP_BUF_D2*4,a0),d2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
138 mov (CYGARC_JMP_BUF_D3*4,a0),d3
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
139 mov (CYGARC_JMP_BUF_A2*4,a0),a2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
140 mov (CYGARC_JMP_BUF_A3*4,a0),a3
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
141 mov (CYGARC_JMP_BUF_LR*4,a0),d0
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 ## mov d0,mdr
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
143 mov (CYGARC_JMP_BUF_SP*4,a0),a1 # stashed (caller''s sp)
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 mov a1,sp
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 mov d0,(0,sp) # put link on stack
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 mov d1,d0 # return arg1
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 ret [],0 # this ignores (0,sp) and does pc=mdr
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 #------------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 # end of context.S
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 30
diff changeset
153