Welcome to mirror list, hosted at ThFree Co, Russian Federation.

etrap_fast.S « sparc_leon « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6cab927296d18fd5bf36c3fe260de2e87a341aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Copyright (c) 2011 Aeroflex Gaisler
 *
 * BSD license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

        
#include <asm-leon/leonstack.h>
#include <asm-leon/winmacros.h>
        
/* Registers to not touch at all. */
#define t_psr        l0 /* Set by caller */
#define t_pc         l1 /* Set by caller */
#define t_npc        l2 /* Set by caller */
#define t_wim        l3 /* Set by caller */
#define t_twinmask   l4 /* Set at beginning of this entry routine. */
#define t_kstack     l5 /* Set right before pt_regs frame is built */
#define t_retpc      l6 /* If you change this, change winmacro.h header file */
#define t_systable   l7 /* Never touch this, could be the syscall table ptr. */
#define curptr       g6 /* Set after pt_regs frame is built */

	/* Number of register windows */
	.global _nwindows_min1, _nwindows

        .text
	.align 4
	.globl	leonbare_trapsetup_fast

/* etap entry special for irqtrap.S */
leonbare_trapsetup_fast:

#ifdef 	_FLAT
	restore
	RW_STORE(sp)
	save
#endif

#ifndef _SOFT_FLOAT
	/* build a pt_regs trap frame. */
        sub	%fp, (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ), %t_kstack
	st 	%t_psr, [%t_kstack + (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ - 8)] /* sparc_fpuwindow_regs.irqpsr  */ 
	
	set	SPARC_PSR_EF_MASK, %t_twinmask
	andn	%t_psr, %t_twinmask, %t_psr	          ! fpu off
	
	PT_STORE_ALL_FAST(t_kstack, t_psr, t_pc, t_npc, g2)
        /*PT_STORE_GLOBALS(t_kstack)*/ 
	
	/* build a fp_regs trap frame. */
	sethi %hi(fpustate_current), %g2
	ld [%g2+%lo(fpustate_current)], %g3
	st %g3,[%t_kstack + (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ - 4)]    /* sparc_fpuwindow_regs.lastctx */
	add %t_kstack,SF_REGS_SZ + PT_REGS_SZ,%g3
	st 	%g3, [%g2+%lo(fpustate_current)]
	st	%g0, [%g3 + FW_FSR]
#else	
	/* build a pt_regs trap frame.
	 */
        sub	%fp, (SF_REGS_SZ + PT_REGS_SZ), %t_kstack
	PT_STORE_ALL_FAST(t_kstack, t_psr, t_pc, t_npc, g2)
	/*PT_STORE_GLOBALS(t_kstack)*/
#endif
	

#ifndef _FLAT
        /* See if we are in the trap window . */
	mov	1, %t_twinmask
	sll	%t_twinmask, %t_psr, %t_twinmask ! t_twinmask = (1 << psr)
	andcc	%t_twinmask, %t_wim, %g0
	beq	1f		! in trap window, clean up
	 nop

                /*-------------------------------------------------*/
                /* Spill , adjust %wim and go. */
                srl	%t_wim, 0x1, %g2	! begin computation of new %wim
		
		sethi %hi(_nwindows_min1), %g3
		ld [%g3+%lo(_nwindows_min1)], %g3

                sll	%t_wim, %g3, %t_wim	! NWINDOWS-1
                or	%t_wim, %g2, %g2
                and	%g2, 0xff, %g2		
        
                save	%g0, %g0, %g0           ! get in window to be saved
        
        	/* Set new %wim value */
                wr	%g2, 0x0, %wim

        	/* Save the kernel window onto the corresponding stack. */
                RW_STORE(sp)
        
        	restore	%g0, %g0, %g0
                /*-------------------------------------------------*/
        
1:                
#endif
	/* Trap from kernel with a window available.
	 * Just do it...
	 */
	jmpl	%t_retpc + 0x8, %g0	! return to caller
	 mov	%t_kstack, %sp		! jump onto new stack