1 ##=============================================================================
5 ## H8/300 context switch code
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.
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.
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
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.
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.
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.
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####
43 ## Author(s): yoshinori sato
44 ## Contributors: yoshinori sato
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()
51 ######DESCRIPTIONEND####
53 ##=============================================================================
55 #include <pkgconf/hal.h>
57 #include <cyg/hal/arch.inc>
58 #include <cyg/hal/basetype.h>
61 #ifdef CYGPKG_HAL_H8300_H8300H
64 #ifdef CYGPKG_HAL_H8300_H8S
68 #------------------------------------------------------------------------------
69 # hal_thread_switch_context
70 # Switch thread contexts
71 # er0 = address of sp of next thread to execute
72 # er1 = address of sp save location of current thread
74 .global CYG_LABEL_DEFN(hal_thread_switch_context)
75 CYG_LABEL_DEFN(hal_thread_switch_context):
76 mov.w @sp,r2 ; save ccr
82 # Now load the destination thread by dropping through
83 # to hal_thread_load_context
85 #------------------------------------------------------------------------------
86 # hal_thread_load_context
88 # D0 = address of sp of next thread to execute
89 # Note that this function is also the second half of hal_thread_switch_context
90 # and is simply dropped into from it.
92 .global CYG_LABEL_DEFN(hal_thread_load_context)
93 CYG_LABEL_DEFN(hal_thread_load_context):
99 ##-----------------------------------------------------------------------------
100 ## HAL longjmp(), setjmp() implementations
101 ## These implementations omit the usual movm [d2,d3,a2,a3],(sp)
102 ## Which is the first instruction of all C compiled functions.
103 ## Note: These definitions are repeated in hal_arch.h. If changes are required
104 ## remember to update both sets.
106 #define CYGARC_JMP_BUF_SP 0
107 #define CYGARC_JMP_BUF_ER3 1
108 #define CYGARC_JMP_BUF_ER4 2
109 #define CYGARC_JMP_BUF_ER5 3
110 #define CYGARC_JMP_BUF_ER6 4
111 #define CYGARC_JMP_BUF_PC 5
113 #define CYGARC_JMP_BUF_SIZE 6
116 # This just preserves the callee save registers
118 # setjmp cannot use movm to do this as we need to keep
119 # the sp underneath all live data at all times.
120 .globl CYG_LABEL_DEFN(hal_setjmp)
121 CYG_LABEL_DEFN(hal_setjmp): ; er0=env
122 mov.l er3,@(CYGARC_JMP_BUF_ER3*4,er0)
123 mov.l er4,@(CYGARC_JMP_BUF_ER4*4,er0)
124 mov.l er5,@(CYGARC_JMP_BUF_ER5*4,er0)
125 mov.l er6,@(CYGARC_JMP_BUF_ER6*4,er0)
127 mov.l er1,@(CYGARC_JMP_BUF_PC*4,er0)
129 mov er1,@(CYGARC_JMP_BUF_SP*4,er0)
133 # longjmp returns to caller of setjmp
134 # after restoring callee save registers
135 .globl CYG_LABEL_DEFN(hal_longjmp)
136 CYG_LABEL_DEFN(hal_longjmp):
137 mov.l @(CYGARC_JMP_BUF_ER3*4,er0),er3
138 mov.l @(CYGARC_JMP_BUF_ER4*4,er0),er4
139 mov.l @(CYGARC_JMP_BUF_ER5*4,er0),er5
140 mov.l @(CYGARC_JMP_BUF_ER6*4,er0),er6
141 mov.l @(CYGARC_JMP_BUF_PC*4,er0),er2
142 mov.l @(CYGARC_JMP_BUF_SP*4,er0),sp
148 #------------------------------------------------------------------------------