Mercurial > ecos
annotate packages/hal/mn10300/arch/current/src/context.S @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | e0c0827131d1 |
| rev | line source |
|---|---|
| 0 | 1 ##============================================================================= |
| 2 ## | |
| 3 ## context.S | |
| 4 ## | |
| 5 ## MN10300 context switch code | |
| 6 ## | |
| 7 ##============================================================================= | |
| 8 #####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
9 # |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
10 # ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
11 # The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 # Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
13 # compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 # http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
15 # |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 # Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
17 # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
18 # License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
19 # the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
20 # |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
21 # The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
22 # released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
23 # |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
24 # The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
25 # Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
26 # Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
27 # All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
28 # ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
29 # |
| 0 | 30 #####COPYRIGHTEND#### |
| 31 ##============================================================================= | |
| 32 #######DESCRIPTIONBEGIN#### | |
| 33 ## | |
| 34 ## Author(s): nickg | |
| 35 ## Contributors: nickg | |
| 36 ## Date: 1998-04-27 | |
| 37 ## Purpose: MN10300 context switch code | |
| 38 ## Description: This file contains implementations of the thread context | |
| 39 ## switch routines. It also contains the longjmp() and setjmp() | |
| 40 ## routines. | |
| 41 ## | |
| 42 ######DESCRIPTIONEND#### | |
| 43 ## | |
| 44 ##============================================================================= | |
| 45 | |
| 46 #include <pkgconf/hal.h> | |
| 47 | |
|
30
641b639be825
Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents:
2
diff
changeset
|
48 #include <cyg/hal/arch.inc> |
| 0 | 49 |
| 50 #------------------------------------------------------------------------------ | |
| 51 # hal_thread_switch_context | |
| 52 # Switch thread contexts | |
| 53 # D0 = address of sp of next thread to execute | |
| 54 # D1 = address of sp save location of current thread | |
| 55 | |
| 56 .global _hal_thread_switch_context | |
| 57 _hal_thread_switch_context: | |
| 58 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
|
59 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
|
60 # saved to a data register |
|
641b639be825
Merge from eCos master repository on 1999-08-16-22:01:37-BST
jlarmour
parents:
2
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 hal_cpu_save_all # save entire register set |
| 0 | 65 mov d1,a2 # move save loc addr to A2 |
| 66 mov sp,(0,a2) # store SP in save location | |
| 67 | |
| 68 # Now load the destination thread by dropping through | |
| 69 # to hal_thread_load_context | |
| 70 | |
| 71 #------------------------------------------------------------------------------ | |
| 72 # hal_thread_load_context | |
| 73 # Load thread context | |
| 74 # D0 = address of sp of next thread to execute | |
| 75 # Note that this function is also the second half of hal_thread_switch_context | |
| 76 # and is simply dropped into from it. | |
| 77 | |
| 78 .global _hal_thread_load_context | |
| 79 _hal_thread_load_context: | |
| 80 | |
| 81 mov d0,a2 # move next sp loc to a2 | |
| 82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 ret [],0 # and return |
| 0 | 88 |
| 89 ##----------------------------------------------------------------------------- | |
| 90 ## HAL longjmp(), setjmp() implementations | |
| 91 ## These implementations omit the usual movm [d2,d3,a2,a3],(sp) | |
| 92 ## Which is the first instruction of all C compiled functions. | |
| 2 | 93 ## Note: These definitions are repeated in hal_arch.h. If changes are required |
| 94 ## remember to update both sets. | |
| 0 | 95 |
| 2 | 96 #define CYGARC_JMP_BUF_SP 0 |
| 97 #define CYGARC_JMP_BUF_D2 1 | |
| 98 #define CYGARC_JMP_BUF_D3 2 | |
| 99 #define CYGARC_JMP_BUF_A2 3 | |
| 100 #define CYGARC_JMP_BUF_A3 4 | |
| 101 #define CYGARC_JMP_BUF_LR 5 | |
| 102 | |
| 103 #define CYGARC_JMP_BUF_SIZE 6 | |
| 104 | |
| 105 | |
| 0 | 106 # This just preserves the callee save registers |
| 107 # namely a2,a3,d2,d3 | |
| 108 # setjmp cannot use movm to do this as we need to keep | |
| 109 # the sp underneath all live data at all times. | |
| 110 .globl _hal_setjmp | |
| 111 _hal_setjmp: # d0=env | |
| 112 mov d0,a0 # env | |
| 2 | 113 mov d2,(CYGARC_JMP_BUF_D2*4,a0) |
| 114 mov d3,(CYGARC_JMP_BUF_D3*4,a0) | |
| 115 mov a2,(CYGARC_JMP_BUF_A2*4,a0) | |
| 116 mov a3,(CYGARC_JMP_BUF_A3*4,a0) | |
| 0 | 117 mov mdr,d1 # link saved by call (also in (0,sp)) |
| 2 | 118 mov d1,(CYGARC_JMP_BUF_LR*4,a0) |
| 0 | 119 mov sp,a1 |
| 2 | 120 mov a1,(CYGARC_JMP_BUF_SP*4,a0) # a1==(caller''s sp) |
| 0 | 121 clr d0 # return 0 |
| 122 ret [],0 | |
| 123 | |
| 124 # longjmp returns to caller of setjmp | |
| 125 # after restoring callee save registers | |
| 126 .globl _hal_longjmp | |
| 127 _hal_longjmp: | |
| 128 mov d0,a0 | |
| 2 | 129 mov (CYGARC_JMP_BUF_D2*4,a0),d2 |
| 130 mov (CYGARC_JMP_BUF_D3*4,a0),d3 | |
| 131 mov (CYGARC_JMP_BUF_A2*4,a0),a2 | |
| 132 mov (CYGARC_JMP_BUF_A3*4,a0),a3 | |
| 133 mov (CYGARC_JMP_BUF_LR*4,a0),d0 | |
| 0 | 134 ## mov d0,mdr |
| 2 | 135 mov (CYGARC_JMP_BUF_SP*4,a0),a1 # stashed (caller''s sp) |
| 0 | 136 mov a1,sp |
| 137 mov d0,(0,sp) # put link on stack | |
| 138 mov d1,d0 # return arg1 | |
| 139 ret [],0 # this ignores (0,sp) and does pc=mdr | |
| 140 | |
| 141 | |
| 142 #------------------------------------------------------------------------------ | |
| 143 # end of context.S | |
| 144 | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
30
diff
changeset
|
145 |
