OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [calmrisc32/] [arch/] [v2_0/] [src/] [context.S] - Blame information for rev 232

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
##=============================================================================##
2
##      context.S
3
##
4
##      CalmRISC32 context switch code
5
##
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.
11
##
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.
15
##
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
19
## for more details.
20
##
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.
24
##
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.
31
##
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.
34
##
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####
41
##
42
## Author(s):   msalter
43
## Contributors: msalter
44
## Date:        2001-02-12
45
## Purpose:     CalmRISC32 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 
55
#include 
56
 
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
62
 
63
        .global hal_thread_switch_context
64
hal_thread_switch_context:
65
        // FIXME
66
        # Now load the destination thread by dropping through
67
        # to hal_thread_load_context
68
 
69
#------------------------------------------------------------------------------
70
# hal_thread_load_context
71
# Load thread 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.
75
 
76
        .global hal_thread_load_context
77
hal_thread_load_context:
78
        // FIXME
79
 
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.
85
 
86
#define CYGARC_JMP_BUF_R0        0
87
#define CYGARC_JMP_BUF_R1        1
88
#define CYGARC_JMP_BUF_R2        2
89
#define CYGARC_JMP_BUF_R3        3
90
#define CYGARC_JMP_BUF_R4        4
91
#define CYGARC_JMP_BUF_R5        5
92
#define CYGARC_JMP_BUF_R6        6
93
#define CYGARC_JMP_BUF_R7        7
94
#define CYGARC_JMP_BUF_R12       8
95
#define CYGARC_JMP_BUF_R13       9
96
#define CYGARC_JMP_BUF_R14      10
97
#define CYGARC_JMP_BUF_R15      11
98
 
99
#define CYGARC_JMP_BUF_SIZE     48
100
 
101
// FIXME: The follwing restricts us to using only 32 bit registers
102
// in jump buffers. If/when we move to a full 64 bit architecture,
103
// this will need to change, as will the instructions that we use to
104
// save and restore them.
105
 
106
#define jmpbuf_regsize 4
107
 
108
        .globl  hal_setjmp
109
hal_setjmp:
110
        ld      r8, r0
111
        ldw     @[r8+0], r0
112
        ldw     @[r8+4], r1
113
        ldw     @[r8+8], r2
114
        ldw     @[r8+12], r3
115
        ldw     @[r8+16], r4
116
        ldw     @[r8+20], r5
117
        ldw     @[r8+24], r6
118
        ldw     @[r8+28], r7
119
        ldw     @[r8+32], r12
120
        ldw     @[r8+36], r13
121
        ldw     @[r8+40], r14
122
        ldw     @[r8+44], sp
123
 
124
        jmpd    r14
125
         ldw    r0, #0
126
 
127
        .globl  hal_longjmp
128
hal_longjmp:
129
        ld      r9, r0
130
        ld      r8, r1
131
        ldw     sp, @[r9+44]
132
        ldw     r14, @[r9+40]
133
        ldw     r13, @[r9+36]
134
        ldw     r12, @[r9+32]
135
        ldw     r7, @[r9+28]
136
        ldw     r6, @[r9+24]
137
        ldw     r5, @[r9+20]
138
        ldw     r4, @[r9+16]
139
        ldw     r3, @[r9+12]
140
        ldw     r2, @[r9+8]
141
        ldw     r1, @[r9+4]
142
        # Value to return is in r8.  If zero, return 1
143
        ld      r0, r8
144
        cmp eq  r0, #0
145
        brf     0f
146
        ldw     r0, #1
147
    0:
148
        jmpd    r14
149
         nop
150
 
151
 
152
#------------------------------------------------------------------------------
153
# end of context.S

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.