1 ##=============================================================================##
4 ## CalmRISC16 context switch code
6 ##=============================================================================
7 #####ECOSGPLCOPYRIGHTBEGIN####
8 ## -------------------------------------------
9 ## This file is part of eCos, the Embedded Configurable Operating System.
10 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 ## eCos is free software; you can redistribute it and/or modify it under
13 ## the terms of the GNU General Public License as published by the Free
14 ## Software Foundation; either version 2 or (at your option) any later version.
16 ## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
17 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 ## You should have received a copy of the GNU General Public License along
22 ## with eCos; if not, write to the Free Software Foundation, Inc.,
23 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 ## As a special exception, if other files instantiate templates or use macros
26 ## or inline functions from this file, or you compile this file and link it
27 ## with other works to produce a work based on this file, this file does not
28 ## by itself cause the resulting work to be covered by the GNU General Public
29 ## License. However the source code for this file must still be made available
30 ## in accordance with section (3) of the GNU General Public License.
32 ## This exception does not invalidate any other reasons why a work based on
33 ## this file might be covered by the GNU General Public License.
35 ## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
36 ## at http://sources.redhat.com/ecos/ecos-license/
37 ## -------------------------------------------
38 #####ECOSGPLCOPYRIGHTEND####
39 ##=============================================================================
40 #######DESCRIPTIONBEGIN####
43 ## Contributors: msalter
45 ## Purpose: CalmRISC16 context switch code
46 ## Description: This file contains implementations of the thread context
47 ## switch routines. It also contains the longjmp() and setjmp()
50 ######DESCRIPTIONEND####
52 ##=============================================================================
54 #include <pkgconf/hal.h>
55 #include <cyg/hal/arch.inc>
57 #------------------------------------------------------------------------------
58 # hal_thread_switch_context
59 # Switch thread contexts
60 # A0 = address of sp of next thread to execute
61 # A1 = address of sp save location of current thread
63 .global hal_thread_switch_context
64 hal_thread_switch_context:
66 # Now load the destination thread by dropping through
67 # to hal_thread_load_context
69 #------------------------------------------------------------------------------
70 # hal_thread_load_context
72 # A0 = address of sp of next thread to execute
73 # Note that this function is also the second half of hal_thread_switch_context
74 # and is simply dropped into from it.
76 .global hal_thread_load_context
77 hal_thread_load_context:
80 #------------------------------------------------------------------------------
81 # HAL longjmp, setjmp implementations
82 # hal_setjmp saves only callee save registers into given buffer
83 # Note: These definitions are repeated in hal_arch.h. If changes are required
84 # remember to update both sets.
86 #define CYGARC_JMP_BUF_R4 0
87 #define CYGARC_JMP_BUF_R5 2
88 #define CYGARC_JMP_BUF_A12 4
89 #define CYGARC_JMP_BUF_A13 8
90 #define CYGARC_JMP_BUF_A14 12
91 #define CYGARC_JMP_BUF_A15 16
93 #define CYGARC_JMP_BUF_SIZE 20
95 // FIXME: The follwing restricts us to using only 32 bit registers
96 // in jump buffers. If/when we move to a full 64 bit architecture,
97 // this will need to change, as will the instructions that we use to
98 // save and restore them.
100 #define jmpbuf_regsize 4
104 ldw a8,@[sp+2] // jmpbuf
131 #------------------------------------------------------------------------------