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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparclite/] [sleb/] [current/] [src/] [hal_cygm.S] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*=============================================================================
2
//
3
//      hal_cygm.S
4
//
5
//      SPARClite and CygMon play nice: vector service routines
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 Free Software Foundation, 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
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//=============================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   hmt
43
// Contributors:hmt
44
// Date:        1998-02-24
45
// Purpose:     SPARClite vectors for interworking with CygMon
46
// Description: see vectors.S and hal_priv.c; these VSRs are installed to
47
//              interwork with CygMon.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//===========================================================================*/
52
 
53
!-----------------------------------------------------------------------------
54
 
55
//      .file   "hal_cygm.S"
56
 
57
!-----------------------------------------------------------------------------
58
 
59
#include 
60
#include 
61
#include 
62
#include 
63
 
64
!------------------------------------------------------------------------
65
 
66
#include        // eCos vector number et al
67
#include        // CygMon vector number et al
68
 
69
#define DELAYS_AFTER_WRPSR_SAME_WINDOW
70
#define DELAYS_AFTER_WRWIM
71
 
72
!------------------------------------------------------------------------
73
 
74
        .text
75
 
76
!---------------------------------------------------------------------------
77
 
78
#ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON
79
 
80
        .global hal_user_trap_to_cygmon_vsr
81
hal_user_trap_to_cygmon_vsr:
82
        ! here,locals have been set up as follows:
83
        ! %l0 = psr (with this CWP/window-level in it)
84
        ! %l1 = pc
85
        ! %l2 = npc
86
        ! %l3 = vector number (1-15 for interrupts)
87
        ! and we are in our own register window, though it is likely that
88
        ! the next one will need to be saved before we can use it:
89
        ! ie. this one is the invalid register window.
90
 
91
        rd      %tbr, %l4               ! Get the trap type
92
        srl     %l4, 4, %l4             ! into the bottom byte
93
        and     %l4, 0xff, %l4          ! actual trap number
94
 
95
        ! we deal with traps 1,3,8(+128) and 255 here.
96
        ! ta 1  => tt 129       :       breakpoint
97
        ! ta 3  => tt 131       :       flush windows (unneccessary, JIC)
98
        ! ta 8  => tt 136       :       syscall (apparently)
99
        ! ta 127 -OR- Debug Support Unit trap
100
        !       => tt 255       :       debug trap
101
        ! others bounce through to eCos handler, of course.
102
 
103
        cmp     %l4, 129
104
        beq     bounce_to_cygmon
105
        mov     BSP_EXC_BREAK, %l5
106
 
107
        ! ta 2 is a "skipped" breakpoint, we increment the PC, NPC
108
        ! ourselves to permit continuation.
109
        cmp     %l4, 130
110
        bne     1f
111
        nop
112
        mov     %l2, %l1
113
        add     %l2, 4, %l2
114
        b       bounce_to_cygmon
115
        mov     BSP_EXC_BREAK, %l5
116
 
117
1:
118
        cmp     %l4, 131
119
        beq     bounce_to_cygmon
120
        mov     BSP_EXC_WINFLUSH, %l5
121
 
122
        cmp     %l4, 136
123
        beq     bounce_to_cygmon
124
        mov     BSP_EXC_SYSCALL, %l5
125
 
126
        cmp     %l4, 255
127
        beq     bounce_to_cygmon
128
        mov     BSP_EXC_DEBUG, %l5
129
 
130
        ! if we are here, it~s not a recognized trap to feed to CygMon, so
131
        ! call the eCos default trap VSR:
132
        .extern hal_default_exception_vsr
133
        ba      hal_default_exception_vsr       ! should be in range
134
        nop                                     ! does not return
135
 
136
 
137
        .global hal_nofpcp_trap_to_cygmon_vsr
138
hal_nofpcp_trap_to_cygmon_vsr:
139
        rd      %tbr, %l4               ! Get the trap type
140
        srl     %l4, 4, %l4             ! into the bottom byte
141
        and     %l4, 0xff, %l4          ! actual trap number
142
        ! we deal with trap types 4 and 36 here.
143
 
144
        cmp     %l4, 4
145
        beq     bounce_to_cygmon
146
        mov     BSP_EXC_FPDIS, %l5
147
 
148
        cmp     %l4, 36
149
        beq     bounce_to_cygmon
150
        mov     BSP_EXC_CPDIS, %l5
151
 
152
        ! we really should not be here otherwise, but for best debugging...
153
        b       bounce_to_cygmon
154
        mov     BSP_EXC_TRAP, %l5
155
 
156
bounce_to_cygmon:
157
        ! here we have decided to jump over CygMon, the CygMon vector
158
        ! number to use is in %l5.
159
        set     CYGMON_VECTOR_TABLE_BASE, %l6
160
        sll     %l5, 2, %l5             ! to a word offset
161
        ! our calling convention is the same, so...
162
        ld      [ %l6 + %l5 ], %l6
163
        jmp     %l6
164
        nop
165
 
166
 
167
// Now a handler for INT15 (NMI) to assist in debugging; we have to ack and
168
// clear the interrupt, after waiting for the source to go away, I guess...
169
        .global hal_nmi_handler
170
hal_nmi_handler:
171
        ! here,locals have been set up as follows:
172
        ! %l0 = psr (with this CWP/window-level in it)
173
        ! %l1 = pc
174
        ! %l2 = npc
175
        ! %l3 = vector number (1-15 for interrupts)
176
        ! and we are in our own register window, though it is likely that
177
        ! the next one will need to be saved before we can use it:
178
        ! ie. this one is the invalid register window.
179
 
180
#define TRGM0   0
181
#define TRGM1   4
182
#define REQSNS  8
183
#define REQCLR 12
184
#define IMASK  16
185
#define IRLAT  20
186
#define IMODE  24
187
 
188
#define NMIBIT 0x80000000
189
 
190
        sethi   %hi( 0x10000000 ), %l4  ! base address of the 86940 companion
191
 
192
10:
193
        add     %l4, REQCLR, %l5        ! Request clear register
194
        set     NMIBIT, %l6
195
        sta     %l6, [ %l5 ] 4          ! Clear INT15
196
 
197
        add     %l4, REQSNS, %l5        ! Request sense register
198
        lda     [ %l5 ] 4, %l7
199
        andcc   %l6, %l7, %g0           ! test the sense bit
200
 
201
        sethi   %hi( 0x02000000 ), %l6  ! Pump it out to the LED
202
        srl     %l7, 24, %l7
203
        stb     %l7, [ %l6 + 3 ]
204
 
205
        bne     10b                     ! poll until the request is gone
206
        nop
207
        nop
208
        nop
209
 
210
        set     0x00100000, %l6         ! clear the latch
211
        add     %l4, IRLAT, %l5
212
        sta     %l6, [ %l5 ] 4
213
 
214
        nop
215
        nop
216
        nop
217
 
218
        b       bounce_to_cygmon
219
        mov     BSP_EXC_INT15, %l5
220
 
221
 
222
 
223
 
224
 
225
#endif // CYG_HAL_USE_ROM_MONITOR_CYGMON
226
 
227
! end of hal_cygm.S

powered by: WebSVN 2.1.0

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