source: trunk/libs/newlib/src/libgloss/sparc_leon/irqtrap_fast.S @ 504

Last change on this file since 504 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25
26#include <asm-leon/leonstack.h>
27#include <asm-leon/asmmacro.h>
28#include <asm-leon/winmacros.h>
29#include <asm-leon/leon.h>
30
31        /* l0: psr
32           l1: pc
33           l2: npc
34           l3: wim
35           l7: irqnr */ 
36         
37        .seg    "text"
38
39        /* ------- */
40        .weak   _leonbare_irq_entry_svt
41        .set    _leonbare_irq_entry_svt,__leonbare_irq_entry_svt
42        .weak   leonbare_irq_entry
43        .set    leonbare_irq_entry,_leonbare_irq_entry
44        /* ------- */
45        !.global leonbare_irq_entry,_leonbare_irq_entry_svt
46        .global _irqtbl, _irqtrap, handler_irq, fpustate_current
47
48#define FASTIRQ_ENABLE 
49/*#define FASTIRQ_DYNAMIC*/     /* depend on FASTIRQ_ENABLE */
50       
51__leonbare_irq_entry_svt:        /* irq from svt trap dispatcher */
52        sub %l6,0x10, %l7
53        rd %wim, %l3
54       
55_leonbare_irq_entry:   
56
57        SAVE_ALL_FAST(.L3)                        ! fast irq processing, volatile %g6, use frame
58       
59.L3:
60#ifdef __threadx__     
61        set     _tx_thread_system_state, %o0
62        ld      [%o0],%o1
63        add     %o1,1,%o1
64        st      %o1,[%o0]
65#endif
66       
67        set     nestcount,%o0
68        ld      [%o0],%o1
69        add     %o1,1,%o1
70        st      %o1,[%o0]
71       
72#ifdef CONFIG_LEONBARE_NONESTEDIRQ     
73        or      %l0, SPARC_PSR_PIL_MASK, %o0       ! no nested irqs
74        wr      %o0, SPARC_PSR_ET_MASK, %psr
75        WRITE_PAUSE
76#else
77        sll     %l7,SPARC_PSR_PIL_SHIFT,%o1
78        andn    %l0,SPARC_PSR_PIL_MASK,%o0
79        or      %o0, %o1, %o1
80        set     nestedirq,%o0
81        ld      [%o0],%o0
82        cmp     %g0,%o0                            ! no nested irqs?
83        beq,a   .L1
84        or      %o1, SPARC_PSR_PIL_MASK, %o1       
85.L1:   
86        wr      %o1, SPARC_PSR_ET_MASK, %psr
87        WRITE_PAUSE
88#endif
89       
90        mov     %l7, %o0                           ! irq level
91        call    handler_irq                        ! void handler_irq (int irq, struct leonbare_pt_regs *pt_regs)
92#ifndef _SOFT_FLOAT
93         add    %sp, FW_REGS_SZ + 8 + SF_REGS_SZ , %o1  ! pt_regs ptr
94#else
95         add    %sp, SF_REGS_SZ , %o1              ! pt_regs ptr
96#endif
97       
98        or      %l0, SPARC_PSR_PIL_MASK, %o1
99        wr      %o1, SPARC_PSR_ET_MASK, %psr       ! enable nesting again, keep ET up
100        WRITE_PAUSE
101
102        set     nestcount,%o0
103        ld      [%o0],%o1
104        sub     %o1,1,%o1
105        st      %o1,[%o0]
106       
107#ifdef __threadx__     
108        set     _tx_thread_system_state, %o0
109        ld      [%o0],%o1
110        sub     %o1,1,%o1
111        st      %o1,[%o0]
112#endif
113       
114        RESTORE_ALL_FAST
115
116        .seg    "data"
117        .global nestedirq
118        .align  4
119nestedirq:
120        .long   0
121        .global fastirq
122        .align  4
123fastirq:
124        .long   0
125        .global nestcount
126        .align  4
127nestcount:
128        .long   0
Note: See TracBrowser for help on using the repository browser.