Mercurial > ecos
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 |
| rev | line source |
|---|---|
| 0 | 1 ##============================================================================= |
| 2 ## | |
| 3 ## context.S | |
| 4 ## | |
| 5 ## MN10300 context switch code | |
| 6 ## | |
| 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 | 39 ##============================================================================= |
| 40 #######DESCRIPTIONBEGIN#### | |
| 41 ## | |
| 42 ## Author(s): nickg | |
| 43 ## Contributors: nickg | |
| 44 ## Date: 1998-04-27 | |
| 45 ## Purpose: MN10300 context switch code | |
| 46 ## Description: This file contains implementations of the thread context | |
| 47 ## switch routines. It also contains the longjmp() and setjmp() | |
| 48 ## routines. | |
| 49 ## | |
| 50 ######DESCRIPTIONEND#### | |
| 51 ## | |
| 52 ##============================================================================= | |
| 53 | |
| 54 #include <pkgconf/hal.h> | |
| 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 | 57 |
| 58 #------------------------------------------------------------------------------ | |
| 59 # hal_thread_switch_context | |
| 60 # Switch thread contexts | |
| 61 # D0 = address of sp of next thread to execute | |
| 62 # D1 = address of sp save location of current thread | |
| 63 | |
| 64 .global _hal_thread_switch_context | |
| 65 _hal_thread_switch_context: | |
| 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 | 73 mov d1,a2 # move save loc addr to A2 |
| 74 mov sp,(0,a2) # store SP in save location | |
| 75 | |
| 76 # Now load the destination thread by dropping through | |
| 77 # to hal_thread_load_context | |
| 78 | |
| 79 #------------------------------------------------------------------------------ | |
| 80 # hal_thread_load_context | |
| 81 # Load thread context | |
| 82 # D0 = address of sp of next thread to execute | |
| 83 # Note that this function is also the second half of hal_thread_switch_context | |
| 84 # and is simply dropped into from it. | |
| 85 | |
| 86 .global _hal_thread_load_context | |
| 87 _hal_thread_load_context: | |
| 88 | |
| 89 mov d0,a2 # move next sp loc to a2 | |
| 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 | 96 |
| 97 ##----------------------------------------------------------------------------- | |
| 98 ## HAL longjmp(), setjmp() implementations | |
| 99 ## These implementations omit the usual movm [d2,d3,a2,a3],(sp) | |
| 100 ## Which is the first instruction of all C compiled functions. | |
| 2 | 101 ## Note: These definitions are repeated in hal_arch.h. If changes are required |
| 102 ## remember to update both sets. | |
| 0 | 103 |
| 2 | 104 #define CYGARC_JMP_BUF_SP 0 |
| 105 #define CYGARC_JMP_BUF_D2 1 | |
| 106 #define CYGARC_JMP_BUF_D3 2 | |
| 107 #define CYGARC_JMP_BUF_A2 3 | |
| 108 #define CYGARC_JMP_BUF_A3 4 | |
| 109 #define CYGARC_JMP_BUF_LR 5 | |
| 110 | |
| 111 #define CYGARC_JMP_BUF_SIZE 6 | |
| 112 | |
| 113 | |
| 0 | 114 # This just preserves the callee save registers |
| 115 # namely a2,a3,d2,d3 | |
| 116 # setjmp cannot use movm to do this as we need to keep | |
| 117 # the sp underneath all live data at all times. | |
| 118 .globl _hal_setjmp | |
| 119 _hal_setjmp: # d0=env | |
| 120 mov d0,a0 # env | |
| 2 | 121 mov d2,(CYGARC_JMP_BUF_D2*4,a0) |
| 122 mov d3,(CYGARC_JMP_BUF_D3*4,a0) | |
| 123 mov a2,(CYGARC_JMP_BUF_A2*4,a0) | |
| 124 mov a3,(CYGARC_JMP_BUF_A3*4,a0) | |
| 0 | 125 mov mdr,d1 # link saved by call (also in (0,sp)) |
| 2 | 126 mov d1,(CYGARC_JMP_BUF_LR*4,a0) |
| 0 | 127 mov sp,a1 |
| 2 | 128 mov a1,(CYGARC_JMP_BUF_SP*4,a0) # a1==(caller''s sp) |
| 0 | 129 clr d0 # return 0 |
| 130 ret [],0 | |
| 131 | |
| 132 # longjmp returns to caller of setjmp | |
| 133 # after restoring callee save registers | |
| 134 .globl _hal_longjmp | |
| 135 _hal_longjmp: | |
| 136 mov d0,a0 | |
| 2 | 137 mov (CYGARC_JMP_BUF_D2*4,a0),d2 |
| 138 mov (CYGARC_JMP_BUF_D3*4,a0),d3 | |
| 139 mov (CYGARC_JMP_BUF_A2*4,a0),a2 | |
| 140 mov (CYGARC_JMP_BUF_A3*4,a0),a3 | |
| 141 mov (CYGARC_JMP_BUF_LR*4,a0),d0 | |
| 0 | 142 ## mov d0,mdr |
| 2 | 143 mov (CYGARC_JMP_BUF_SP*4,a0),a1 # stashed (caller''s sp) |
| 0 | 144 mov a1,sp |
| 145 mov d0,(0,sp) # put link on stack | |
| 146 mov d1,d0 # return arg1 | |
| 147 ret [],0 # this ignores (0,sp) and does pc=mdr | |
| 148 | |
| 149 | |
| 150 #------------------------------------------------------------------------------ | |
| 151 # end of context.S | |
| 152 | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
153 |
