1 |
27 |
unneback |
##=============================================================================
|
2 |
|
|
##
|
3 |
|
|
## context.S
|
4 |
|
|
##
|
5 |
|
|
## H8/300 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): yoshinori sato
|
44 |
|
|
## Contributors: yoshinori sato
|
45 |
|
|
## Date: 2002-02-17
|
46 |
|
|
## Purpose: H8/300 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 |
|
|
#include
|
59 |
|
|
|
60 |
|
|
.h8300h
|
61 |
|
|
|
62 |
|
|
#------------------------------------------------------------------------------
|
63 |
|
|
# hal_thread_switch_context
|
64 |
|
|
# Switch thread contexts
|
65 |
|
|
# D0 = address of sp of next thread to execute
|
66 |
|
|
# D1 = address of sp save location of current thread
|
67 |
|
|
|
68 |
|
|
.global CYG_LABEL_DEFN(hal_thread_switch_context)
|
69 |
|
|
CYG_LABEL_DEFN(hal_thread_switch_context):
|
70 |
|
|
hal_cpu_save_all
|
71 |
|
|
mov.l sp,@er1
|
72 |
|
|
|
73 |
|
|
# Now load the destination thread by dropping through
|
74 |
|
|
# to hal_thread_load_context
|
75 |
|
|
|
76 |
|
|
#------------------------------------------------------------------------------
|
77 |
|
|
# hal_thread_load_context
|
78 |
|
|
# Load thread context
|
79 |
|
|
# D0 = address of sp of next thread to execute
|
80 |
|
|
# Note that this function is also the second half of hal_thread_switch_context
|
81 |
|
|
# and is simply dropped into from it.
|
82 |
|
|
|
83 |
|
|
.global CYG_LABEL_DEFN(hal_thread_load_context)
|
84 |
|
|
CYG_LABEL_DEFN(hal_thread_load_context):
|
85 |
|
|
|
86 |
|
|
mov.l @er0,sp
|
87 |
|
|
hal_cpu_load_all
|
88 |
|
|
rts
|
89 |
|
|
|
90 |
|
|
##-----------------------------------------------------------------------------
|
91 |
|
|
## HAL longjmp(), setjmp() implementations
|
92 |
|
|
## These implementations omit the usual movm [d2,d3,a2,a3],(sp)
|
93 |
|
|
## Which is the first instruction of all C compiled functions.
|
94 |
|
|
## Note: These definitions are repeated in hal_arch.h. If changes are required
|
95 |
|
|
## remember to update both sets.
|
96 |
|
|
|
97 |
|
|
#define CYGARC_JMP_BUF_SP 0
|
98 |
|
|
#define CYGARC_JMP_BUF_ER3 1
|
99 |
|
|
#define CYGARC_JMP_BUF_ER4 2
|
100 |
|
|
#define CYGARC_JMP_BUF_ER5 3
|
101 |
|
|
#define CYGARC_JMP_BUF_ER6 4
|
102 |
|
|
#define CYGARC_JMP_BUF_PC 5
|
103 |
|
|
|
104 |
|
|
#define CYGARC_JMP_BUF_SIZE 6
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
# This just preserves the callee save registers
|
108 |
|
|
# namely a2,a3,d2,d3
|
109 |
|
|
# setjmp cannot use movm to do this as we need to keep
|
110 |
|
|
# the sp underneath all live data at all times.
|
111 |
|
|
.globl CYG_LABEL_DEFN(hal_setjmp)
|
112 |
|
|
CYG_LABEL_DEFN(hal_setjmp): ; er0=env
|
113 |
|
|
mov.l er3,@(CYGARC_JMP_BUF_ER3*4,er0)
|
114 |
|
|
mov.l er4,@(CYGARC_JMP_BUF_ER4*4,er0)
|
115 |
|
|
mov.l er5,@(CYGARC_JMP_BUF_ER5*4,er0)
|
116 |
|
|
mov.l er6,@(CYGARC_JMP_BUF_ER6*4,er0)
|
117 |
|
|
mov.l @sp,er1
|
118 |
|
|
mov.l er1,@(CYGARC_JMP_BUF_PC*4,er0)
|
119 |
|
|
mov sp,er1
|
120 |
|
|
mov er1,@(CYGARC_JMP_BUF_SP*4,er0)
|
121 |
|
|
sub.l er0,er0
|
122 |
|
|
rts
|
123 |
|
|
|
124 |
|
|
# longjmp returns to caller of setjmp
|
125 |
|
|
# after restoring callee save registers
|
126 |
|
|
.globl CYG_LABEL_DEFN(hal_longjmp)
|
127 |
|
|
CYG_LABEL_DEFN(hal_longjmp):
|
128 |
|
|
mov.l @(CYGARC_JMP_BUF_ER3*4,er0),er3
|
129 |
|
|
mov.l @(CYGARC_JMP_BUF_ER4*4,er0),er4
|
130 |
|
|
mov.l @(CYGARC_JMP_BUF_ER5*4,er0),er5
|
131 |
|
|
mov.l @(CYGARC_JMP_BUF_ER6*4,er0),er6
|
132 |
|
|
mov.l @(CYGARC_JMP_BUF_PC*4,er0),er2
|
133 |
|
|
mov.l @(CYGARC_JMP_BUF_SP*4,er0),sp
|
134 |
|
|
mov.l er2,@sp
|
135 |
|
|
mov.l er1,er0
|
136 |
|
|
rts
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
#------------------------------------------------------------------------------
|
140 |
|
|
# end of context.S
|
141 |
|
|
|
142 |
|
|
|