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/winmacros.h> |
---|
28 | |
---|
29 | /* Registers to not touch at all. */ |
---|
30 | #define t_psr l0 /* Set by caller */ |
---|
31 | #define t_pc l1 /* Set by caller */ |
---|
32 | #define t_npc l2 /* Set by caller */ |
---|
33 | #define t_wim l3 /* Set by caller */ |
---|
34 | #define t_twinmask l4 /* Set at beginning of this entry routine. */ |
---|
35 | #define t_kstack l5 /* Set right before pt_regs frame is built */ |
---|
36 | #define t_retpc l6 /* If you change this, change winmacro.h header file */ |
---|
37 | #define t_systable l7 /* Never touch this, could be the syscall table ptr. */ |
---|
38 | #define curptr g6 /* Set after pt_regs frame is built */ |
---|
39 | |
---|
40 | /* Number of register windows */ |
---|
41 | .global _nwindows_min1, _nwindows |
---|
42 | |
---|
43 | .text |
---|
44 | .align 4 |
---|
45 | .globl leonbare_trapsetup_fast |
---|
46 | |
---|
47 | /* etap entry special for irqtrap.S */ |
---|
48 | leonbare_trapsetup_fast: |
---|
49 | |
---|
50 | #ifdef _FLAT |
---|
51 | restore |
---|
52 | RW_STORE(sp) |
---|
53 | save |
---|
54 | #endif |
---|
55 | |
---|
56 | #ifndef _SOFT_FLOAT |
---|
57 | /* build a pt_regs trap frame. */ |
---|
58 | sub %fp, (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ), %t_kstack |
---|
59 | st %t_psr, [%t_kstack + (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ - 8)] /* sparc_fpuwindow_regs.irqpsr */ |
---|
60 | |
---|
61 | set SPARC_PSR_EF_MASK, %t_twinmask |
---|
62 | andn %t_psr, %t_twinmask, %t_psr ! fpu off |
---|
63 | |
---|
64 | PT_STORE_ALL_FAST(t_kstack, t_psr, t_pc, t_npc, g2) |
---|
65 | /*PT_STORE_GLOBALS(t_kstack)*/ |
---|
66 | |
---|
67 | /* build a fp_regs trap frame. */ |
---|
68 | sethi %hi(fpustate_current), %g2 |
---|
69 | ld [%g2+%lo(fpustate_current)], %g3 |
---|
70 | st %g3,[%t_kstack + (SF_REGS_SZ + PT_REGS_SZ + FW_REGS_SZ - 4)] /* sparc_fpuwindow_regs.lastctx */ |
---|
71 | add %t_kstack,SF_REGS_SZ + PT_REGS_SZ,%g3 |
---|
72 | st %g3, [%g2+%lo(fpustate_current)] |
---|
73 | st %g0, [%g3 + FW_FSR] |
---|
74 | #else |
---|
75 | /* build a pt_regs trap frame. |
---|
76 | */ |
---|
77 | sub %fp, (SF_REGS_SZ + PT_REGS_SZ), %t_kstack |
---|
78 | PT_STORE_ALL_FAST(t_kstack, t_psr, t_pc, t_npc, g2) |
---|
79 | /*PT_STORE_GLOBALS(t_kstack)*/ |
---|
80 | #endif |
---|
81 | |
---|
82 | |
---|
83 | #ifndef _FLAT |
---|
84 | /* See if we are in the trap window . */ |
---|
85 | mov 1, %t_twinmask |
---|
86 | sll %t_twinmask, %t_psr, %t_twinmask ! t_twinmask = (1 << psr) |
---|
87 | andcc %t_twinmask, %t_wim, %g0 |
---|
88 | beq 1f ! in trap window, clean up |
---|
89 | nop |
---|
90 | |
---|
91 | /*-------------------------------------------------*/ |
---|
92 | /* Spill , adjust %wim and go. */ |
---|
93 | srl %t_wim, 0x1, %g2 ! begin computation of new %wim |
---|
94 | |
---|
95 | sethi %hi(_nwindows_min1), %g3 |
---|
96 | ld [%g3+%lo(_nwindows_min1)], %g3 |
---|
97 | |
---|
98 | sll %t_wim, %g3, %t_wim ! NWINDOWS-1 |
---|
99 | or %t_wim, %g2, %g2 |
---|
100 | and %g2, 0xff, %g2 |
---|
101 | |
---|
102 | save %g0, %g0, %g0 ! get in window to be saved |
---|
103 | |
---|
104 | /* Set new %wim value */ |
---|
105 | wr %g2, 0x0, %wim |
---|
106 | |
---|
107 | /* Save the kernel window onto the corresponding stack. */ |
---|
108 | RW_STORE(sp) |
---|
109 | |
---|
110 | restore %g0, %g0, %g0 |
---|
111 | /*-------------------------------------------------*/ |
---|
112 | |
---|
113 | 1: |
---|
114 | #endif |
---|
115 | /* Trap from kernel with a window available. |
---|
116 | * Just do it... |
---|
117 | */ |
---|
118 | jmpl %t_retpc + 0x8, %g0 ! return to caller |
---|
119 | mov %t_kstack, %sp ! jump onto new stack |
---|
120 | |
---|
121 | |
---|