• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file IA64syscallstub.h
3  * Assembly language file macros
4  *
5  * @remark Copyright 2002 OProfile authors
6  * @remark Read the file COPYING
7  *
8  * @author Bob Montgomery
9  */
10 
11 /* $Id: IA64syscallstub.h,v 1.3 2008/01/21 21:35:17 movement Exp $ */
12 
13 #define SYSCALLSTUB_POST(name)		\
14 	.sbss;				\
15 	.align 8;			\
16 	.type .post_saverp_##name, @object;	\
17 	.size .post_saverp_##name, 8;	\
18 .post_saverp_##name:			\
19 	.skip 8;			\
20 	.text;				\
21 	.global post_stub_##name;	\
22 	.align 32;			\
23 	.proc post_stub_##name;		\
24 post_stub_##name:			\
25 .L1_##name:				\
26 	mov r3=ip;			\
27 	;;				\
28 	addl r16=.L2_##name - .L1_##name, r3;	\
29 	;;				\
30 	mov b6=r16;			\
31 	;;				\
32 	br.ret.sptk.many b6;		\
33 	;;				\
34 .L2_##name:				\
35 	mov r3=ip;			\
36 	mov r15=gp;	/* save kgp */	\
37 	mov r17=rp;			\
38 	;;				\
39 	addl r14=.post_fptr_##name - .L2_##name, r3;	\
40 	;;				\
41 	ld8 r14=[r14];			\
42 	;;				\
43 	adds r14=8, r14;		\
44 	;;				\
45 	ld8 gp=[r14];			\
46 	;;				\
47 	addl r14=@ltoff(old_sys_##name), gp;    \
48 	addl r16=@gprel(.post_saverp_##name), gp;	\
49 	;;				\
50 	ld8 r14=[r14];			\
51 	st8 [r16]=r17;	/* save krp */	\
52 	;;				\
53 	ld8 r14=[r14];			\
54 	mov gp=r15;	/* restore kgp */	\
55 	;;				\
56 	ld8 r14=[r14];			\
57 	;;				\
58 	mov b6 = r14;			\
59 	;;				\
60 	br.call.sptk.many b0=b6;	\
61 	;;				\
62 .L3_##name:				\
63 	mov r3=ip;			\
64 	mov r15=gp;	/* save kgp */	\
65 	;;				\
66 	addl r14=.post_fptr_##name - .L3_##name, r3;	\
67 	;;				\
68 	ld8 r14=[r14];			\
69 	;;				\
70 	adds r14=8, r14;		\
71 	;;				\
72 	ld8 gp=[r14];			\
73 	br.call.sptk.many b0=post_call_stub_##name;	\
74 	;;				\
75 	addl r16=@gprel(.post_saverp_##name), gp;	\
76 	;;				\
77 	ld8 r14=[r16];			\
78 	;;				\
79 	mov b0 = r14;			\
80 	mov gp = r15; /* preserved */	\
81 	br.cond.sptk.many b0;		\
82 	.align 16;			\
83 .post_fptr_##name:				\
84 	data8 @fptr(post_sys_##name);	\
85 	.endp post_stub_##name;		\
86 	.align 16;			\
87 	.global post_call_stub_##name;	\
88 	.proc post_call_stub_##name;	\
89 post_call_stub_##name:			\
90 	alloc loc1=ar.pfs, 8, 6, 8, 0;	\
91 	mov loc0=rp;			\
92 	mov loc2=r15; /* preserve it */	\
93 	mov loc3=r8;			\
94 	mov loc4=r10;			\
95 	mov loc5=gp;			\
96 	mov out0 = r8;	/* old rv */	\
97 	mov out1 = in0;			\
98 	mov out2 = in1;			\
99 	mov out3 = in2;			\
100 	mov out4 = in3;			\
101 	mov out5 = in4;			\
102 	mov out6 = in5;			\
103 	mov out7 = in6;			\
104 	;;				\
105 	br.call.sptk.many rp = post_sys_##name;	\
106 	;;				\
107 	mov ar.pfs = loc1;		\
108 	mov rp = loc0;			\
109 	mov r15=loc2;			\
110 	mov r8=loc3;			\
111 	mov r10=loc4;			\
112 	mov gp=loc5;			\
113 	br.ret.sptk.few	rp;		\
114 	.endp post_call_stub_##name;
115 
116 #define SYSCALLSTUB_PRE(name)		\
117 	.text;				\
118 	.global pre_stub_##name;	\
119 	.align 32;			\
120 	.proc pre_stub_##name;		\
121 pre_stub_##name:			\
122 .L4_##name:				\
123 	mov r3=ip;			\
124 	;;				\
125 	addl r17=.L5_##name - .L4_##name, r3;	\
126 	;;				\
127 	mov b6=r17;			\
128 	;;				\
129 	br.ret.sptk.many b6;		\
130 	;;				\
131 .L5_##name:				\
132 	mov r3=ip;			\
133 	mov r15=gp;	/* save kgp */	\
134 	mov r16=rp;	/* save krp */	\
135 	;;				\
136 	addl r14=.pre_fptr_##name - .L5_##name, r3;	\
137 	;;				\
138 	ld8 r14=[r14];			\
139 	;;				\
140 	adds r14=8, r14;		\
141 	;;				\
142 	ld8 gp=[r14];			\
143 	;;				\
144 	br.call.sptk.many b0=pre_call_stub_##name;	\
145 	;;				\
146 	/* kernel gp still in r15 */	\
147 	/* kernel rp still in r16 */	\
148 	/* module gp in gp */		\
149 	;;				\
150 	addl r14=@ltoff(old_sys_##name), gp;    \
151 	;;				\
152 	ld8 r14=[r14];			\
153 	;;				\
154 	ld8 r14=[r14];			\
155 	mov gp=r15; /* restore kgp */	\
156 	;;				\
157 	ld8 r14=[r14];			\
158 	mov rp=r16; /* restore krp */	\
159 	;;				\
160 	mov b6 = r14;			\
161 	;;				\
162 	/* use the saved krp */		\
163 	br.call.sptk.many b6=b6;	\
164 	;;				\
165 	.align 16;			\
166 .pre_fptr_##name:				\
167 	data8 @fptr(pre_sys_##name);	\
168 	.endp pre_stub_##name;		\
169 	.align 16;			\
170 	.global pre_call_stub_##name;	\
171 	.proc pre_call_stub_##name;	\
172 pre_call_stub_##name:			\
173 	alloc loc1=ar.pfs, 8, 5, 8, 0;	\
174 	mov loc0=rp;			\
175 	mov loc2=r15; /* preserve it */	\
176 	mov loc3=r16; /* preserve it */	\
177 	mov loc4=gp;			\
178 	mov out0 = in0;			\
179 	mov out1 = in1;			\
180 	mov out2 = in2;			\
181 	mov out3 = in3;			\
182 	mov out4 = in4;			\
183 	mov out5 = in5;			\
184 	mov out6 = in6;			\
185 	mov out7 = in7;			\
186 	;;				\
187 	br.call.sptk.many rp = pre_sys_##name;	\
188 	;;				\
189 	mov ar.pfs = loc1;		\
190 	mov rp = loc0;			\
191 	mov r15=loc2;			\
192 	mov r16=loc3;			\
193 	mov gp=loc4;			\
194 	br.ret.sptk.few	rp;		\
195 	.endp pre_call_stub_##name;
196 
197 
198