1
2
3
4
5
6
7 #ifndef _SPARC_WINMACRO_H
8 #define _SPARC_WINMACRO_H
9
10 #include <asm/ptrace.h>
11 #include <asm/psr.h>
12
13
14 #define _SV save %sp, -REGWIN_SZ, %sp
15 #define _RS restore
16
17 #define FLUSH_ALL_KERNEL_WINDOWS \
18 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
19 _RS; _RS; _RS; _RS; _RS; _RS; _RS;
20
21
22
23
24 #define STORE_WINDOW(reg) \
25 std %l0, [%reg + RW_L0]; \
26 std %l2, [%reg + RW_L2]; \
27 std %l4, [%reg + RW_L4]; \
28 std %l6, [%reg + RW_L6]; \
29 std %i0, [%reg + RW_I0]; \
30 std %i2, [%reg + RW_I2]; \
31 std %i4, [%reg + RW_I4]; \
32 std %i6, [%reg + RW_I6];
33
34
35 #define LOAD_WINDOW(reg) \
36 ldd [%reg + RW_L0], %l0; \
37 ldd [%reg + RW_L2], %l2; \
38 ldd [%reg + RW_L4], %l4; \
39 ldd [%reg + RW_L6], %l6; \
40 ldd [%reg + RW_I0], %i0; \
41 ldd [%reg + RW_I2], %i2; \
42 ldd [%reg + RW_I4], %i4; \
43 ldd [%reg + RW_I6], %i6;
44
45
46 #define LOAD_PT_INS(base_reg) \
47 ldd [%base_reg + STACKFRAME_SZ + PT_I0], %i0; \
48 ldd [%base_reg + STACKFRAME_SZ + PT_I2], %i2; \
49 ldd [%base_reg + STACKFRAME_SZ + PT_I4], %i4; \
50 ldd [%base_reg + STACKFRAME_SZ + PT_I6], %i6;
51
52 #define LOAD_PT_GLOBALS(base_reg) \
53 ld [%base_reg + STACKFRAME_SZ + PT_G1], %g1; \
54 ldd [%base_reg + STACKFRAME_SZ + PT_G2], %g2; \
55 ldd [%base_reg + STACKFRAME_SZ + PT_G4], %g4; \
56 ldd [%base_reg + STACKFRAME_SZ + PT_G6], %g6;
57
58 #define LOAD_PT_YREG(base_reg, scratch) \
59 ld [%base_reg + STACKFRAME_SZ + PT_Y], %scratch; \
60 wr %scratch, 0x0, %y;
61
62 #define LOAD_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc) \
63 ld [%base_reg + STACKFRAME_SZ + PT_PSR], %pt_psr; \
64 ld [%base_reg + STACKFRAME_SZ + PT_PC], %pt_pc; \
65 ld [%base_reg + STACKFRAME_SZ + PT_NPC], %pt_npc;
66
67 #define LOAD_PT_ALL(base_reg, pt_psr, pt_pc, pt_npc, scratch) \
68 LOAD_PT_YREG(base_reg, scratch) \
69 LOAD_PT_INS(base_reg) \
70 LOAD_PT_GLOBALS(base_reg) \
71 LOAD_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc)
72
73 #define STORE_PT_INS(base_reg) \
74 std %i0, [%base_reg + STACKFRAME_SZ + PT_I0]; \
75 std %i2, [%base_reg + STACKFRAME_SZ + PT_I2]; \
76 std %i4, [%base_reg + STACKFRAME_SZ + PT_I4]; \
77 std %i6, [%base_reg + STACKFRAME_SZ + PT_I6];
78
79 #define STORE_PT_GLOBALS(base_reg) \
80 st %g1, [%base_reg + STACKFRAME_SZ + PT_G1]; \
81 std %g2, [%base_reg + STACKFRAME_SZ + PT_G2]; \
82 std %g4, [%base_reg + STACKFRAME_SZ + PT_G4]; \
83 std %g6, [%base_reg + STACKFRAME_SZ + PT_G6];
84
85 #define STORE_PT_YREG(base_reg, scratch) \
86 rd %y, %scratch; \
87 st %scratch, [%base_reg + STACKFRAME_SZ + PT_Y];
88
89 #define STORE_PT_PRIV(base_reg, pt_psr, pt_pc, pt_npc, pt_wim) \
90 st %pt_psr, [%base_reg + STACKFRAME_SZ + PT_PSR]; \
91 st %pt_pc, [%base_reg + STACKFRAME_SZ + PT_PC]; \
92 st %pt_npc, [%base_reg + STACKFRAME_SZ + PT_NPC]; \
93 st %pt_wim, [%base_reg + STACKFRAME_SZ + PT_WIM];
94
95 #define STORE_PT_ALL(base_reg, reg_psr, reg_pc, reg_npc, reg_wim, g_scratch) \
96 STORE_PT_PRIV(base_reg, reg_psr, reg_pc, reg_npc, reg_wim) \
97 STORE_PT_GLOBALS(base_reg) \
98 STORE_PT_YREG(base_reg, g_scratch) \
99 STORE_PT_INS(base_reg)
100
101 #define SAVE_BOLIXED_USER_STACK(cur_reg, scratch) \
102 ld [%cur_reg + THREAD_W_SAVED], %scratch; \
103 sll %scratch, 2, %scratch; \
104 add %scratch, %cur_reg, %scratch; \
105 st %sp, [%scratch + THREAD_STACK_PTRS]; \
106 sub %scratch, %cur_reg, %scratch; \
107 sll %scratch, 4, %scratch; \
108 add %scratch, %cur_reg, %scratch; \
109 STORE_WINDOW(scratch + THREAD_REG_WINDOW); \
110 sub %scratch, %cur_reg, %scratch; \
111 srl %scratch, 6, %scratch; \
112 add %scratch, 1, %scratch; \
113 st %scratch, [%cur_reg + THREAD_W_SAVED];
114
115
116 #define LOAD_CURRENT(dest_reg) \
117 sethi %hi(C_LABEL(current_set)), %dest_reg; \
118 ld [%dest_reg + %lo(C_LABEL(current_set))], %dest_reg;
119
120 #endif